Timer/PWM Module (TPM)
MCF51CN128 Reference Manual, Rev. 6
19-19
Freescale Semiconductor
The TPM module provides high-true interrupt signals.
19.6.2
Description of Interrupt Operation
For each interrupt source in the TPM, a flag bit is set upon recognition of the interrupt condition such as
timer overflow, channel input capture, or output compare events. This flag is read (polled) by software to
determine that the action has occurred, or an associated enable bit (TOIE or CHnIE) can be set to enable
the interrupt generation. While the interrupt enable bit is set, the interrupt is generated whenever the
associated interrupt flag is set. Software must perform a sequence of steps to clear the interrupt flag before
returning from the interrupt-service routine.
TPM interrupt flags are cleared by a two-step process including a read of the flag bit while it is set followed
by a write of zero to the bit. If a new event is detected between these two steps, the sequence is reset and
the interrupt flag remains set after the second step to avoid the possibility of missing the new event.
19.6.2.1
Timer Overflow Interrupt (TOF) Description
The meaning and details of operation for TOF interrupts varies slightly depending upon the mode of
operation of the TPM system (general purpose timing functions versus center-aligned PWM operation).
The flag is cleared by the two step sequence described above.
19.6.2.1.1
Normal Case
When CPWMS is cleared, TOF is set when the timer counter changes from the terminal count (the value
in the modulo register) to 0x0000. If the TPM counter is a free-running counter, the update is made when
the TPM counter changes from 0xFFFF to 0x0000.
19.6.2.1.2
Center-Aligned PWM Case
When CPWMS is set, TOF is set when the timer counter changes direction from up-counting to
down-counting at the end of the terminal count (the value in the modulo register).
19.6.2.2
Channel Event Interrupt Description
The meaning of channel interrupts depends on the channel’s current mode (input capture, output compare,
edge-aligned PWM, or center-aligned PWM).
Table 19-7. Interrupt Summary
Interrupt
Local
Enable
Source
Description
TOF
TOIE
Counter overflow
Set each time the TPM counter reaches its terminal
count (at transition to its next count value)
CHnF
CHnIE
Channel event
An input capture event or channel match took place
on channel n