Hi,
I took your code and rewrote some parts of it.
1) You should never reset the TPMCNT. It is only reset when coming out of reset.
This means that all the timing parameter that you enter should be relative, not absolute.
2) Your application, if I have understood it, only requiers 1 interrupt. It is the interrupt from the falling 100 Hz input signal.
In this interrupt , there are two ways of setting the desired pulse width.
Either the outgoing pulse width is important, then read the TPMCNT, add 0x18 and store it in the TPM1C1V register.
Or if the time from the falling edge to the trailing edge of the pulse width is vital, then read the TPM1C0V, add 0x18 and store it in TPMC1V.
Use the PULSEHIGHTIME macro to select either method.
3) The interrupt at the trailing edge of the outgoing pulse is not important.
You can select to have them with the code using the CH1INTERRUPT macro.
4) Sorry, I did not have the time to make a beautiful source code. Hope it is readable anyhow.
I ran the code on a DEMO9S08SH8, which is slightly different than the 9S08SG8. I think that the code will run just the same on a 9S08SG8 MCU.
Regards,
Ake