I'm trying to replicate the "simple" CTC mode for timer0, but NOTHING is simple with the Xmega. :evil:
The timer is running, the IVEC_TCC0_CCA_vect ISR fires but the overall time is out by about 256 times!! (Supposed to be 4ms)
The clock is running at 4MHz but I don't understand if this is also the peripheral clock.
TCC0_CTRLA is at the moment at DIV1 (was 64)
TCC0_CTRLB is set for FREQ which supposedly has CCA as top.
TCC0_CCA is set at 250
the old formula was 250ns*64*250=4ms so I guess that the timer clock is not the 4MHz.
I have 2 LEDs toggling in the ISR at 100ms and 1s but I can see that the 1s led is flashing at 4s (stopwatch timed) and the 100ms led looks more like a 400ms flash.
Other timers are also out by a factor of 4 (x64 or 256x if I set the prescaler at 64 which was)
Can anyone shed any light on this please? :)