Peter Eckstrand

Output compare questions

Discussion created by Peter Eckstrand on Mar 25, 2008
Latest reply on Mar 25, 2008 by bigmac
I'm using a HCS08 controller.
I use the TPM1C0 to generate a tick at 1ms.
Now I want to implement a timer that gives a time out if two SCI RX interrupts are separated more than 500 us.
Is it possible to use another channel of TPM1, say TPM1C1, and in the RX ISR after reading the received data, read the TPM1 counter value, calculate the value that corresponds to +500us, set this value as the TPM1C1 compare value, and then enable output compare interrupt?
In pseudo-code:
Code:ISR{  read received data  disable output compare interupt  read TPM1 counter value  calculate counter value + 500us  enable output compare for TPM1C1  set TPM1C1 compare value}

 Will this work?