I'm running the MCU off the high speed (16MHz, confirmed) internal oscillator and I've configured timer 1 to overflow with maximum overflow frequency:
/* No system clock pre-division, overflow upon reaching 0x0001 (starting from 0x0000) */
TIM1_TimeBaseInit(0, TIM1_CounterMode_Up, 0x0001, 0);
Once in the timer 1 overflow handling routine, I toggle a pin. For some reason I'm getting only getting a 32kHz square wave on that pin (hence 64kHz interrupt frequency).
Why is it so slow?
The same problem occurs with other timers as well.
Update: Ok, so I ran the timer with reasonable settings. Below are results for:
500 counts
300 counts
200 counts (unstable as hell)
100 counts
50 counts (frequency is the same down to 0 counts)