Greetings All,
I have a question regarding stability of wave frequency, which produced by MTIM timer module in MC9S08QG8 device. The problem appears when timer runs in high speed - the frequency of produced wave is not stable (more then 2%)!
I evaluate this chip using internal click source at maximal buss speed after trimming correction.
Platform: Freescele EVB - DEMO09S08QG8.
I set timer by following values:
MTIMCLK_PS = 2; // 2*38=>should give 25us period
MTIMCLK_CLKS = 0; // 0-Bus clock; 1-fixed-freq. clock
MTIMMOD = 38; // Modulo value for 25us period
MTIMSC &=~ 0x90; // clear TOF and exit stop TSTP
MTIMSC |= 0x60; // reset and start MTIM, enable interrupts (TOIE)
COP is fed regularly.
The only allowed interrupt is conducted with MTIM with toggling some hardware pin with connection to scope allowing accurate frequency measure.
The interrupt looks like:
interrupt 12 void MTIM_ISR(void)
{
volatile U_CHAR x;
LED2 = ~LED2; // toggle pin - set to high – connected to the scope
x = MTIMSC_TOF;
MTIMSC_TOF = 0; // clear TOF flag
MTIMSC_TRST = 1; // reset counter
LED2 = ~LED2; // toggle pin - set to low – connected to the scope
}
As I mentioned, the output signal is not stable. The stability is above 2%. Accuracy depends on quantity of tasks inside main loop (again: there are no additional interrupts in my code).
I have tested it also on demo application demo9S08QG8_test.c, which comes with EVB. The same result - when I speed up the timer frequency, the signal becomes unstable.
Had some body experience the same problem or can advice.
Thanks in advance.