Step 2. Element Declaration
Declare an integer variable for the scale factor value as shown in
Example 4-7. Declaring an Element
int MEP_ScaleFactor = 0; //scale factor value
volatile struct EPWM_REGS *ePWM[] = {0, &EPwm1Regs, &EPwm2Regs, &EPwm3Regs,
&EPwm4Regs};
Step 3. MEP_ScaleFactor Initialization
The SFO() function does not require a starting scale factor value in MEP_ScaleFactor. Prior to using the
MEP_ScaleFactor variable in application code, SFO() should be called to drive the MEP calibration module to
calculate an MEP_ScaleFactor value.
As part of the one-time initialization code prior to using MEP_ScaleFactor, include the following shown in
.
Example 4-8. Initializing With a Scale Factor Value
MEP_ScaleFactor initialized using function SFO ()
while (SFO() == 0) {} // MEP_ScaleFactor calculated by MEP Cal Module
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 in
Note
See the HRPWM_SFO example in the device-specific C/C++ header files and peripheral examples
available from the TI website.
Example 4-9. SFO Function Calls
main ()
{
int status;
// User code
// ePWM1, 2, 3, 4 are running in HRPWM mode
// The status variable returns 1 once a new MEP_ScaleFactor has been
// calculated by the MEP Calibration Module running SFO
// diagnostics.
status = SFO();
if(status==2) {ESTOP0;} // The function returns a 2 if MEP_ScaleFactor is greater
// than the maximum 255 allowed (error condition)
}
High-Resolution Pulse Width Modulator (HRPWM)
SPRUH18I – JANUARY 2011 – REVISED JUNE 2022
TMS320x2806x Microcontrollers
399
Copyright © 2022 Texas Instruments Incorporated
Содержание TMS320 2806 Series
Страница 2: ......