I am trying to set timer interrupt in CTC mode . I am not using any prescalar value and I am using the max count for 16 bit OCR register .
this should give me a delay of 592ms according to my calculations .
In the ISR I am multiplying this period by 10 so I should get a delay of around 6 secs but I see my control goes to the ISR routine but I am not getting 6 secs
delays.
iam using ATMEGA1284p with 11.0592MHz clock.
what am I missing here?
uint16_t HeartBeat=0; void timer1_init() { /*--------------------------------------------------------------- required_delay=(timer_counter+1)Xclock_time_period //11.0592MHz =(65535+1)x 9.04x10E-6 = 592ms ----------------------------------------------------------------*/ // set up timer1 with no prescaler and CTC mode TCCR1A |= (1 << WGM11); TCCR1B |= (1 << CS10); // initialize counter TCNT1 = 0; // initialize compare value OCR1A = 65535; // enable compare interrupt TIMSK1 |= (1 << OCIE1A); // enable global interrupts sei(); } ISR (TIMER1_COMPA_vect) { HeartBeat++; if(HeartBeat > 10) { HeartBeat = 0; TFT_String(10,100,"HERE..." ,RED,txt_bg_color,3); _delay_ms(1000); TFT_String(10,100,"HERE..." ,txt_bg_color,txt_bg_color,3); } }