At the moment I'm trying to learn microcontrollers with Arduino, and have a problem with the timer.
Arduino works at 16MHz clock, and the best prescaler is 1024, which means the timer increments the value every 64 us. Timer 3 is a 16 bit timer, which gives us a maximum time of 64*65535= 4194240, ca. 4s
But what if I want to do a job every 8 seconds? Any idea?
Here's my code:
TCCR3A = 0; TCCR3B = 0; TCCR3B |= (1<<WGM32); //CTC TCCR3B |= (1 << CS32); TCCR3B |= (1 << CS30);// 1024 prescaler TIMSK3 |= (1<<OCIE3A); sei();