I am using an arduino mega2560 and I want to set up timer5 in CTC mode to generate an interrupt every 250ms
The arduino board is running at 16MHz and I am using the arduino libraries (I have to) but I want to set up this timer manually. Here is how I set up the timer:
TCCR5A = 0x00; TCCR5B = (1<<WGM52)|(1<<CS52) OCR5A = 15624; TIMSK5 = 0x02;
I'm setting the prescaler to 256, enabling ctc mode, setting OCR5A to my desired value, and enabling the compare match A interrupt for timer5.
However it's running way too fast. On closer inspection of TCNT5 it seems the counter is only counting up to 0xFF (making it behave like an 8 bit timer)
I've spent hours just trying to figure this out. Any help would be appreciated.