Russ Ether

HCS08 TPM "input capture"  both edges

Discussion created by Russ Ether on Nov 14, 2006
Latest reply on Nov 17, 2006 by Russ Ether
I have an application where I need to read an input PWM signal that can vary from 0% to 100% duty cycle.
I assume that TPM "input capture" was designed for this purpose and is the cleanest way to do it?
If I set up the TMP channel to trigger on both edges (rising and falling),  what is the best way for my interrupt routine to determine whether it was a rising or falling edge which triggered the interrupt?   My ISR needs to be able to determine this, so it knows whether to just store the counter value (for the beginning of the pulse) or to compute the pulse width (for the end of the pulse).
Also, what is the best way to handle 0% and 100% duty cycles, since there would not be any interrupts generated?
I'm sure there are a gazillion ways to handle these situations, but I am wondering how experienced HCS08 programmers usually do it.