|
From: | Clemens Koller |
Subject: | Re: [avr-gcc-list] Problem with timer0 overflow interrupt in c language.. |
Date: | Thu, 06 Dec 2007 21:50:30 +0100 |
User-agent: | Thunderbird 2.0.0.9 (Windows/20071031) |
Sach schrieb:
Hi friends, I m programming with WinAVR for ATMega32 8-bit RISC from atmel. I have tried to write timer overflow interrupt and LED toggle everytime when timer0 overflows. In this code i have not got the output result. So please help me with this issue. Here the code that i have written is given below: #include <avr\io.h> #include <avr\interrupt.h> void main(void) { SP = 0x085F; TCCR0 = (1<<CS02)|(1<<CS00); TIFR = 1<<TOV0; TIMSK = 1<<TOIE0; DDRB = 0xFF; sei(); while(1); } ISR (TIMER0_OVF_vect) { cli(); PORTB = ~PORTB; // Toggle pins on Port B }
Tried to remove the cli(); ? You won't get any interrupts after cli(); And try one of so many examples out there. Here is another one from some code of mine: (not compile tested...): #include <...> int timer0; void timer0_init(void) { timer0 = 0; /* timer0 prescaler = clk/1042 -> 11059200Hz / 1024 = 10800Hz per increment */ /* overflow every 256 ticks = 42.1875Hz = 23.7037ms an interrupt */ TCCR0B |= _BV(CS00) | _BV(CS02); TCNT0 = 0; TIMSK0 |= _BV(TOIE0); /* and take care that the timers are not in power down mode */ } ISR(TIMER0_OVF_vect) { /* don't use cli(); here */ timer0++; /* or toggle your LED */ } int main(void ) { PORTB = 0xff; /* i.e. all to output */ timer0_init(); sei(); /* do something else here */ } Well... good luck... Regards, -- Clemens Koller __________________________________ R&D Imaging Devices Anagramm GmbH Rupert-Mayer-Straße 45/1 Linhof Werksgelände D-81379 München Tel.089-741518-50 Fax 089-741518-19 http://www.anagramm-technology.com
[Prev in Thread] | Current Thread | [Next in Thread] |