Using the MC9S08DZ60 and utilizing overflow of TPM1 to generate an interrupt every 1ms for my time base. I am having coherency issues when using a 16 bit (unsigned int) variable as a timer even though I stop interrupts before loading the number. Looking at a port I toggle, I have proved that the high byte is being decremented occasionally before the low byte is loaded giving me 44ms (0x2c) instead of 300ms (0x12c). Below is a simplified example (COSMIC tools, not CodeWarrior). I'm at my wits end and any suggestions would be appreciated.
unsigned int x;
x = 300;
/* Do something */
TPM1SC &=0x7F; //RESET INTERRUPT FLAG
Added p/n to subject.