#include "avr/interrupt.h"
int main(void)
{
//Configuration ----------------------------------------------------
//Config Port A as Output using some helper function
GPIO::Port_Direction(GPIO_PORT_A,GPIO_DIRECTION_OUTPUT);
//Set Timer Initial Value = 0
TCNT2=0;
//Set Timer Mode To Normal and Prescaler 1024
TCCR2=0b00000101;
//Enable Global Interrupt using register (SREG)
BITWISE_SET_BIT(SREG,SREG_I); //or use sei();
//Enable Timer2 Interrupt using register (TIMSK)
BITWISE_SET_BIT(TIMSK,TOIE2);
//Loop ----------------------------------------------------
while(1)
{
GPIO::Pin_Clear(GPIO_IO_PA1);
delay_ms(1000);
GPIO::Pin_Set(GPIO_IO_PA1);
delay_ms(1000);
}
}
int timer2Counter;
ISR(TIMER2_OVF_vect)
{
timer2Counter++;
//if i use 488 which (61*8) it work correct and generate 1 second timer , but if i use 61 generate 125ms this issue only with timer2 but with timer0 61 worked fine
if(timer2Counter==61)
{
GPIO::Pin_Toggle(GPIO_IO_PA2);
timer2Counter=0;
}
}