Oct 25, 2013 #1 D djc Advanced Member level 1 Joined Jan 27, 2013 Messages 402 Helped 3 Reputation 6 Reaction score 2 Trophy points 1,298 Location India 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.
Hi, Can somebody guide me how to generate 500 ms delay using any of the timer like Timer 0 or Timer 1 of ATMEGA8.
Oct 25, 2013 #2 N nick703 Advanced Member level 1 Joined Oct 17, 2011 Messages 422 Helped 21 Reputation 44 Reaction score 22 Trophy points 1,298 Location surat Activity points 3,987 use this link and try to your self if any error then post . https://sites.google.com/site/qeewiki/books/avr-guide/timer-on-the-atmega8
use this link and try to your self if any error then post . https://sites.google.com/site/qeewiki/books/avr-guide/timer-on-the-atmega8
Oct 25, 2013 #3 jayanth.devarayanadurga Banned Joined Dec 4, 2012 Messages 4,280 Helped 822 Reputation 1,654 Reaction score 791 Trophy points 1,393 Location Bangalore, India Activity points 0 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 }
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 }
Oct 29, 2013 #4 D djc Advanced Member level 1 Joined Jan 27, 2013 Messages 402 Helped 3 Reputation 6 Reaction score 2 Trophy points 1,298 Location India Activity points 4,554 Thank you jayanth and nick, i am able to generate 500ms interrupt now.
Dec 25, 2013 #5 D djc Advanced Member level 1 Joined Jan 27, 2013 Messages 402 Helped 3 Reputation 6 Reaction score 2 Trophy points 1,298 Location India Activity points 4,554 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.
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.
Dec 25, 2013 #6 alexan_e Administrator Joined Mar 16, 2008 Messages 11,888 Helped 2,021 Reputation 4,158 Reaction score 2,031 Trophy points 1,393 Location Greece Activity points 64,371 Seems like you didn't read the linked guide the previous time and you have just used the solution that was provided. Here is another guide that explains everything about AVR timers https://www.github.com/abcminiuser/avr-tutorials/blob/master/Timers/Output/Timers.pdf?raw=true
Seems like you didn't read the linked guide the previous time and you have just used the solution that was provided. Here is another guide that explains everything about AVR timers https://www.github.com/abcminiuser/avr-tutorials/blob/master/Timers/Output/Timers.pdf?raw=true
Dec 25, 2013 #7 D djc Advanced Member level 1 Joined Jan 27, 2013 Messages 402 Helped 3 Reputation 6 Reaction score 2 Trophy points 1,298 Location India Activity points 4,554 Thanx alexan, I found the fault where i was actually lacking.