hi all,
When i try to simulate my code using AVR studio, i found that after the first time the program enter the ISR, instruction will go lost.
The result from my PORTA just keep blinking.Why my counter wont continue counting until 10?
#include#include #define F_CPU 4000000 volatile int counter=0; int main(void) { DDRA= 0xFF; PORTA = 0xFF; TIMSK |= (1 << TOIE1); sei(); //Preloaded value TCNT1 = 64535; TCCR1B |= (1<<CS11); while(1) { } } ISR(TIMER1_OVF_vect) { counter++; TCCR1B = 0X00; //OFF TIMER switch(counter) { case 10: PORTA ^= (1 << 0); TCNT1 = 64535; TCCR1B|= (1<<CS1); break; } PORTA ^= (1 << 0); TCNT1 = 64535; TCCR1B |= (1<<CS11); }
thank you.