I am using timer 2 in my atmega16 for a Compare match interrupt but for some reason the program crashes as soon as it reaches the statement sei();
then it restarts again ..
here's the code
#define F_CPU 8000000
the code in blue which glows a LED for 500millisec one time goes on repeating forever indicating restarts
if I remove the sei(); statement then its fine the LED glows only one time
what is the problem here
then it restarts again ..
here's the code
#define F_CPU 8000000
Rich (BB code):
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
int main(void)
{
DDRB=0xff;
PORTB=0xff;
_delay_ms(500);
PORTB=0;
_delay_ms(500);
TIMSK|=(1<<OCIE2);
TCCR2|=(1<<WGM21)|(1<<CS22)|(1<<CS21);
sei();
OCR2=25;
while(1){
}
}
ISR(TIMER2_COMPA_vect){
}
if I remove the sei(); statement then its fine the LED glows only one time
what is the problem here