AN4485, Using eFlexPWM with MC56F82xx DSC - Freescale ...
AN4485, Using eFlexPWM with MC56F82xx DSC - Freescale ...
AN4485, Using eFlexPWM with MC56F82xx DSC - Freescale ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Freescale</strong> Semiconductor<br />
Application Note<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong><br />
<strong>MC56F82xx</strong> <strong>DSC</strong><br />
by: Richy Ye<br />
Applications Engineering<br />
Shanghai<br />
1 Introduction<br />
The enhanced flexible pulse width modulator<br />
(<strong>eFlexPWM</strong>) module contains PWM submodules, each<br />
of which is set up to control a single half-bridge power<br />
stage. Fault channel support is provided. The <strong>eFlexPWM</strong><br />
module can generate various PWM modes, including<br />
highly sophisticated waveforms, which can be used to<br />
control all known motor types and is ideal for controlling<br />
different switching mode power supply (SMPS)<br />
topologies as well.<br />
The <strong>eFlexPWM</strong> module has these main features:<br />
• 16 bits of resolution for center-, edge-aligned,<br />
and asymmetrical PWMs<br />
• Fractional delay for enhanced resolution of the<br />
PWM period and duty cycle<br />
• PWM outputs that can operate as complementary<br />
pairs or as independent channels<br />
• Ability to accept signed numbers for PWM<br />
generation<br />
© <strong>Freescale</strong> Semiconductor, Inc., 2012. All rights reserved.<br />
Document Number: <strong>AN4485</strong><br />
Rev. 0, 04/2011<br />
Contents<br />
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1<br />
2 Block diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3<br />
3 Module functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5<br />
3.1 PWM capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5<br />
3.2 PWM synchronization . . . . . . . . . . . . . . . . . . . . . . 13<br />
3.3 Fractional delay logic. . . . . . . . . . . . . . . . . . . . . . . 14<br />
3.4 Fault protection . . . . . . . . . . . . . . . . . . . . . . . . . . . 15<br />
3.5 Enhanced capture capability . . . . . . . . . . . . . . . . . 17<br />
3.6 ADC triggering. . . . . . . . . . . . . . . . . . . . . . . . . . . . 18<br />
4 Design considerations . . . . . . . . . . . . . . . . . . . . . . . . . . 20<br />
5 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Introduction<br />
2<br />
• Independent control of both rising and falling edges of each PWM output<br />
• Support for synchronization to external hardware or other PWMs<br />
• Double-buffered PWM registers<br />
— Integral reload rate 1–16<br />
— Half-cycle reload capability<br />
• Multiple output trigger events can be generated per PWM cycle via hardware<br />
• Support for double switching PWM outputs<br />
• Fault inputs can be assigned to control multiple PWM outputs<br />
• Programmable filters for fault inputs<br />
• Independently programmable PWM output polarity<br />
• Independent top and bottom hardware deadtime insertion<br />
• Each complementary pair can operate <strong>with</strong> its own PWM frequency and deadtime values<br />
• Individual software control for each PWM output<br />
• All outputs can be programmed to change status simultaneously via a FORCE_OUT event<br />
• PWMX pin can optionally output a third PWM signal from each submodule (please refer to the pin<br />
assignment table of the respective device to see which pin is used for this purpose)<br />
• Channels not used for PWM generation can be used for buffered output compare functions<br />
• Channels not used for PWM generation can be used for input capture functions <strong>with</strong> enhanced<br />
dual-edge capture capability (please refer to information in respective chapter of reference manual<br />
to see which submodules include this function)<br />
• Option to supply the source for each complementary PWM signal pair from:<br />
— Crossbar module outputs<br />
— External ADC input, taking into account values set in ADC high- and low-limit registers<br />
This document includes a module introduction, block diagram, module functions, and design<br />
considerations.<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
<strong>Freescale</strong> Semiconductor
2 Block diagram<br />
��������<br />
���������<br />
��������<br />
�����<br />
������� �<br />
������<br />
Figure 1. Block diagram of PWM module<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Block diagram<br />
The <strong>MC56F82xx</strong>'s <strong>eFlexPWM</strong> module contains four submodules (each submodule has its own time base)<br />
and has one fault channel, fault channel zero, which accommodates four distinct fault inputs. Each<br />
FAULTx pin can be mapped arbitrarily to control any combination of the PWM outputs.<br />
By default, submodule 0 is regarded as the master for internal synchronization control. Control signals<br />
MASTER RELOAD, MASTER FORCE, MASTER SYNC, and AUX CLOCK are output only by<br />
submodule 0, and received by other submodules (1/2/3) or external components. Alternatively, these four<br />
submodules can be controlled and synchronized together by external signals EXT_SYNC, EXT_FORCE,<br />
and EXT_CLK. In addition, each submodule can generate independent output trigger signals to trigger<br />
events in other components, and an interrupt signal for a CPU interrupt response.<br />
Table 1 identifies PWM feature support that varies by submodule (SM).<br />
������ ������<br />
������ �����<br />
������ ����<br />
��������� �<br />
�����<br />
�����<br />
�����<br />
<strong>Freescale</strong> Semiconductor 3<br />
������ ��������<br />
����������<br />
��� �����<br />
��������� �<br />
��������� �<br />
��������� �<br />
�����<br />
�����<br />
�����<br />
�����<br />
�����<br />
�����<br />
�����<br />
�����<br />
�����
Block diagram<br />
Please note that only the auxiliary PWM signal of submodule3, PWMX3, is enabled to pinout in the<br />
<strong>MC56F82xx</strong>. Also, signals FAULT[n], PWM[n]_EXT_SYNC, EXT_FORCE, PWM[n]_EXTA,<br />
PWM[n]_EXTB, EXT_CLK, and PWM[n]_OUT_TRIGx, where n can be 0, 1, 2 or 3 and x can be 0 or 1,<br />
cannot be found from the pin description table in the data sheet, but may be configured for a wide range<br />
of intermodule connections via the crossbar module.<br />
4<br />
Table 1. PWM submodule feature support<br />
Submodule Fractional delay (high resolution) Enhanced input capture<br />
SM0, SM1, SM2 Yes No<br />
�����<br />
������<br />
����<br />
��������<br />
����<br />
������<br />
������<br />
SM3 No Yes (1-level FIFO depth)<br />
���������<br />
������<br />
�������<br />
�������<br />
�������<br />
���<br />
��������<br />
������<br />
���<br />
������� �<br />
�����<br />
������� �<br />
�����<br />
�������<br />
������� �<br />
�����<br />
������� �<br />
�����<br />
������� �<br />
�����<br />
������� �<br />
�����<br />
��� �����<br />
���������� � �����<br />
������<br />
����������<br />
������<br />
����������<br />
������<br />
����������<br />
���� �����<br />
����������<br />
������<br />
����������<br />
������<br />
����������<br />
���� �����<br />
����������<br />
������<br />
����������<br />
�������� �������<br />
Figure 2. Block diagram of submodule<br />
�����<br />
��<br />
������<br />
��������<br />
���������<br />
���<br />
������<br />
�����<br />
Figure 2 specifies the PWM submodule details. In each case, two comparators and associated VALx<br />
registers are utilized for each PWM output signal. One comparator and VALx register are used to control<br />
the turn-on edge, while a second comparator and VALx register control the turn-off edge. The generation<br />
of the local sync signal is performed exactly the same way as the other PWM signals in the submodule.<br />
While comparator 0 causes a rising edge of the local sync signal, comparator 1 generates a falling edge.<br />
Comparator 1 is also hardwired to the reload logic to generate the full cycle reload indicator.<br />
� �<br />
�<br />
� �<br />
�<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
�<br />
�<br />
������<br />
������� �����<br />
��� ��<br />
�����<br />
��� ���<br />
��� ��<br />
����<br />
�������� ������<br />
�����<br />
��� ���<br />
������ ��������<br />
����������<br />
������<br />
�����<br />
������ ������<br />
���������� � �����<br />
������ ����<br />
���������� � �����<br />
���<br />
���<br />
�����<br />
����������<br />
������<br />
��������<br />
�������<br />
����� ������ ����<br />
������ ���<br />
����<br />
����<br />
����<br />
<strong>Freescale</strong> Semiconductor
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Module functions<br />
If VAL1 is controlling the modulus of the counter and VAL0 is half of the VAL1 register minus the INIT<br />
value, then the half-cycle reload pulse will occur exactly halfway through the timer count period and the<br />
local sync will have a 50% duty cycle. On the other hand, if the VAL1 and VAL0 registers are not required<br />
for register reloading or counter initialization, they can be used to modulate the duty cycle of the local sync<br />
signal, effectively turning it into an auxiliary PWM signal (PWMX), assuming that the PWMX pin is not<br />
being used for another function such as input capture or deadtime distortion correction. Including the local<br />
sync signal, each submodule is capable of generating three PWM signals where software has complete<br />
control over each edge of each of the signals.<br />
If the comparators and edge value registers are not required for PWM generation, they can also be used<br />
for other functions such as output compares, generating output triggers, or generating interrupts at timed<br />
intervals. The 16-bit comparators shown in Figure 2 are “equal to or greater than,” not just “equal to,”<br />
comparators. In addition, if both the set and reset of the flip-flop are asserted, then the flop output goes to 0.<br />
3 Module functions<br />
This section describes the implementation of various functions in the <strong>eFlexPWM</strong> module in detail,<br />
including PWM capability, ADC trigger, enhanced capture, PWM synchronization, and fault protection.<br />
3.1 PWM capability<br />
<strong>MC56F82xx</strong>'s <strong>eFlexPWM</strong> module contains four submodules, each of which has its own time base and<br />
PWM capability. They can work independently of each other or in synchronization. In this section only<br />
one submodule is used as an example.<br />
3.1.1 Edge-aligned PWM<br />
An edge-aligned PWM provides a single PWM signal where one out of two edges of the PWM is aligned<br />
to the period boundary, and the other edge is determined by the duty cycle. As Figure 3 shows, this allows<br />
maximum duty cycle resolution using an edge-aligned PWM, because the PWM duty cycle can be changed<br />
per PWM clock.<br />
���� ��������<br />
����<br />
���� ��������<br />
����<br />
���� � ���� � ���� ��������<br />
����<br />
����<br />
Figure 3. Edge-aligned PWM example (INIT = VAL2 = VAL4)<br />
<strong>Freescale</strong> Semiconductor 5
Module functions<br />
For an edge-aligned PWM on <strong>MC56F82xx</strong>, the turn-on edge value (VAL2, VAL4) for each pulse is<br />
specified to be the INIT value. Therefore only the turn-off edge value (VAL3, VAL5) needs to be updated<br />
to change the duty cycle. The code for an edge-aligned PWM can be found in the software available <strong>with</strong><br />
this application note.<br />
The edge-aligned PWM is usually used for single power switch converters, such as BUCK, BOOST, and<br />
Flyback converters, etc.<br />
3.1.2 Center-aligned PWM<br />
Center-aligned PWM provides a single PWM signal where half of the PWM period appears before a center<br />
point, and the other half after the center point. As Figure 4 shows, it will reduce 1-bit duty cycle resolution,<br />
because the PWM duty cycle can only be changed twice per PWM clock.<br />
6<br />
���� ��������<br />
����<br />
����<br />
���� ��������<br />
����<br />
����<br />
���� ��������<br />
����<br />
����<br />
Figure 4. Center-aligned PWM example<br />
For a center-aligned PWM on <strong>MC56F82xx</strong>, the center point is specified to be half the value of the sum of<br />
the INIT value and VAL1. Therefore the turn-on edge value (VAL2, VAL4) for each pulse needs to be<br />
updated so that the difference between center point and turn-on edge is half of the duty cycle. Then the<br />
turn-off edge value (VAL3, VAL5) also needs to be updated so that the difference between turn-off edge<br />
and center point is half of the duty cycle.<br />
If all PWM signal edge calculations follow this same convention, then the signals will be center-aligned<br />
<strong>with</strong> respect to each other. Of course, center alignment between the signals is not restricted to symmetry<br />
around the zero count value, as any other number would also work. However, centering on zero provides<br />
the greatest range in signed mode and also simplifies the calculations. The code for center-aligned PWM<br />
can be found in the software available <strong>with</strong> this application note.<br />
The center-aligned PWM is usually used for multiple power switches or multi-phase converters, such as<br />
half-bridge and full-bridge inverter, etc. <strong>Using</strong> it will greatly improve system EMI and THD.<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
<strong>Freescale</strong> Semiconductor
3.1.3 Complementary PWM<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Module functions<br />
Complementary PWM provides a PWM output signal on one pin <strong>with</strong> the complement of the PWM signal<br />
on the other output pin (thus providing a pair of complementary channels). As Figure 5 shows,<br />
complementary operation allows use of the deadtime insertion feature to avoid shooting through.<br />
���� ��������<br />
����<br />
���� ��������<br />
����<br />
���� ��������<br />
����<br />
�� ��������<br />
����<br />
����<br />
���� ��������<br />
����<br />
Figure 5. Complementary PWM example (<strong>with</strong> deadtime insertion)<br />
For complementary PWM on <strong>MC56F82xx</strong>, writing a logic zero to CTRL2[INDEP] configures the PWM<br />
output as a pair of complementary channels. The PWM pins are paired between PWMxA and PWMxB in<br />
complementary channel operation. MCTRL[IPOL] determines which signal is connected to the output pin<br />
(PWM23 or PWM45). The code for complementary PWM can be found in the software available <strong>with</strong> this<br />
application note.<br />
Complementary PWM is usually used for converters <strong>with</strong> a bridge leg, such as synchronously switched<br />
BUCK, half-bridge, and full-bridge converters, etc.<br />
3.1.4 Push-pull PWM<br />
������<br />
������<br />
Push-pull PWM means that a standard PWM output signal goes out on one pin, then the PWM signal (same<br />
duty cycle) goes to the other output pin on the next cycle, then the process repeats. The cycle is shown in<br />
Figure 6.<br />
<strong>Freescale</strong> Semiconductor 7
Module functions<br />
8<br />
���� ��������<br />
����<br />
����<br />
���� ��������<br />
����<br />
����<br />
���� ��������<br />
����<br />
����<br />
Figure 6. Push-pull PWM example<br />
When using push-pull PWM on <strong>MC56F82xx</strong>, writing a logic one to CTRL2[INDEP] configures the PWM<br />
output as independent channels. The active PWM signal of PWMxA should lie in the former half of the<br />
PWM cycle, so that inequality is assured: initial value (INIT) � turn-on edge value (VAL2) � turn-off edge<br />
value (VAL3) � half period point value ((VAL1+INIT)/2). Similarly, in order to output the active PWM<br />
signal of PWMxB in the second half of the PWM cycle, then the values must be:<br />
half-period point value ((VAL1+INIT)/2) � turn-on edge value (VAL4) � turn-off edge value<br />
(VAL5) � period value (VAL1)<br />
Also, the offset must be kept as half of the PWM period for two turn-on edges (VAL2 and VAL4) and two<br />
turn-off edges (VAL3 and VAL5) separately. The code for push-pull PWM can be found in the software<br />
available <strong>with</strong> this application note.<br />
The push-pull PWM is usually used for DC to AC inverters <strong>with</strong> isolated transformer, such as push-pull,<br />
half-bridge, and full-bridge converters, etc.<br />
3.1.5 Multi-phase PWM<br />
��� ������ ��� ������<br />
Multi-phase PWM allows multiple PWM generators to output PWM signals that are synchronized but<br />
constantly shift phase relative to each other, as shown in Figure 7.<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
<strong>Freescale</strong> Semiconductor
���� ��������<br />
���� ������<br />
���� ������<br />
���� ������<br />
���� ��������<br />
���� ������<br />
���� ������<br />
���� ������<br />
���� ��������<br />
�����<br />
�����<br />
�����<br />
�����<br />
�����<br />
�����<br />
��� ������ ��� ������<br />
��� ������<br />
Figure 7. Multi-phase PWM example<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
��� ������<br />
Module functions<br />
When using multi-phase PWM on <strong>MC56F82xx</strong>, in order to keep time base synchronization among the<br />
different phases of the PWM signals, the same initialization control signal must be selected by all PWM<br />
submodules. This means that if the master submodule (submodule 0) selects the local sync signal as its<br />
initialization control signal, the slave submodules (submodules 1/2/3) should select the master signal<br />
(master reload or sync signal) to initialize their counters, or else all submodules will all select the same<br />
external sync signal as their initialization control signal. Also, it is important that the phase offsets be set<br />
up to evenly distribute the phase shift among the different phases of the PWM signals.<br />
As shown in Figure 7, there are three pairs of PWM signals, so the phase offset among the three pairs of<br />
PWM signals should be set to one third of the PWM period,. This means that there is one-third of PWM<br />
period phase difference among center point of each pair PWM signals ((PWM2_VAL3+PWM2_VAL2)/2<br />
– (PWM1_VAL3+PWM1_VAL2)/2 = (PWM1_VAL3+PWM1_VAL2)/2 –<br />
(PWM0_VAL3+PWM0_VAL2)/2 = (VAL1-INIT)/3) if center-aligned PWM mode is used. If<br />
edge-aligned PWM mode is used, there is one-third of PWM period phase difference among edge (turn-on<br />
edge or turn-off edge) of each pair of PWM signals (PWM2_VAL3(VAL2) – PWM1_VAL3(VAL2) =<br />
PWM1_VAL3(VAL2) – PWM0_VAL3(VAL2) = (VAL1-INIT)/3). The code for multi-phase PWM can be<br />
found in the software available <strong>with</strong> this application note.<br />
<strong>Freescale</strong> Semiconductor 9
Module functions<br />
Multi-phase PWM is usually used for multi-phase converters <strong>with</strong> two, three, four, or more phases, such<br />
as interleaved BUCK, interleaved BOOST and interleaved flyback converters, etc.<br />
3.1.6 Phase-shifted PWM<br />
Phase-shifted PWM is similar to multi-phase PWM, but the phase relationships are constantly changing.<br />
In general, phase-shifted PWM is always set to 50% duty cycle, as shown in Figure 8.<br />
10<br />
���� ��������<br />
���� ������<br />
���� ������<br />
���� ��������<br />
���� ������<br />
���� ������<br />
���� ��������<br />
�����<br />
�����<br />
�����<br />
�����<br />
Figure 8. Phase-shifted PWM example<br />
For phase-shifted PWM on <strong>MC56F82xx</strong>, in order to keep time base synchronization among different<br />
phases PWM signals, the same initialization control signal must be selected by all PWM submodules. This<br />
means that if the master submodule (submodule 0) selects the local sync signal as its initialization control<br />
signal, the slave submodules (submodule 1/2/3) should select the master signal (master reload or sync<br />
signal) to initialize their counters, or else all submodules will all select the same external sync signal as<br />
their initialization control signal. Also, it is important that the duty cycle of each PWM signal pair be kept<br />
unchanged.<br />
As shown in Figure 8, there are two pairs of PWM signals. The first pair of PWM signals (PWM0A,<br />
PWM0B) are kept fixed, and the phase relationship between the two pairs of PWM signals is changed only<br />
by changing the phase of the secondary pair PWM signals (PWM1A, PWM1B). This means that there is<br />
an identical phase offset (phase-shifted quantum) between turn-on edges and turn-off edges of each pair<br />
of PWM signals (PWM1_VAL2-PWM0_VAL2 = PWM1_VAL3-PWM0_VAL3 = required phase-shifted<br />
quantum). The code for phase-shifted PWM can be found in the software available <strong>with</strong> this application<br />
note.<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
<strong>Freescale</strong> Semiconductor
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Module functions<br />
The phase-shifted PWM is usually used for ZVT converters, such as a full-bridge ZVT converter.<br />
3.1.7 Current-limit PWM<br />
Current-limit PWM mode is a variation of standard fixed-frequency PWM where the turn-on time is<br />
truncated when the current reaches a desired maximum value, as shown in Figure 9.<br />
���� ��������<br />
����<br />
���� ��������<br />
���� � ���� ��������<br />
���� ������������<br />
�������� �������<br />
���� ��������<br />
���������<br />
�����<br />
Figure 9. Current-limit PWM example<br />
For current-limit PWM on <strong>MC56F82xx</strong>, the turn-on edge value (VAL2) is specified to be the INIT value.<br />
Then the turn-off edge value (VAL3) is set to a fixed value large enough to meet actual maximum turn-on<br />
time requirement. In order to truncate the turn-on time when the current reaches a desired maximum value,<br />
an internal comparator can be used to disable the PWM output, where the comparator output will be used<br />
as the fault input of the PWM module. Automatic clearing mode <strong>with</strong> only full cycle clearing timing<br />
should be selected for fault clearing mode in the PWM module. The code for current-limit PWM can be<br />
found in the software available <strong>with</strong> this application note.<br />
The current-limit PWM is usually used for a peak-current-controlled converter, such as peak current<br />
controlled phase-shifted full-bridge converter, which uses the combination of phase-shifted PWM mode<br />
and current-limit PWM mode to drive power MOSFETs. This automatically prevents the output<br />
transformer from saturation, which eliminates the need for a capacitor to block DC current. And it should<br />
be noted that a subharmonic oscillation issue exists in the control loop when the output inductor current<br />
increases to a value so high that it can’t return to its initial value in one PWM cycle. At this moment, an<br />
algorithm, called slope compensation, is usually used to correct this issue.<br />
<strong>Freescale</strong> Semiconductor 11
Module functions<br />
Therefore, a 12-bit DAC on <strong>MC56F82xx</strong> can be used to implement the slope compensation algorithm<br />
using its automatic waveform generation function (down-counting sawtooth waveform). The maximum<br />
value of the sawtooth waveform is from the output of the output voltage loop of the phase-shifted<br />
full-bridge converter — the minimal value and step will be determined by the desired slope rate, PWM<br />
cycle, and DAC updating rate. Then the DAC output is used as the desired maximum value of the output<br />
inductor current (if the step is large, an external capacitor can be added on the DAC output pin to smooth<br />
DAC output), and connected to the input of an internal comparator, which is used to disable the<br />
corresponding PWM output when the actual output inductor current reaches the desired maximum value.<br />
3.1.8 Current-reset PWM<br />
Current-reset PWM mode is a variable frequency mode where the turn-on time is specified, and the turn-off<br />
time is truncated when current falls below a desired minimum value, as shown in Figure 10.<br />
12<br />
���� ��������<br />
����<br />
���� ��������<br />
���� � ���� ��������<br />
���� ������������<br />
�������� �������<br />
���� ��������<br />
�����<br />
���������<br />
Figure 10. Current-reset PWM example<br />
For current-reset PWM on <strong>MC56F82xx</strong>, the turn-on edge value (VAL2) is specified to be the INIT value.<br />
The turn-off edge value (VAL3) is also specified to assure that the programmed turn-on time is a fixed<br />
value. In order to truncate the turn-off time when current falls below a desired minimal value, an internal<br />
comparator can be used to initialize the PWM counter. The comparator output will be used as the external<br />
sync signal input of the PWM module, and EXT_SYNC should be selected as the initialization control<br />
source in the PWM module. The code for current-reset PWM can be found in the software available <strong>with</strong><br />
this application note.<br />
The current-reset PWM is usually used for transition mode (critical current mode) PFC converters, and<br />
will greatly improve converter efficiency in low-power applications. The combination of current-limit<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
<strong>Freescale</strong> Semiconductor
PWM mode and current-reset PWM mode is used in a transition mode PFC converter for better<br />
performance.<br />
3.2 PWM synchronization<br />
���������� �����<br />
���������<br />
�����<br />
������ ������<br />
������ ����<br />
��������<br />
��������<br />
����<br />
������ �������<br />
�<br />
�<br />
�<br />
�<br />
����<br />
����� ����<br />
������<br />
����������<br />
Figure 11. Submodule timer synchronization<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Module functions<br />
��� �������<br />
The 16-bit counter shown in Figure 11 can be initialized <strong>with</strong> an INIT value by four possible sources: local<br />
sync, master reload, master sync, and EXT_SYNC.<br />
If local sync is selected as the counter initialization signal, the counter will count up until its output equals<br />
VAL1. VAL1 is used to specify the counter modulus value, then VAL1 <strong>with</strong>in the submodule effectively<br />
controls the timer period (and thus the PWM frequency generated by that submodule) and everything<br />
works on a local level. If the master sync signal (which originates as the local sync from submodule0) is<br />
configured to initialize the counter, then the counter period of any submodule can be locked to the period<br />
of the counter in submodule0. Then the VAL1 register and associated comparator of the other submodules<br />
can be freed up for other functions such as PWM generation, input captures, output compares, or output<br />
triggers.<br />
If the master reload signal (which only originates from submodule0) is selected as the source for counter<br />
initialization, then the period of the counter of any submodule will be locked to the reload frequency of<br />
submodule0. Since the reload frequency is optional and can vary from one to sixteen, it will support<br />
generating multi-frequency PWM signals in synchronization.<br />
If the EXT_SYNC signal (which originates on-chip or off-chip depending on the system architecture) is<br />
selected as the source for counter initialization, the counter period in all submodules can be controlled by<br />
an external source. This makes it easy to implement synchronization between the <strong>eFlexPWM</strong> module and<br />
the external signal.<br />
In addition, the counter can optionally be initialized upon the assertion of the FORCE_OUT signal (which<br />
is provided mainly for synchronous switching of multiple PWM outputs), assuming that CTRL2[FRCEN]<br />
is set. As indicated by the preceding figure, this constitutes a second initialization input into the counter.<br />
<strong>Freescale</strong> Semiconductor 13<br />
����<br />
����������<br />
�����<br />
������ ����<br />
����� ������� �����
Module functions<br />
This will cause the counter to initialize regardless of which signal is selected as the counter initialization<br />
signal.<br />
In summary, if multiple PWMs <strong>with</strong> the same frequency are required to synchronize, the master sync<br />
signal (submodule0 selects local sync for counter initialization) is recommended to initialize the counters<br />
in slave submodules (submodule1/2/3) if all PWM signals are from internal submodules. Otherwise, the<br />
EXT_SYNC signal is recommended to initialize the counters in all submodules when some PWM signals<br />
are from another PWM module or are off-chip. If it is necessary to synchronize multiple PWMs <strong>with</strong><br />
different frequencies, two methods are recommended.<br />
• Method one:<br />
1. Configure the highest frequency PWM signal from submodule0 (which uses local sync to initialize<br />
the counter for internal PWM synchronization, or EXT_SYNC for external PWM<br />
synchronization).<br />
2. Select master reload (reload rate depends on the frequency ratio of different PWMs) signal for<br />
counter initialization in slave submodules (submodule1/2/3).<br />
• Method two:<br />
1. Select local sync to initialize counters for those submodules which generate the higher frequency<br />
PWM signals.<br />
2. Configure their FORCE source as master sync signal (submodule0 is configured to generate lowest<br />
frequency PWMs) or EXT_FORCE signal (other slave submodule is configured to generate lowest<br />
frequency PWMs — this submodule is required to output a local sync trigger as an EXT_FORCE<br />
signal input for other submodules).<br />
3. Configure the submodule (which generates lowest frequency PWMs) to select local sync to<br />
initialize the counter for internal PWM synchronization, or EXT_SYNC for external PWM<br />
synchronization.<br />
3.3 Fractional delay logic<br />
For applications requiring greater resolution than a single IPBus clock period (up to 16.67 ns), the<br />
fractional delay logic can achieve fine resolution on the rising and falling edges of the PWM outputs. Use<br />
the PWM_SMn_FRCTRL register (where n is 0, 1, or 2) to enable the fractional delay logic only where<br />
needed. The FRACVALx registers (highest five bits are used) act as a fractional clock cycle (IPBus clock<br />
period/2 5 , up to 520.8 ps) addition to the turn-on and turn-off count specified by the VAL2, VAL3, VAL4,<br />
or VAL5 registers. The FRACVAL1 register acts as a fractional increase in the PWM period as defined by<br />
VAL1.<br />
For example, assume the following conditions:<br />
INIT = 0x00<br />
VAL1 = 0x0F<br />
VAL2 = 0x00<br />
VAL3 = 0x07<br />
FRACVAL3 = 0x00<br />
14<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
<strong>Freescale</strong> Semiconductor
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Module functions<br />
these settings would cause the PWM output to have a 50% duty cycle: it would be high from a count value<br />
of 0x00 (VAL2) to 0x07 (VAL3), at which point it would go low until the counter reaches the maximum<br />
value of 0x0F (VAL1). If FRACVAL3 were set to a value of 0xB800 (real value is 0x17), then the time the<br />
PWM output is active would be:<br />
8 cycles + (23/32) cycles = 8.719 cycles<br />
for a high duty cycle of:<br />
(8.719 cycles/16 cycles) � 100% = 54.49%<br />
Another case involves fine tuning the PWM period using the FRACVAL1 register. If a PWM period of<br />
100.25 clock cycles is required, program VAL1 <strong>with</strong> 0x64 and FRACVAL1 <strong>with</strong> 0x4000. In this case, the<br />
fractional value accumulates so that every four PWM cycles are one clock cycle longer (101 instead of<br />
100). The rising and falling edges of the PWM outputs also use the accumulated fraction to delay their<br />
edges and maintain a consistent spacing of 100.25 cycles between corresponding edges, from one cycle to<br />
the next.<br />
In order to enable a high-resolution PWM function (fractional delay logic), two independent registers<br />
(VALx and FRACVALx, where x is 1, 2, 3, 4, or 5) must be programmed to get the desired duty cycle and<br />
period. An example can be found, in the software available <strong>with</strong> this application note, of variable duty<br />
cycle and period PWM <strong>with</strong> high-resolution function, developed to show how to simply set the two<br />
registers.<br />
3.4 Fault protection<br />
Fault protection can control any combination of PWM output pins. Faults are generated by a logic one on<br />
any of the FAULTx pins. This polarity can be changed via FCTRL[FLVL]. Each FAULTx pin can be<br />
mapped arbitrarily to any of the PWM outputs. When fault protection hardware disables PWM outputs,<br />
the PWM generator continues to run, but the output pins are forced to logic 0, logic 1, or tri-state depending<br />
on the value of SMnOCTRL[PWMxFS].<br />
3.4.1 Automatic fault clearing<br />
When FCTRL[FAUTOx] is set, disabled PWM pins are enabled when the FAULTx pin returns to logic<br />
zero and a new PWM full or half-cycle begins. See Figure 12 — if FSTS[FFULLx] is set, then the disabled<br />
PWM pins are enabled only at the start of a full cycle and not at the half-cycle. Clearing FSTS[FFLAGx]<br />
does not affect disabled PWM pins when FCTRL[FAUTOx] is set. This mode is very useful for<br />
cycle-by-cycle protection, and has quicker response in half-cycle resolution, which will help improve<br />
system dynamic response.<br />
<strong>Freescale</strong> Semiconductor 15
Module functions<br />
16<br />
�����<br />
������ ���<br />
�������<br />
3.4.2 Manual fault clearing<br />
Figure 12. Automatic fault clearing example<br />
Clearing the automatic clearing mode bit, FCTRL[FAUTOx], configures faults from the FAULTx pin for<br />
manual clearing:<br />
• If the fault safety mode bits, FCTRL[FSAFEx], are clear, then PWM pins disabled by the FAULTx<br />
pins are enabled when:<br />
— Software clears the corresponding FSTS[FFLAGx] flag.<br />
— The next PWM full or half cycle begins, regardless of the logic level detected by the filter at<br />
the FAULTx pin. See Figure 13. If FSTS[FFULLx] is set, then the disabled PWM pins are<br />
enabled only at the start of a full cycle and not at the half-cycle.<br />
�����<br />
������ ���<br />
�������<br />
������ �������<br />
Figure 13. Manual fault clearing example (FCTRL[FSAFEx] = 0)<br />
• If the fault safety mode bits, FCTRL[FSAFEx], are set, then PWM pins disabled by the FAULTx<br />
pins are enabled when:<br />
— •Software clears the corresponding FSTS[FFLAGx] flag.<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
���� �����<br />
������� �������� ������� �������� �������<br />
������� �������� �������<br />
<strong>Freescale</strong> Semiconductor
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Module functions<br />
— The filter detects a logic zero on the FAULTx pin at the start of the next PWM full or half-cycle<br />
boundary (see Figure 14). If FSTS[FFULLx] is set, then the disabled PWM pins are enabled<br />
only at the start of a full cycle and not at the half-cycle.<br />
�����<br />
������ ���<br />
�������<br />
������� �������� �������<br />
������ �������<br />
Figure 14. Manual fault clearing example (FCTRL[FSAFEx] = 1)<br />
This mode is very useful for latch-up protection, and has flexible enable mode and quick response in<br />
half-cycle resolution, which will help to improve system design flexibility and dynamic response.<br />
3.5 Enhanced capture capability<br />
When <strong>eFlexPWM</strong> submodule3 pins (PWM3A, PWM3B, PWM3X) aren’t being used for PWM<br />
generation, they can be used to perform the input capture function. Commensurate <strong>with</strong> the idea of<br />
controlling both edges of an output signal, the enhanced capture (E-capture) logic is designed to measure<br />
both edges of an input signal. As a result, when a submodule pin is configured for input capture, the<br />
CVALx/x+1 registers associated <strong>with</strong> that pin are used to record the edge values.<br />
Figure 15 is a block diagram of the E-capture circuit. Upon entering the pin input, the signal is split into<br />
two paths: one goes straight to a mux input where software can pass the signal directly to the capture logic<br />
for processing. The other path connects the signal to an 8-bit counter which counts both the rising and<br />
falling edges of the input signal. The output of this counter is compared to an 8-bit value that is specified<br />
by the user (EDGCMPx) and when the two values are equal, the comparator generates a pulse that resets<br />
the counter. This pulse is also supplied to the mux input where software can select it to be processed by<br />
the capture logic. This feature allows the module to count a specified number of edge events and then<br />
perform a capture and interrupt.<br />
<strong>Freescale</strong> Semiconductor 17
Module functions<br />
18<br />
��� �����<br />
���������<br />
������<br />
�����<br />
�������<br />
�����<br />
������<br />
���� ����� �� �������� ���<br />
����� ����� ��� ����<br />
�������<br />
Figure 15. Block diagram of enhanced capture unit<br />
Based on the mode selection, the mux selects either the pin input or the comparator output from the<br />
counter/compare circuit to be processed by the capture logic. The selected signal is routed to two separate<br />
capture circuits which work in tandem to capture sequential edges of the signal. The type of edge to be<br />
captured by each circuit is determined by CAPTCTRLx[EDGx1] and CAPTCTRLx[EDGx0].<br />
Also, controlling the operation of the capture circuits is the arming logic, which allows captures to be<br />
performed in a free-running (continuous) or one-shot fashion. In free-running mode, the capture sequences<br />
will be performed indefinitely. If both capture circuits are enabled, they will work together in a ping-pong<br />
style where a capture event from one circuit leads to the arming of the other and vice-versa. In one-shot<br />
mode, only one capture sequence will be performed. Similarly, if only capture circuits are enabled, the<br />
capture event will occur on the enabled capture circuit. Both capture circuits are capable of generating an<br />
interrupt to the CPU. The duty cycle meter code for E-capture function on PWM3X can be found in the<br />
software available <strong>with</strong> this application note.<br />
3.6 ADC triggering<br />
�� �<br />
�� �<br />
�� �<br />
�� �<br />
�������<br />
����������<br />
In cases where timing of ADC triggering is critical, scheduling must be done as a hardware event instead<br />
of by software. With the <strong>eFlexPWM</strong> module, multiple ADC triggers can be generated by the compare<br />
output capability in hardware per PWM period <strong>with</strong>out the need of another timer module. Figure 16 shows<br />
how this is accomplished in a submodule. For example, when specifying complementary PWM mode<br />
operation, only two edge comparators are required to generate the output PWM signals for a given<br />
submodule. This means that the other comparators are free to perform other functions, such as a compare<br />
output for an ADC trigger event. In this example, the software does not need to quickly respond after the<br />
first triggering to set up other triggerings that must occur in the same PWM period.<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
�<br />
�<br />
���������<br />
�����<br />
���� ����<br />
��������<br />
������� ������� �����<br />
������� ������ �����<br />
������� ��� ����<br />
���<br />
���<br />
������� �<br />
�������<br />
�����<br />
������<br />
�����<br />
�����<br />
������� �<br />
�������<br />
���<br />
���<br />
����<br />
����<br />
����<br />
����<br />
���<br />
���<br />
<strong>Freescale</strong> Semiconductor
���� �������<br />
����<br />
����<br />
����<br />
����<br />
���� �������<br />
���<br />
������ ��������<br />
Figure 16. Multiple output trigger generation in PWM period<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Module functions<br />
Because each submodule has its own timer, it is possible for each submodule to run at a different frequency.<br />
One of the possible options <strong>with</strong> the <strong>eFlexPWM</strong> module is to have one or more submodules running at a<br />
lower frequency only to trigger outputs, but still synchronized to those timers in other submodules, which<br />
are used to generate PWM signals. Figure 17 shows how this feature can be used to schedule ADC triggers<br />
over multiple PWM periods. A suggested use for this configuration would be to use the lower-frequency<br />
submodule to control the sampling points where multiple ADC triggers can now be scheduled over the<br />
entire sampling period. In this figure, all submodule comparators are shown being used for ADC trigger<br />
generation.<br />
<strong>Freescale</strong> Semiconductor 19
Design considerations<br />
20<br />
����<br />
����<br />
����<br />
����<br />
����<br />
����<br />
������ ��������<br />
Figure 17. Multiple output trigger generation over several PWM periods<br />
4 Design considerations<br />
���������� ������� ���� �����������<br />
���������� �������<br />
Use the following list of considerations to ensure correct operation of the <strong>eFlexPWM</strong> module on<br />
<strong>MC56F82xx</strong>:<br />
• The PWM output pins are set to input ports <strong>with</strong> an internal weak pullup resistor (about 2.0 V) after<br />
reset, or by default it is required to connect a strong external pulldown or pullup resistor (1–10 k�)<br />
close to the pin to ensure safety status under uncertain conditions.<br />
• There are two methods to manually disable PWM outputs regardless of duty cycle and clock<br />
settings:<br />
— Disable PWM output by clearing corresponding bit of PWM_OUTEN, which will result in<br />
tri-state output on the PWM pin.<br />
— Disable PWM output by setting corresponding bit of PWM_MASK followed by a<br />
FORCE_OUT event, which will result in logic zero output prior to output polarity on the PWM<br />
pin.<br />
• It is recommended to meet these boundary conditions for correct PWM generation:<br />
INIT � VAL2 (VAL4), VAL3 (VAL5) � VAL1<br />
• When variable frequency PWMs are required, it is recommended to keep INIT constant and change<br />
frequency only through changing VAL1.<br />
• When enabling high-resolution PWM (fractional delay logic) function:<br />
— If automatically generating initialization code from Processor Expert in CodeWarrior v8.3,<br />
there will be a wrong value assignment for the PWM_SMnFRCTRL register. The correct value<br />
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
������<br />
<strong>Freescale</strong> Semiconductor
<strong>Using</strong> <strong>eFlexPWM</strong> <strong>with</strong> <strong>MC56F82xx</strong> <strong>DSC</strong>, Rev. 0<br />
Conclusion<br />
needs to be set according to the bit definition of the PWM_SMnFRCTRL register in the<br />
reference manual. Otherwise incorrect PWM behavior may result.<br />
— In order to assure correct high-resolution PWM generation, at least three integer PWM clock<br />
(up to 60 MHz) cycle duration (except for deadtime) is required between the edge value<br />
(VAL2, VAL3, VAL4, and VAL5) and the period boundary value (INIT and VAL1).<br />
— If complementary high-resolution PWM mode (high resolution enabled for both duty cycle and<br />
period) is specified, besides enabling fractional delay logic for the complementary PWM<br />
channel, these conditions must also be met for correct PWM generation:<br />
PWM_SMnFRACVAL2 = PWM_SMnFRACVAL5<br />
PWM_SMnFRACVAL3 = PWM_SMnFRACVAL4<br />
— If complementary high-resolution PWM mode is specified, and the inverted generated PWM<br />
is selected as the source for deadtime generation, swap the programming for the turn-on edge<br />
VAL2/FRACVAL2 (VAL4/FRACVAL4) and turn-off edge VAL3/FRACVAL3<br />
(VAL5/FRACVAL5) registers to ensure correct PWM output.<br />
5 Conclusion<br />
This note summarizes the structure and functions of the <strong>eFlexPWM</strong> module on <strong>MC56F82xx</strong> <strong>DSC</strong>, and<br />
provides example code to help better understand implementation of the functions, making it easy for users<br />
to properly use this module in their projects. Finally, some design considerations are shared <strong>with</strong> users to<br />
help them better use the module.<br />
The example project was developed on the MC56F8257 <strong>with</strong> CodeWarrior v8.3 IDE. The macro of<br />
MODE_SEL is designed to select different function routines in the project.<br />
<strong>Freescale</strong> Semiconductor 21
How to Reach Us:<br />
Home Page:<br />
freescale.com<br />
Web Support:<br />
freescale.com/support<br />
Document Number: <strong>AN4485</strong><br />
Rev. 0<br />
04/2011<br />
Information in this document is provided solely to enable system and software<br />
implementers to use <strong>Freescale</strong> products. There are no express or implied copyright<br />
licenses granted hereunder to design or fabricate any integrated circuits based on the<br />
information in this document.<br />
<strong>Freescale</strong> reserves the right to make changes <strong>with</strong>out further notice to any products<br />
herein. <strong>Freescale</strong> makes no warranty, representation, or guarantee regarding the<br />
suitability of its products for any particular purpose, nor does <strong>Freescale</strong> assume any<br />
liability arising out of the application or use of any product or circuit, and specifically<br />
disclaims any and all liability, including <strong>with</strong>out limitation consequential or incidental<br />
damages. “Typical” parameters that may be provided in <strong>Freescale</strong> data sheets and/or<br />
specifications can and do vary in different applications, and actual performance may<br />
vary over time. All operating parameters, including “typicals,” must be validated for each<br />
customer application by customer’s technical experts. <strong>Freescale</strong> does not convey any<br />
license under its patent rights nor the rights of others. <strong>Freescale</strong> sells products<br />
pursuant to standard terms and conditions of sale, which can be found at the following<br />
address: http://www.reg.net/v2/webservices/<strong>Freescale</strong>/Docs/TermsandConditions.htm<br />
<strong>Freescale</strong>, the <strong>Freescale</strong> logo, AltiVec, C-5, CodeTest, CodeWarrior, ColdFire, C-Ware,<br />
Energy Efficient Solutions logo, Kinetis, mobileGT, PowerQUICC, Processor Expert,<br />
QorIQ, Qorivva, StarCore, Symphony, and VortiQa are trademarks of <strong>Freescale</strong><br />
Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. Airfast, BeeKit, BeeStack, ColdFire+,<br />
CoreNet, Flexis, MagniV, MXC, Platform in a Package, QorIQ Qonverge, QUICC<br />
Engine, Ready Play, SafeAssure, SMARTMOS, TurboLink, Vybrid, and Xtrinsic are<br />
trademarks of <strong>Freescale</strong> Semiconductor, Inc. All other product or service names are<br />
the property of their respective owners.<br />
© 2012 <strong>Freescale</strong> Semiconductor, Inc.