Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[AVR] 500ms delay using timer in ATMEGA8

Status
Not open for further replies.

djc

Advanced Member level 1
Advanced Member level 1
Joined
Jan 27, 2013
Messages
402
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Visit site
Activity points
4,554
Hi,

Can somebody guide me how to generate 500 ms delay using any of the timer like Timer 0 or Timer 1 of ATMEGA8.
 

For ATMEGA8 at 8 MHz Clock.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//Timer1 Prescaler = 64; Preload = 62499; Actual Interrupt Time = 500 ms
 
//Place/Copy this part in declaration section
void InitTimer1(){
  SREG_I_bit = 1; 
  TCCR1A = 0x80;
  TCCR1B = 0x0B;
  OCR1AH = 0xF4; 
  OCR1AL = 0x23; 
  OCIE1A_bit = 1; 
}
 
void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_COMPA {
  //Enter your code here 
}

 

Thank you jayanth and nick, i am able to generate 500ms interrupt now.
 

hi jayanth,

I am again facing a problem in timer reload value. Now i want to generate 1sec output compare interrupt. So how to calculate timer reload value. Please guide me.
 

Thanx alexan,

I found the fault where i was actually lacking.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top