www.ti.com
Operational Description of HRPWM
337
SPRUI07–March 2020
Submit Documentation Feedback
Copyright © 2020, Texas Instruments Incorporated
High-Resolution Pulse Width Modulator (HRPWM)
Both routines can be run as background tasks in a slow loop requiring negligible CPU cycles. In most
applications only one of these routines will be needed. However, if the application has free HRPWM
resources then both the routines could be used. The repetition rate at which an SFO function needs to be
executed depends on the applications operating environment. As with all digital CMOS devices
temperature and supply voltage variations have an effect on MEP operation. However, in most
applications these parameters vary slowly and therefore it is often sufficient to execute the SFO function
once every 5 to 10 seconds or so. If more rapid variations are expected, then execution may have to be
performed more frequently to match the application. Note, there is no high limit restriction on the SFO
function repetition rate, hence it can execute as quickly as the background loop is capable.
While using HRPWM feature with no SFO diagnostics, HRPWM logic will not be active for the first 3
TBCLK cycles of the PWM period. While running the application in this configuration, if CMPA register
value is less than 3 cycles, then its CMPAHR register must be cleared to zero. This would avoid any
unexpected transitions on PWM signal.
However, if SFO diagnostic function SFO_MepEn is used in the background, then HRPWM logic will not
be active for the first 6 TBCLK cycles of PWM period. While using SFO_MepEn function if CMPA register
value is less than 6 cycles, then its CMPAHR register must be cleared to zero. This would avoid any
unexpected transitions on PWM signal. Also note that the SFO_MepDis function cannot be used
concurrently with PWM signals with HRPWM enabled (see the previous section for details).
4.2.4.1 Software Usage
Software library functions SFO_MepEn(int n) and SFO_MepDis(int n) calculate the MEP scale factor for
ePWMn modules, where n = 1, 2, 3, or 4. The scale factor is an integer value in the range 1 – 255, and
represents the number of micro step edge positions available for a system clock period. The scale factor
value is returned in an array of integer variables of length 5 called MEP_ScaleFactor[5]. For example, see
Table 4-7.
(1)
MEP_ScaleFactor[0] variable is a starting value and used by the SFO software functions internally
Table 4-7. Factor Values
Software function calls Functional description Updated Variable
MEP_ScaleFactor[5]
(1)
SFO_MepDis(n)
SFO_MepDis(1); Returns the scale factor value to array index 1 MEP_ScaleFactor[1]
SFO_MepDis(2); Returns the scale factor value to array index 2 MEP_ScaleFactor[2]
SFO_MepDis(3); Returns the scale factor value to array index 3 MEP_ScaleFactor[3]
SFO_MepDis(4); Returns the scale factor value to array index 4 MEP_ScaleFactor[4]
SFO_MepEn(n)
SFO_MepEn(1); Returns the scale factor value to array index 1 MEP_ScaleFactor[1]
SFO_MepEn(2); Returns the scale factor value to array index 2 MEP_ScaleFactor[2]
SFO_MepEn(3); Returns the scale factor value to array index 3 MEP_ScaleFactor[3]
SFO_MepEn(4); Returns the scale factor value to array index 4 MEP_ScaleFactor[4]