Note: The waveforms in this chapter show the behavior
of the MCPWMs for a static compare register value. In a running system, the active
compare registers (PWMx_CMPA and PWMx_CMPB) are typically updated from the
respective shadow registers (PWMx_CMPAS and PWMx_CMPBS) once every period. Specify
when the update takes place: either when the time-base counter reaches zero or when
the time-base counter reaches the period. There are some cases when the action based
on the new value can be delayed by one period or the action based on the old value
can take effect for an extra period. Some PWM configurations avoid this situation.
These include, but are not limited to, the following:
Use up-down count mode to
generate a symmetric PWM:
Use up-down count
mode to generate an asymmetric PWM:
- To achieve 50%-0%
asymmetric PWM, use the following configuration: load
PWMx_CMPA/PWMx_CMPB on period and use the period action to clear the PWM
and a compare-up action to set the PWM. Modulate the compare value from
0 to TBPRD to achieve 50%-0% PWM duty.
When using
up-count mode to generate an asymmetric PWM:
- To achieve 0-100%
asymmetric PWM, load PWMx_CMPA/PWMx_CMPB on TBPRD. When
PWMx_CMPA/PWMx_CMPB is not loaded on TBCTR = PRD, boundary conditions
can occur depending on the timing of the write and the value written to
PWMx_CMPA/PWMx_CMPB. Use the Zero action to set the PWM and a compare-up
action to clear the PWM. Modulate the compare value from 0 to TBPRD + 1
to achieve 0-100% PWM duty.
When using
up-count mode to generate an asymmetric PWM with dead-band enabled:
- To achieve 0%-100% PWM,
use the following configuration: When the PWMx_CMPA value is too close
to 0 or PRD such that the following conditions are met (CMPX <
Deadband) or (CMPX > PRD – Deadband), the actions specified by the
AQCTL register for CMPX do not take effect. To avoid this, the AQCTL
settings must be altered under these conditions only to generate either
high or low pulses for both CAU or CAD events (both set or both clear).
Make sure that this software update is occurring synchronous to the PWM
carrier cycle, and shadow mode is enabled.
When using up-down
count mode to generate an asymmetric PWM with dead-band enabled:
- To achieve 0%-100% PWM,
use the following configuration: When the PWMx_CMPA value is too close
to 0 or PRD such that the following conditions are met (CMPX <
Deadband/2) or (CMPX > PRD – (Deadband)/2), the actions specified by
the AQCTL register for CMPX do not take effect. To avoid this, the AQCTL
settings must be altered under these conditions only to generate either
high or low pulses for both CAU or CAD events (both set or both clear).
Make sure that this software update is occurring synchronous to the PWM
carrier cycle, and shadow mode is enabled.
See Using
Enhanced Pulse Width Modulator (ePWM) Module for 0-100% Duty Cycle
Control.
Figure 15-22 shows how a symmetric PWM waveform can be generated using the up-down-count mode
of the TBCTR. In this mode, 0%-100% DC modulation is achieved by using equal compare
matches on the up count and down count portions of the waveform. In the example
shown, PWMx_CMPA is used to make the comparison. When the counter is incrementing,
the PWMx_CMPA match pulls the PWM output high. Likewise when the counter is
decrementing, the compare match pulls the PWM signal low. When PWMx_CMPA = 0, the
PWM signal is high for the entire period giving a 100% duty waveform. When PWMx_CMPA
= TBPRD, the PWM signal is low achieving 0% duty.
When using this configuration in practice, if
loading PWMx_CMPA/PWMx_CMPB on zero, then use PWMx_CMPA/PWMx_CMPB values greater
than or equal to 1. If loading PWMx_CMPA/PWMx_CMPB on period, then use
PWMx_CMPA/PWMx_CMPB values less than or equal to TBPRD - 1. This means there is
always a pulse of at least 1 TBCLK cycle in a PWM period which, when very short,
tend to be ignored by the system.
The following PWM waveforms show some common
action-qualifier configurations. Some conventions used in the figures and examples
are as follows:
- TBPRD, PWMx_CMPA, and PWMx_CMPB refer to the value written in the respective registers. The active register, not the shadow register, is used by the hardware.
- CMPx, refers to either PWMx_CMPA or PWMx_CMPB.
- MCPWMx_yA and MCPWMx_yB refer to the output
signals from MCPWMx, Channel pair y.
- Up-Down means count-up and count-down mode, Up
means up-count mode.
- Sym = Symmetric, Asym = Asymmetric.
A. PWM period = (TBPRD + 1) ×
TTBCLK
B. Duty modulation for MCPWMx_yA is
set by PWMy_CMPA, and is active high (that is, high time duty proportional to
PWMy_CMPA).
C. Duty modulation for MCPWMx_yB is
set by PWMy_CMPB and is active high (that is, high time duty proportional to
PWMy_CMPB).
D. The "Do Nothing" actions (X) are
shown for completeness, but are not shown on subsequent diagrams.
E. Actions at zero and period,
although appearing to occur concurrently, are actually separated by one TBCLK
period. TBCTR wraps from period to 0000.
Figure 15-23 Up,
Single Edge Asymmetric Waveform, with Independent Modulation on PWMxA and
PWMxB—Active High