Oscillator HRPWM API Functions

Module Details

The code for this module is contained in source/stl_osc_hr.c, with include/stl_osc_hr.h containing the API declarations for use by applications.

Note that the Dual-Clock Compare (DCC) hardware diagnostic is the recommended method for Clock checks. However, the STL_OSC_CT or STL_OSC_HR modules are provided for scenarios where DCC may not be used, such as all available DCC instances being already in use. See your device technical reference manual and device DCC examples in C2000Ware for more details about using DCC.

Error Injection

To inject an error to be detected by STL_OSC_HR_testSFO(), you can do one of the following:

  • Set mepMax and mepMin the same value so that the MEP scale factor calculated by SFO calibration will be out of range.

  • Disable HRPWM clock by clearing HRPWM bit in the PCLKCR0 register.

  • Set sfoDelay to 0 to cause timeout.

Module Details

group stl_osc_hr

Defines

STL_OSC_HR_PASS 0U
STL_OSC_HR_FAIL 1U
STL_OSC_HR_SFO_INCOMPLETE 0
STL_OSC_HR_SFO_COMPLETE 1
STL_OSC_HR_SFO_ERROR 2

Typedefs

typedef STL_OSC_HR_Obj *STL_OSC_HR_Handle

Defines the OSC HR test handle.

Functions

uint16_t STL_OSC_HR_testSFO(const STL_OSC_HR_Handle oscHRHandle)

Tests the HRPWM SFO library’s calibration process to ensure execution completion and verify value of MEP scale factor.

This function runs calibration using the SFO Library Software to calculate an appropriate Micro Edge Positioner (MEP) scale factor for HRPWM-supported ePWM modules to verify this value.

Parameters
  • oscHRHandle: is a pointer to the OSC HR object.

The ePWM module used for the test is selected by ePWMBase member of the OSC HR test object. The valid range of inputs is from EPWM1_BASE to EPWMx_BASE where x is the value specified by PWM_CH - 1. PWM_CH is defined in the SFO library header file SFO_V8.h. The channel member can be configured to select between channels A and B. The mepEdgeMode value is configured for the PWM edges to be controlled by MEP. The values mepMin and mepMax define the minimum and maximum bounds of the expected MEP scale factor range. The expected MEP scale factor for EPWMCLK of 100 MHz, given a step size of 150 ps, is about 66 MEP steps. (1/EPWMCLK)/Step size = (1/100 MHz)/150 ps is about 66.

The sfoDelay value is the delay count required for the SFO() to finish calibration. The typical EPWM cycles required for SFO() to complete calibration if called repeatedly without interrupts is 130,000 EPWMCLK cycles. Please refer to Appendix A: SFO Library Software of the Technical Reference Manual HRPWM chapter and the device datasheet for more details. The repetition rate at which SFO() needs to be executed depends on the application. If there is not a sufficiently large interval between SFO() calls, the SFO() will return and not advance to the next stage. The execution will only advance to the next stage if the previous call’s execution has completed and SFO() is called again. This interval can be experimentally calculated for a particular application.

Note

The SFO library binary is provided in the C2000Ware calibration libraries. The source code however is not publicly released. It may be made available in some cases upon request through an FAE.

Return

If the MEP scale factor calculated by the calibration falls within the MEP min and max values, the function returns STL_OSC_HR_PASS. If the calibration fails to complete in the specified delay, if SFO() returns an error status, or if the calculated MEP scale factor is outside the range, this function returns STL_OSC_HR_FAIL.

struct STL_OSC_HR_Obj
#include <stl_osc_hr.h>

Defines the OSC HR test object.