Timer/PWM Module (TPM)
MCF51CN128 Reference Manual, Rev. 6
Freescale Semiconductor
19-18
Input capture, output compare, and edge-aligned PWM functions do not make sense when the counter is
operating in up/down counting mode so this implies that all active channels within a TPM must be used in
CPWM mode when CPWMS is set.
The timer channel registers are buffered to ensure coherent 16-bit updates and to avoid unexpected PWM
pulse widths. Writes to any of the registers TPMxCnVH and TPMxCnVL actually write to buffer registers.
In center-aligned PWM mode, the TPMxCnVH:TPMxCnVL registers are updated with the value of their
write buffer according to the value of CLKSB:CLKSA bits:
•
If CLKSB and CLKSA are cleared, the registers are updated when the second byte is written
•
If CLKSB and CLKSA are not cleared, the registers are updated after both bytes were written, and
the TPM counter changes from (TPMxMODH:TPMxMODL – 1) to
(TPMxMODH:TPMxMODL). If the TPM counter is a free-running counter, the update is made
when the TPM counter changes from 0xFFFE to 0xFFFF.
When TPMxCNTH:TPMxCNTL equals TPMxMODH:TPMxMODL, the TPM can optionally generate a
TOF interrupt (at the end of this count).
19.5
Reset Overview
19.5.1
General
The TPM is reset whenever any MCU reset occurs.
19.5.2
Description of Reset Operation
Reset clears TPMxSC that disables TPM counter clock and overflow interrupt (TOIE=0). CPWMS,
MSnB, MSnA, ELSnB, and ELSnA are all cleared. This configures all TPM channels for input capture
operation and the associated pins are not controlled by TPM.
19.6
Interrupts
19.6.1
General
The TPM generates an optional interrupt for the main counter overflow and an interrupt for each channel.
The meaning of channel interrupts depends on each channel’s mode of operation. If the channel is
configured for input capture, the interrupt flag is set each time the selected input capture edge is
recognized. If the channel is configured for output compare or PWM modes, the interrupt flag is set each
time the main timer counter matches the value in the 16-bit channel value register.
All TPM interrupts are listed in
.