TPM module issue with HC9S08SG16

Showing results for 
Search instead for 
Did you mean: 

TPM module issue with HC9S08SG16

Contributor III



I have a question regarding the Timer module TPM. I try to use this timer with the Edge-Aligned PWM mode activated so that i can (when needed) generate some pulse with variable frequency on a I/O pin. I was able to generate the pulse but have difficulties to stop the timer properly. I observed that the cycle: start timer / stop timer / start timer / and so on... doesn't work properly.

I'm using the overflow status flag (TOF of the TPM1SC) with the interrupts enabled so that i have a software interruption (isrVtpm1ovf) at each timer overflow (when TPM1CNT reaches TPM1MOD). The TPM1C0SC is configured in Edge-aligned PWM mode and TPM1C0V is loaded with my pulse width time value (this is a fix time).


In the interrupt isrVtpm1ovf, i want either to change the modulo value or to stop the timer. I don't have issue for changing the modulo value but when it comes to stop the timer and then, later in my main loop program, start it again, a pulse is generated without software interrupt. Like if something was still in the internal bus of the TPM module and released directly after that i start the timer again, even though i have make sure that all counters and registers related to TPM were correctly cleared.


What i could observe is that my instruction to stop the timer + disable the interrupt (CLR TPM1SC) happened during the generation of the pulse (so that the pulse is not completed when the timer stops), is this could be the root of the issue ?

Because if i stops the timer after that the pulse is completed, then i don't have this kind of unexpected pulse and everything seem to work. However i don't think it's the correct operation to do and i can't explain why this works only like that, moreover the datasheet doesn't mention this kind of behavior. Also from my understanding, any write to the TPM1SC register reset the latching mechanism and so nothing should remain into the internal bus of the TPM module.


Thank you in advance for your help.

Labels (1)
0 Kudos
1 Reply

NXP TechSupport
NXP TechSupport


Do you still have problems?


Vicente Gomez

0 Kudos