www.ti.com
Operational Description of HRPWM
339
SPRUI07–March 2020
Submit Documentation Feedback
Copyright © 2020, Texas Instruments Incorporated
High-Resolution Pulse Width Modulator (HRPWM)
Step 4. Application Code
While the application is running, fluctuations in both device temperature and supply voltage may be
expected. To be sure that optimal Scale Factors are used for each ePWM module, the SFO function
should be re-run periodically as part of a slower back-ground loop. Some examples of this are shown
here.
NOTE: See the HRPWM_SFO example in C2000Ware available from the TI website.
Example 4
‑‑
4. SFO Function Calls
main()
{
// User code
// Case1: ePWM1,2,3,4 are running in HRPWM mode
SFO_MepEn(1); // Each of these of function enables
SFO_MepEn(2); // the respective MEP diagnostic logic
SFO_MepEn(3); // and returns MEP Scale factor value
SFO_MepEn(4);
MEP_ScaleFactor1 = MEP_ScaleFactor[1]; // used for ePWM1
MEP_ScaleFactor2 = MEP_ScaleFactor[2]; // used for ePWM2
MEP_ScaleFactor3 = MEP_ScaleFactor[3]; // used for ePWM3
MEP_ScaleFactor4 = MEP_ScaleFactor[4]; // used for ePWM4
// Case2:ePWM1,2,3 only are running in HRPWM mode.
One of the ePWM channel(as an example ePWM4) is used as for
Scale factor calibration
// Here minimum duty cycle limitation is 3 clock cycles.
//
// HRPWM 4 MEP diagnostics circuit is used to estimate the MEP steps
// with the assumption that all HRPWM channels behave similarly
// though may not be identical.
SFO_MepDis(4); // MEP steps using ePWM4
MEP_ScaleFactor1 = MEP_ScaleFactor[4]; // used for ePWM1
MEP_ScaleFactor2 = MEP_ScaleFactor1 // used for ePWM2
MEP_ScaleFactor3 = MEP_ScaleFactor1 // used for ePWM3
MEP_ScaleFactor4 = MEP_ScaleFactor1 // used for ePWM4
4.2.5 HRPWM Examples Using Optimized Assembly Code
The best way to understand how to use the HRPWM capabilities is through two real examples:
1. Simple buck converter using asymmetrical PWM (that is, count-up) with active high polarity.
2. DAC function using simple R+C reconstruction filter.
The following examples all have Initialization/configuration code written in C. To make these easier to
understand, the #defines shown below are used. Note, #defines can be found in C2000Ware.
Example 4-5 assumes MEP step size of 150 ps and does not use the SFO library.