I am working on a project which requires use of 16bit timer . I am using Arduino Uno (Atmega 328p) board and Timer_1 (16 bit timer ) in Overflow mode. i want to use 1024 prescaler settings.
According to the datasheet of the controller i have to set [b]CS10 and CS12[/b] bits to use 1024 prescaler but the problem is OverFlow interrupt routine is never fired when 1024 or 256 prescaler is selected .
The Following code works just fine with Prescaler set to 8 or 64.
#include <inttypes.h>
volatile uint8_t sCount = 0;
void setup()
{
Timer_one_16_init(); // configure the timer
pinMode(13,OUTPUT);
}
void loop()
{
// do nothing
}
void Timer_one_16_init(){
TCCR1A = 0;
// set the pre-scaler to 1024 (slowest)
TCCR1B |= (1<<CS12)|(1<<CS10);
// set the bottom / starting value
TCNT1 = 0x00;
// set Overflow interrupt
TIMSK1 |= (1<<TOIE1);
// enable global interrupt
sei();
}
ISR(TIMER1_OVF_vect){
sCount++;
if (sCount == 60)
{
digitalWrite(13,!digitalRead(13));
sCount = 0;
}
}
i have no idea why this is happening. i have done everything which is given in the datasheet .
Am i doing something wrong ?
Thanks in advance