I'm trying to blink an led without using the delay function. I came across using the timer interrupt and I tried it, and it compiles fine. But the output is fixed on PORTA = 0x01; so, I believe the ISR function is not working. Is there anything I am missing in the code? Thanks.
#include <asf.h>
#include <avr/interrupt.h>
volatile unsigned int count=0;
volatile unsigned int tTime=0;
void port_init(void) {
PORTA = 0xff;
}
ISR(TIMER0_OVF_vect)
{
TCNT0 = 206;
count++;
if (count < 625) {
PORTA=0x01;
}
else if ((count > 625) && (count < 1250)) {
PORTA=0x00;
}
else {
count=0;
}
}
int main (void)
{
board_init();
port_init();
TCCR0 = 0x06; //setting dispensing ratio
TCNT0 = 206; //initial value of register
TIMSK = 0x01; //enabling interrupt
SREG=0x80;
DDRA=0xff;
while(1){
}
}