Operational Description of HRPWM
www.ti.com
338
SPRUI07–March 2020
Submit Documentation Feedback
Copyright © 2020, Texas Instruments Incorporated
High-Resolution Pulse Width Modulator (HRPWM)
To use the HRPWM feature of the ePWMs, it is recommended that the SFO functions be used as
described here.
Step 1. Add Include Files
The SFO.h file needs to be included as follows. This include file is mandatory while using the SFO library
function.
Example 4-1. A Sample of How to Add Include Files
#include "device280x_Device.h" // device280x Headerfile
#include "device280x_EPWM_defines.h" // init defines
#include "SFO.h" // SFO lib functions (needed for HRPWM)
Step 2. Element Declaration
Declare a 5-element array of integer variables as follows:
Example 4-2. Declaring an Element
int MEP_ScaleFactor[5] = {0,0,0,0,0}; // Scale factor values for ePWM1-4
int MEP_ScaleFactor1, MEP_ScaleFactor2, MEP_ScaleFactor3, MEP_ScaleFactor4 // Not required by library
volatile struct EPWM_REGS *ePWM[] = {0, &EPwm1Regs, &EPwm2Regs, &EPwm3Regs, &EPwm4Regs};
Step 3. MEP_ScaleFactor Initialization
After power up, the SFO_MepEn(n) function needs a starting Scale Factor value. This value can be
conveniently determined by using one of the ePWM modules to run the SFO_MepDis(n) function prior to
configuring its PWM outputs for the application. SFO_MepDis(n) function does not require a starting Scale
Factor value.
As part of the one-time initialization code, include the following:
Example 4-3. Initializing With a Scale Factor Value
// MEP_ScaleFactor variables initialized using function SFO_MepDis
while (MEP_ScaleFactor[1] == 0) SFO_MepDis(1); //SFO for HRPWM1
while (MEP_ScaleFactor[2] == 0) SFO_MepDis(2); //SFO for HRPWM2
while (MEP_ScaleFactor[3] == 0) SFO_MepDis(3); //SFO for HRPWM3
while (MEP_ScaleFactor[4] == 0) SFO_MepDis(4); //SFO for HRPWM4
// Initialize a common seed variable MEP_ScaleFactor[0] // required for all SFO functions
MEP_ScaleFactor[0] = MEP_ScaleFactor[1]; // Common variable for SFOMepEn(n) function