Richard Serge

MTIM Quirk (QG8) - Reset dependent upon COUNT

Discussion created by Richard Serge on Jul 30, 2006
Latest reply on Aug 5, 2006 by Richard Serge
In testing whether or not the Modulo Timer's prescaler in a QG8 is reset when you reset the timer or store a new value in the Modulo register (it IS reset, BTW), I discovered a quirk about the timer that can kill ya.

If you reset the timer by setting the TRST bit in MTIMSC or by storing a new value in the MODULO register, the timer WILL STILL TIME OUT ON THE VERY NEXT CLOCK if the COUNT register was equal to the MODULO count at the time of reset.

For example, lets say the output of the prescaler is 1 KHz (1ms period), and your MODULO value was 99. If you set the TRST bit at a count of 98 (or less), then the COUNT will reset to 0 and the timer will not time out until 100ms after setting TRST. This is the expected result. However, if you set TRST while the COUNT is 99 then the timer will time out within 1 ms (at the next clock output from the prescaler).

I've seen warnings in the data sheet before about things that can kill ya but this one should be in a bold red font, and it's not even mentioned.

Talk about a time bomb.

I'm still working on a way around this and when I have something that works 100 percent I'll post it here... or someone else can and save me the time.