EPWM
The ePWM driver provides API to configure various sub-modules within the ePWM module. Below are the high level features supported by the driver.
Features Supported
Configuration of Time Base submodule to set time-base clock, counter mode,
Configuration of Counter Compare submodule to specify duty cycle
Configuration of Action Qualifier submodule to specify the type of action to take when time-base or counter-compare event occurs
Configuration of Dead Band submodule to set rising-edge and falling-edge delay or bypass the module
Configuration of Chopper submodule to generate a chopper frequency, set pulse width of the first pulse in the chopped pulse train or bypass the module
Configuration of Trip Zone submodule to specify the tripping action to take when a fault occurs
Configuration of event-trigger submodule to trigger an interrupt and rate at which these events occur
SysConfig Features
Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
Selection of output channels.
Configuring pinmux based on selected pin.
Enabling TimeBase Clock based on selected ePWM instance.
Features NOT Supported
ePWM digital comparator modules
ePWM high-resolution modules
Important Usage Guidelines
NA
Example Usage
Include the below file to access the APIs
#include <drivers/epwm.h>
Check external Synchronization signal
uint16_t tbStatus = EPWM_tbGetStatus(ePWMBaseAddr, EPWM_TB_STS_SYNCI);
if(0 == tbStatus)
{
DebugP_log("External Synchronization event has occured\r\n");
}
else
{
DebugP_log("No external Synchronization event has occured\r\n");
}
Get Timebase Counter direction
uint16_t tbStatus = EPWM_tbGetStatus(ePWMBaseAddr, EPWM_TB_STS_CTR_DIR);
if(0 == tbStatus)
{
DebugP_log("Time base counter is currently counting down\r\n");
}
else
{
DebugP_log("Time base counter is currently counting up\r\n");
}
Configure Counter compare
uint32_t counterCmpVal = 0x100;
uint32_t status;
status =EPWM_counterComparatorCfg(ePWMBaseAddr, EPWM_CC_CMP_A, counterCmpVal, EPWM_SHADOW_REG_CTRL_ENABLE, EPWM_CC_CMP_LOAD_MODE_CNT_EQ_PRD, FALSE);
if(TRUE == status)
{
DebugP_log("Comparator value was written successfully\r\n");
}
else
{
DebugP_log("Comparator value write failed\r\n");
}
API Reference
This file contains declarations of CSL APIs corresponding to the ePWM module. This also contains necessary structure, enum and macro definitions and APIs are consolidated to provide more functional APIs.
Programming sequence of EPWM is as follows:
Enable Clocks for PWMSS
Configure the pinmux functionality
Enable the clocks for EPWM through the API EPWM_ClockEnable.
Enable the Time base clock through the API PWMSSTimebaseClkEnable.
The sub-modules of EPWM have to be configured as below:
Timebase
Configure the time base clock through the API EPWM_tbTimebaseClkCfg
Configure the output PWM frequency through the API EPWM_tbPwmFreqCfg
If synchronization is enable, then configure the synchronization through the API EPWM_tbSyncEnable else disable synchronization through the API EPWM_tbSyncDisable
Set the sync out mode through the API EPWM_tbSetSyncOutMode
Set the emulation mode through the API EPWM_tbSetEmulationMode
Counter comparator
Configure the counter comparator through the API EPWM_counterComparatorCfg
DeadBand
If deadband is enabled, then configure deadband through the API EPWM_deadbandCfg else bypass the deadband through the API EPWM_deadbandBypass
Chopper
If chopper is enabled
Configure chopper through the API EPWM_chopperCfg
Enable the chopper through the API EPWM_chopperEnable by passing TRUE as parameter
If chopper is disabled
Disable chopper through the API EPWM_chopperEnable by passing FALSE as parameter
TripZone
If tripzone is enabled
Configure trip action through API EPWM_tzTriggerTripAction
Enable trip zone event through the API EPWM_tzTripEventEnable
If tripzone is disabled
Disable both the trip zone events through the API EPWM_tzTripEventDisable
Event Trigger
Enable event trigger through the API EPWM_etIntrCfg
Disable event trigger through the API EPWM_etIntrDisable
EPWM Output Channel
-
EPWM_OUTPUT_CH_MIN
Minimum value of enumeration. Used for input validation.
-
EPWM_OUTPUT_CH_A
Output channel A.
-
EPWM_OUTPUT_CH_B
Output channel B.
-
EPWM_OUTPUT_CH_MAX
Maximum value of enumeration. Used for input validation.
-
typedef uint32_t EPWM_OutputCh_t
Number of supported EPWM outputs in a single epwm channel.
EPWM Tb Counter Direction
-
EPWM_TB_COUNTER_DIR_UP
Up Count mode.
-
EPWM_TB_COUNTER_DIR_DOWN
Down count mode.
-
EPWM_TB_COUNTER_DIR_UP_DOWN
Up down count mode.
-
EPWM_TB_COUNTER_DIR_STOP
stop-freeze counter operation (default on reset).
-
typedef uint32_t EPWM_TbCounterDir_t
Types of Time base counter direction modes.
EPWM Shadow register Control
-
EPWM_SHADOW_REG_CTRL_ENABLE
Shadow register value will be used.
-
EPWM_SHADOW_REG_CTRL_DISABLE
Shadow register is disabled and active register value will be used.
-
typedef uint32_t EPWM_ShadowRegCtrl_t
Shadow register enable or disable control.
Same macros will be used to control the following shadow registers
Time Base period register
Counter Comparator A register
Counter Comparator B register
Note
Same macros are used for controlling all the three registers because the field values are same for all these cases.
Shadow enable = 0x0
Shadow disable = 0x1 In any case if these values changes across the above mentioned registers then separate macros need to be used.
Shadow enable macros with value 0x0
PWMSS_EPWM_TBCTL_PRDLD_LOAD_FROM_SHADOW,
PWMSS_EPWM_CMPCTL_SHDWAMODE_SHADOW,
PWMSS_EPWM_CMPCTL_SHDWBMODE_SHADOW
Shadow disable macros with value 0x1
PWMSS_EPWM_TBCTL_PRDLD_LOAD_IMMEDIATELY
PWMSS_EPWM_CMPCTL_SHDWAMODE_IMMEDIATE
PWMSS_EPWM_CMPCTL_SHDWBMODE_IMMEDIATE
EPWM Counter directions after sync event
-
EPWM_TB_CNT_DIR_AFT_SYNC_DOWN
Count down after the synchronization event.
-
EPWM_TB_CNT_DIR_AFT_SYNC_UP
Count up after the synchronization event.
-
typedef uint32_t EPWM_TbCntDirAftSync_t
Counter directions after sync event.
EPWM Source of Synchronization output signal
-
EPWM_TB_SYNC_OUT_EVT_SYNCIN
Sync Input signal.
-
EPWM_TB_SYNC_OUT_EVT_CNT_EQ_ZERO
Time-base counter equal to zero.
-
EPWM_TB_SYNC_OUT_EVT_CNT_EQ_CMP_B
Time-base counter equal to counter-compare B (TBCNT = CMPB).
-
EPWM_TB_SYNC_OUT_EVT_DISABLE
Disable EPWMxSYNCO(Sync Output) signal.
-
typedef uint32_t EPWM_TbSyncOutEvt_t
Source of Synchronization output signal.
EPWM Flags to get the different types of time base status
-
EPWM_TB_STS_CTR_MAX
Time-Base Counter Max Latched Status.
-
EPWM_TB_STS_SYNCI
Input Synchronization Latched Status.
-
EPWM_TB_STS_CTR_DIR
Time-Base Counter Direction Status.
-
typedef uint32_t EPWM_TbSts_t
Flags to get the different types of time base status.
EPWM Emulation Mode
-
EPWM_TB_EMU_MODE_STP_AFT_NEXT_CYCLE
Stop after the next time-base counter increment or decrement.
-
EPWM_TB_EMU_MODE_STP_AFT_COMPLETE_CYCLE
Stop after the next time-base counter increment or decrement. Up-count mode: stop when the time-base counter = period. Down-count mode: stop when the time-base counter = 0000. Up-down-count mode: stop when the time-base counter = 0000.
-
EPWM_TB_EMU_MODE_FREE_RUN
Counter is in Free run.
-
typedef uint32_t EPWM_TbEmuMode_t
Emulation Mode. This selects the behaviour of the ePWM time-base counter during emulation events.
EPWM Comparator type
-
EPWM_CC_CMP_MIN
Minimum value of enumeration. Used for input validation.
-
EPWM_CC_CMP_A
Counter Comparator A.
-
EPWM_CC_CMP_B
Counter Comparator B.
-
EPWM_CC_CMP_MAX
Maximum value of enumeration. Used for input validation.
-
typedef uint32_t EPWM_CcCmp_t
\ Counter Comparator type either A or B.
EPWM Counter-Comparator registers(A and B) load mode
-
EPWM_CC_CMP_LOAD_MODE_CNT_EQ_ZERO
Load on CTR = 0: Time-base counter equal to zero.
-
EPWM_CC_CMP_LOAD_MODE_CNT_EQ_PRD
Load on CTR = PRD: Time-base counter equal to period.
-
EPWM_CC_CMP_LOAD_MODE_CNT_EQ_ZERO_OR_PRD
Load on either CTR = 0 or CTR = PRD.
-
EPWM_CC_CMP_LOAD_MODE_NO_LOAD
Freeze (no loads possible).
-
typedef uint32_t EPWM_CcCmpLoadMode_t
Counter-Comparator registers(A and B) load mode flags from shadow register.
Same macros will be used to control the following registers
Counter Comparator A register
Counter Comparator B register
Note
Same macros are used for controlling all the three registers because the field values are same for all these cases.
load when counter equals zero = 0x0
load when counter equals period = 0x1
load when counter equals zero or period = 0x2
Do not load = 0x3 In any case if these values changes across the above mentioned registers, then separate macros need to be used.
Load when counter equals zero macros with value 0x0
PWMSS_EPWM_CMPCTL_LOADAMODE_CTR_0,
PWMSS_EPWM_CMPCTL_LOADBMODE_CTR_0,
Load when counter equals period macros with value 0x1
PWMSS_EPWM_CMPCTL_LOADAMODE_CTR_PRD
PWMSS_EPWM_CMPCTL_LOADBMODE_CTR_PRD
Load when counter equals zero or period macros with value 0x2
PWMSS_EPWM_CMPCTL_LOADAMODE_CTR_0_OR_PRD
PWMSS_EPWM_CMPCTL_LOADBMODE_CTR_0_OR_PRD
Do not load macros with value 0x3
PWMSS_EPWM_CMPCTL_LOADAMODE_FREEZE
PWMSS_EPWM_CMPCTL_LOADBMODE_FREEZE
EPWM Actions
-
EPWM_AQ_ACTION_DONOTHING
Do nothing (Action disabled).
-
EPWM_AQ_ACTION_LOW
Clear: Force EPWMx output low.
-
EPWM_AQ_ACTION_HIGH
Set: Force EPWMx output high.
-
EPQM_AQ_ACTION_TOLLGE
-
EPWM_AQ_ACTION_TOLLGE
Toggle EPWMx output: low output signal will be forced high, and a high signal will be forced low.
-
typedef uint32_t EPWM_AqAction_t
Types of Actions that Action Qualifier can take on the Output when the supported counter compare event occurs.
Same actions will be applicable for all the supported events and same actions are applicable for both A and B channel PWM outputs.
Note
Same macros are used for all the events and for both A and B because their field values are same.
Action Do nothing macros with value 0x0
PWMSS_EPWM_AQCTLx_ZRO_DISABLED
PWMSS_EPWM_AQCTLx_PRD_DISABLED
PWMSS_EPWM_AQCTLx_CAU_DISABLED
PWMSS_EPWM_AQCTLx_CAD_DISABLED
PWMSS_EPWM_AQCTLx_CBU_DISABLED
PWMSS_EPWM_AQCTLx_CBD_DISABLED
Action high macros with value 0x1
PWMSS_EPWM_AQCTLx_ZRO_CLEAR
PWMSS_EPWM_AQCTLx_PRD_CLEAR
PWMSS_EPWM_AQCTLx_CAU_CLEAR
PWMSS_EPWM_AQCTLx_CAD_CLEAR
PWMSS_EPWM_AQCTLx_CBU_CLEAR
PWMSS_EPWM_AQCTLx_CBD_CLEAR
Action low macros with value 0x2
PWMSS_EPWM_AQCTLx_ZRO_SET
PWMSS_EPWM_AQCTLx_PRD_SET
PWMSS_EPWM_AQCTLx_CAU_SET
PWMSS_EPWM_AQCTLx_CAD_SET
PWMSS_EPWM_AQCTLx_CBU_SET
PWMSS_EPWM_AQCTLx_CBD_SET
Action toggle macros with value 0x3
PWMSS_EPWM_AQCTLx_ZRO_TOGGLE
PWMSS_EPWM_AQCTLx_PRD_TOGGLE
PWMSS_EPWM_AQCTLx_CAU_TOGGLE
PWMSS_EPWM_AQCTLx_CAD_TOGGLE
PWMSS_EPWM_AQCTLx_CBU_TOGGLE
PWMSS_EPWM_AQCTLx_CBD_TOGGLE
EPWM output actions
-
EPWM_AQ_SW_TRIG_OT_ACTION_DONOTHING
Do nothing (Action disabled).
-
EPWM_AQ_SW_TRIG_OT_ACTION_LOW
Clear: Output Low.
-
EPWM_AQ_SW_TRIG_OT_ACTION_HIGH
Set: Output high.
-
EPWM_AQ_SW_TRIG_OT_ACTION_TOGGLE
Toggle output.
-
typedef uint32_t EPWM_AqSwTrigOtAction_t
Actions to be taken on the output, when Software triggered one time events will occur.
Same macros will be used for both A and B channel outputs because the bit field values are same.
Note
The following are the similar macros,
Do nothing macros with value 0x0
PWMSS_EPWM_AQSFRC_ACTSFA_DISABLED
PWMSS_EPWM_AQSFRC_ACTSFB_DISABLED
Action low macros with value 0x1
PWMSS_EPWM_AQSFRC_ACTSFA_CLEAR
PWMSS_EPWM_AQSFRC_ACTSFB_CLEAR
Action high macros with value 0x2
PWMSS_EPWM_AQSFRC_ACTSFA_SET
PWMSS_EPWM_AQSFRC_ACTSFB_SET
Action toggle macros with value 0x3
PWMSS_EPWM_AQSFRC_ACTSFA_TOGGLE
PWMSS_EPWM_AQSFRC_ACTSFB_TOGGLE
EPWM Continuous software forced actions
-
EPWM_AQ_SW_TRIG_CONT_ACTION_NOEFFECT
Forcing disabled, that is, has no effect.
-
EPWM_AQ_SW_TRIG_CONT_ACTION_LOW
Forces a continuous low on output A.
-
EPWM_AQ_SW_TRIG_CONT_ACTION_HIGH
Forces a continuous high on output A.
-
EPWM_AQ_SW_TRIG_CONT_ACTION_SW_DISBALED
Software forcing is disabled and has no effect.
-
typedef uint32_t EPWM_AqSwTrigContAction_t
Types of Continuous software forced actions on output.
Same macros will be used for configuration of both A and B PWM outputs, because bit field values for both A and B are same.
Note
The following are the similar macros,
Do nothing macros with value 0x0
PWMSS_EPWM_AQCSFRC_CSFA_DISABLED
PWMSS_EPWM_AQCSFRC_CSFB_DISABLED
Action low macros with value 0x1
PWMSS_EPWM_AQCSFRC_CSFA_LOW_OUTPUT
PWMSS_EPWM_AQCSFRC_CSFB_LOW_OUTPUT
Action high macros with value 0x2
PWMSS_EPWM_AQCSFRC_CSFA_HIGH_OUTPUT
PWMSS_EPWM_AQCSFRC_CSFB_HIGH_OUTPUT
Action toggle macros with value 0x3
PWMSS_EPWM_AQCSFRC_CSFA_NO_EFFECT
PWMSS_EPWM_AQCSFRC_CSFB_NO_EFFECT
EPWM Software Force Active Register Reload
-
EPWM_AQ_CSFRC_REG_RELOAD_CNT_EQ_ZRO
Load on event counter equals zero.
-
EPWM_AQ_CSFRC_REG_RELOAD_CNT_EQ_PRD
Load on event counter equals period.
-
EPWM_AQ_CSFRC_REG_RELOAD_CNT_EQ_ZRO_OR_PRD
Load on event counter equals zero or counter equals period.
-
EPWM_AQ_CSFRC_REG_RELOAD_IMMEDIATE
Load immediately.
-
typedef uint32_t EPWM_AqCsfrcRegReload_t
Action Qualifier Software Force Active Register Reload From Shadow Options.
EPWM Dead Band Input Mode Control
-
EPWM_DB_IN_MODE_A_RED_A_FED
EPWMxA In (from the action-qualifier) is the source for both falling-edge and rising-edge delay.
-
EPWM_DB_IN_MODE_B_RED_A_FED
EPWMxB In (from the action-qualifier) is the source for rising-edge delayed signal. EPWMxA In (from the action-qualifier) is the source for falling-edge delayed signal.
-
EPWM_DB_IN_MODE_A_RED_B_FED
EPWMxA In (from the action-qualifier) is the source for rising-edge delayed signal. EPWMxB In (from the action-qualifier) is the source for falling-edge delayed signal.
-
EPWM_DB_IN_MODE_B_RED_B_FED
EPWMxB In (from the action-qualifier) is the source for both rising-edge delay and falling-edge delayed signal.
-
typedef uint32_t EPWM_DbInMode_t
Dead Band Input Mode Control. This allows you to select the input source to the falling-edge and rising-edge delay.
EPWM Polarity Select Control
-
EPWM_DB_POL_SEL_ACTV_HIGH
Neither EPWMxA nor EPWMxB is inverted (default).
-
EPWM_DB_POL_SEL_ACTV_LOW_COMPLEMENTARY
EPWMxA is inverted.
-
EPWM_DB_POL_SEL_ACTV_HIGH_COMPLEMENTARY
EPWMxB is inverted.
-
EPWM_DB_POL_SEL_ACTV_LOW
Both EPWMxA and EPWMxB are inverted.
-
typedef uint32_t EPWM_DbPolSel_t
Polarity Select Control. This allows you to selectively invert one of the delayed signals before it is sent out of the dead-band sub-module.
EPWM Dead-band Output Mode Control
-
EPWM_DB_OUT_MODE_BYPASS
Dead-band generation is bypassed for both output signals. In this mode, both the EPWMxA and EPWMxB output signals from the action-qualifier are passed directly to the PWM-chopper sub-module.
-
EPWM_DB_OUT_MODE_NO_RED_B_FED
Disable rising-edge delay. The EPWMxA signal from the action-qualifier is passed straight through to the EPWMxA input of the PWM-chopper sub-module. The falling-edge delayed signal is seen on output EPWMxB
-
EPWM_DB_OUT_MODE_A_RED_NO_FED
Disable falling-edge delay. The EPWMxB signal from the action-qualifier is passed straight through to the EPWMxB input of the PWM-chopper sub-module. The rising-edge delayed signal is seen on output EPWMxA.
-
EPWM_DB_OUT_MODE_A_RED_B_FED
Dead-band is fully enabled for both rising-edge delay on output EPWMxA and falling-edge delay on output EPWMxB.
-
typedef uint32_t EPWM_DbOutMode_t
Dead-band Output Mode Control. This allows you to selectively enable or bypass the dead-band generation for the falling-edge and rising-edge delay.
EPWM Chopping Clock Duty Cycle
-
EPWM_CHP_DUTY_CYCLE_PERC_12PNT5
Duty cycle 1/8 (12.5%).
-
EPWM_CHP_DUTY_CYCLE_PERC_25
Duty cycle 2/8 (25%).
-
EPWM_CHP_DUTY_CYCLE_PERC_37PNT5
Duty cycle 3/8 (37.5%).
-
EPWM_CHP_DUTY_CYCLE_PERC_50_PER
Duty cycle 4/8 (50%).
-
EPWM_CHP_DUTY_CYCLE_PERC_62PNT5
Duty cycle 5/8 (62.5%).
-
EPWM_CHP_DUTY_CYCLE_PERC_75
Duty cycle 6/8 (75%).
-
EPWM_CHP_DUTY_CYCLE_PERC_87PNT5
Duty cycle 7/8 (87.5%).
-
typedef uint32_t EPWM_ChpDutyCycle_t
Chopping Clock Duty Cycle values.
EPWM Chopping Clock Frequency
-
EPWM_CHP_CLK_FREQ_DIV_BY_1
Divide by 1 (no prescale).
-
EPWM_CHP_CLK_FREQ_DIV_BY_2
Divide by 2.
-
EPWM_CHP_CLK_FREQ_DIV_BY_3
Divide by 3.
-
EPWM_CHP_CLK_FREQ_DIV_BY_4
Divide by 4.
-
EPWM_CHP_CLK_FREQ_DIV_BY_5
Divide by 5.
-
EPWM_CHP_CLK_FREQ_DIV_BY_6
Divide by 6.
-
EPWM_CHP_CLK_FREQ_DIV_BY_7
Divide by 7.
-
EPWM_CHP_CLK_FREQ_DIV_BY_8
Divide by 8.
-
typedef uint32_t EPWM_ChpClkFreq_t
Chopping Clock Frequency values .
EPWM One-Shot Pulse Width
-
EPWM_CHP_OSHT_WIDTH_MIN
Minimum value of enumeration. Used for input validation.
-
EPWM_CHP_OSHT_WIDTH_1XSYSOUT_BY_8
1 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_2XSYSOUT_BY_8
2 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_3XSYSOUT_BY_8
3 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_4XSYSOUT_BY_8
4 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_5XSYSOUT_BY_8
5 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_6XSYSOUT_BY_8
6 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_7XSYSOUT_BY_8
7 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_8XSYSOUT_BY_8
8 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_9XSYSOUT_BY_8
9 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_10XSYSOUT_BY_8
10 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_11XSYSOUT_BY_8
11 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_12XSYSOUT_BY_8
12 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_13XSYSOUT_BY_8
13 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_14XSYSOUT_BY_8
14 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_15XSYSOUT_BY_8
15 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_16XSYSOUT_BY_8
16 x SYSCLKOUT/8 wide.
-
EPWM_CHP_OSHT_WIDTH_MAX
Maximum value of enumeration. Used for input validation.
-
typedef uint32_t EPWM_ChpOshtWidth_t
One-Shot Pulse Width values.
EPWM output action when a trip event occurs
-
EPWM_TZ_TRIP_ACTION_TRI_STATE
High impedance (EPWMxA = High-impedance state).
-
EPWM_TZ_TRIP_ACTION_HIGH
Force EPWMxA to a high state.
-
EPWM_TZ_TRIP_ACTION_LOW
Force EPWMxA to a low state.
-
EPWM_TZ_TRIP_ACTION_DO_NOTHING
Do nothing, no action is taken on EPWMxA.
-
typedef uint32_t EPWM_TzTripAction_t
Action to be taken on PWM output When a trip event occurs.
Same macros will be used to control both A and B outputs because the bit field values are same for A and B channels.
Note
The following are the similar macros
Tri state action macro with value 0x0
PWMSS_EPWM_TZCTL_TZA_HIGH_IMPEDANCE
PWMSS_EPWM_TZCTL_TZB_HIGH_IMPEDANCE
High action macro with value 0x1
PWMSS_EPWM_TZCTL_TZA_HIGH_STATE
PWMSS_EPWM_TZCTL_TZA_HIGH_STATE
Low action macro with value 0x2
PWMSS_EPWM_TZCTL_TZA_LOW_STATE
PWMSS_EPWM_TZCTL_TZB_LOW_STATE
Do nothing action macro with value 0x3
PWMSS_EPWM_TZCTL_TZA_DO_NOTHING
PWMSS_EPWM_TZCTL_TZB_DO_NOTHING
EPWM trip zone events
-
EPWM_TZ_EVENT_MIN
Minimum value of enumeration. Used for input validation.
-
EPWM_TZ_EVENT_ONE_SHOT
One shot trip zone event.
-
EPWM_TZ_EVENT_CYCLE_BY_CYCLE
Cycle by cycle trip zone event.
-
EPWM_TZ_EVENT_MAX
Maximum value of enumeration. Used for input validation.
-
typedef uint32_t EPWM_TzEvent_t
Type of trip zone events.
EPWM Trip zone status flags
-
EPWM_TZ_STS_FLG_OST
Latched Status Flag for A One-Shot Trip Event.
-
EPWM_TZ_STS_FLG_CBC
Latched Status Flag for Cycle-By-Cycle Trip Event.
-
EPWM_TZ_STS_FLG_INT
Latched status for Trip Interrupt .
-
typedef uint32_t EPWM_TzStsFlg_t
Trip zone status flags.
EPWM Interrupt (EPWMx_INT) Selection Options
-
EPWM_ET_INTR_EVT_CNT_EQ_ZRO
Enable event time-base counter equal to zero. (TBCNT = 0000h).
-
EPWM_ET_INTR_EVT_CNT_EQ_PRD
Enable event time-base counter equal to period (TBCNT = TBPRD).
-
EPWM_ET_INTR_EVT_CNT_EQ_CMPA_INC
Enable event time-base counter equal to CMPA when the timer is incrementing.
-
EPWM_ET_INTR_EVT_CNT_EQ_CMPA_DEC
Enable event time-base counter equal to CMPA when the timer is decrementing.
-
EPWM_ET_INTR_EVT_CNT_EQ_CMPB_INC
Enable event: time-base counter equal to CMPB when the timer is incrementing.
-
EPWM_ET_INTR_EVT_CNT_EQ_CMPB_DEC
Enable event: time-base counter equal to CMPB when the timer is decrementing.
-
typedef uint32_t EPWM_EtIntrEvt_t
ePWM Interrupt (EPWMx_INT) Selection Options.
EPWM Interrupt (EPWMx_INT) Period Select
-
EPWM_ET_INTR_PERIOD_DIS_INTR
Disable the interrupt event counter. No interrupt will be generated.
-
EPWM_ET_INTR_PERIOD_FIRST_EVT
Generate an interrupt on the first event.
-
EPWM_ET_INTR_PERIOD_SECOND_EVT
Generate an interrupt on the second event.
-
EPWM_ET_INTR_PERIOD_THIRD_EVT
Generate an interrupt on the third event.
-
typedef uint32_t EPWM_EtIntrPeriod_t
ePWM Interrupt (EPWMx_INT) Period Select. These values determine how many selected events need to occur before an interrupt is generated.
Defines
-
EPWM_ETFLG_INT_MASK
Mask used to check interrupt status.
Functions
-
void EPWM_tbTimebaseClkCfg(uint32_t baseAddr, uint32_t tbClk, uint32_t moduleClk)
This API configures the clock divider of the Time base module.
The clock divider can be calculated using the equation TBCLK = SYSCLKOUT/(HSPCLKDIV × CLKDIV)
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tbClk – Timebase clock to be generated in Hz.
moduleClk – Input clock of the PWM module (sysclk2) in Hz.
-
void EPWM_tbPwmFreqCfg(uint32_t baseAddr, uint32_t tbClk, uint32_t pwmFreq, uint32_t counterDir, uint32_t enableShadowWrite)
This API configures the PWM Time base counter Frequency/Period.
The period count determines the period of the final output waveform.
Note
If the counter direction is configured as EPWM_TB_COUNTER_DIR_UP_DOWN, then output frequency will be half the value of required pwm frequency.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tbClk – Timebase clock in Hz.
pwmFreq – Frequency of the PWM Output in Hz.
counterDir – Direction of the counter(up, down, up-down). ‘counterDir’ can take values from the following enum
enableShadowWrite – Flag controlling Whether write to Period register is to be shadowed or not. ‘enableShadowWrite’ can take values from the following enum
-
void EPWM_tbSyncEnable(uint32_t baseAddr, uint32_t tbPhsValue, uint32_t counterDir)
This API enables the synchronization of time base sub-module and also configures the phase count value to be loaded after sync event, counter direction after sync event.
When a sync-in event is generated the the time base counter is reloaded with the new value. After sync the counter will use the new value and direction as specified after sync event.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tbPhsValue – Phase value to be reloaded after sync
counterDir – Count direction after sync. ‘counterDir’ can take values from the following enum
-
void EPWM_tbSyncDisable(uint32_t baseAddr)
This API disables the synchronization. Even if sync-in event occurs the count value will not be reloaded.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
-
void EPWM_tbSetSyncOutMode(uint32_t baseAddr, uint32_t syncOutMode)
This API selects the source of the synchronization output signal. It determines on which of the supported events sync-out has to be generated.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
syncOutMode – Sync out mode. ‘syncOutMode’ can take values from the following enum
-
void EPWM_tbTriggerSwSync(uint32_t baseAddr)
This API generates software triggered sync pulse.
Note
This API can be used for testing. When this API is called sync-in event will be generated.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
-
void EPWM_tbWriteTbCount(uint32_t baseAddr, uint32_t tbCount)
This API loads the Time base counter. The new value is taken immediately.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tbCount – Time base count value to be loaded.
-
uint16_t EPWM_tbReadTbCount(uint32_t baseAddr)
This API gets the Time base counter current value. The count operation is not affected by the read.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
- Return values:
tbCount – Current Timebase count value.
-
uint16_t EPWM_tbGetStatus(uint32_t baseAddr, uint32_t tbStatusMask)
This API gets the Time Base status as indicated by the tbStatusMask parameter.
Note
The returned status will depend on the status mask passed.
Zero indicates the time-base counter never reached its max value.
NonZero indicates that the time-base counter reached max value 0xFFFF
Zero indicates that no external synchronization event has occurred.
NonZero indicates that an external synchronization event has occurred.
Zero indicates that Time-Base Counter is currently counting down.
NonZero indicates that Time-Base Counter is currently counting up.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tbStatusMask – Flag indicating the type of status needed. ‘tbStatusMask’ can take values from the following enum
- Return values:
tbStatus – Requested status is returned.
-
void EPWM_tbStatusClear(uint32_t baseAddr, uint32_t tbStatusClrMask)
This API clears the Time base status bits indicated by the tbStatusClrMask parameter.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tbStatusClrMask – Mask indicating which status bit need to be cleared ‘tbStatusClrMask’ can take following values
-
void EPWM_tbSetEmulationMode(uint32_t baseAddr, uint32_t mode)
This API configures emulation mode. This setting determines the behaviour of Timebase counter during emulation (debugging).
- Parameters:
baseAddr – Base Address of PWMSS instance used.
mode – Emulation mode. ‘mode’ can take values from the following enum
-
uint32_t EPWM_counterComparatorCfg(uint32_t baseAddr, uint32_t cmpType, uint32_t cmpVal, uint32_t enableShadowWrite, uint32_t shadowToActiveLoadTrigger, uint32_t overwriteShadow)
This API configures the counter comparator and loads the comparator value. When Counter comparator value equals the counter value, then an event is generated both in the up direction and down direction.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
cmpType – Comparator Type A or B. ‘cmpType’ can take values from the following enum
cmpVal – Comparator value that needs to be loaded.
enableShadowWrite – Enable write to shadow register. ‘enableShadowWrite’ can take values from the following enum
shadowToActiveLoadTrigger – Shadow to active register load mode. ‘shadowToActiveLoadTrigger’ can take values from the following enum
overwriteShadow – Overwrite even if previous value is not loaded to active register. ‘overwriteShadow’ can take following values
TRUE
FALSE
- Return values:
TRUE – Comparator value is written successfully.
FALSE – Comparator value write is failed.
-
void EPWM_aqActionOnOutputCfg(uint32_t baseAddr, uint32_t pwmOutputCh, const EPWM_AqActionCfg *pCfg)
This API configures the action to be taken on output by the Action qualifier module upon receiving the events. This will determine the output waveform.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
pwmOutputCh – PWM Output channel type either A or B ‘pwmOutputCh’ can take values from the following enum
pCfg – Pointer to the following structure which contains the action configuration variables for different events
-
void EPWM_aqSwTriggerOneTimeAction(uint32_t baseAddr, uint32_t pwmOutputCh, uint32_t swTrigAction)
This API triggers the SW forced single event on the PWM output.
This can be used for testing the AQ sub-module. Every call to this API will trigger a single event.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
pwmOutputCh – PWM Output channel type either A or B ‘pwmOutputCh’ can take values from the following enum
swTrigAction – Action that needs to be taken on the PWM output. ‘swTrigAction’ can take one of the following enum values
-
void EPWM_aqSwTriggerContAction(uint32_t baseAddr, uint32_t pwmOutputCh, uint32_t swTrigAction, uint32_t activeRegReloadMode)
This API forces output value continuously on PWM output channel. The output can be forced to low or high.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
pwmOutputCh – PWM Output channel type either A or B ‘pwmOutputCh’ can take values from the following enum
swTrigAction – Value to be forced on the output This parameter can take values from the following enum
activeRegReloadMode – Shadow to active reg load trigger. This parameter can take values from the following enum
-
void EPWM_deadbandCfg(uint32_t baseAddr, const EPWM_DeadbandCfg *pCfg)
This API performs the configuration of the dead band sub-module. This API configures the input source, output mode, polarity, rising and falling edge delays.
The Dead band generator has two sub-modules, one for raising edge delay and the other for falling edge delay. This can be configured when a delay is need between two signals during signal change. The dead band generator is useful in full-inverters.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
pCfg – Pointer to the structure EPWM_DeadbandCfg containing the dead band configuration parameters.
-
void EPWM_deadbandBypass(uint32_t baseAddr)
This API bypasses the Dead-band sub-module.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
-
void EPWM_chopperCfg(uint32_t baseAddr, const EPWM_ChopperCfg *pCfg)
This API performs the configuration of the chopper sub-module. This API configures chopping clock duty cycle, chopping clock frequency and pulse width of first pulse of chopping clock.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
pCfg – Pointer to the structure EPWM_ChopperCfg containing the chopper configuration parameters.
-
void EPWM_chopperEnable(uint32_t baseAddr, uint32_t enableChopper)
This API controls the enabling or disabling of chopper sub-module.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
enableChopper – Flag controlling the enabling or disabling ‘enableChopper’ can take one of the following values
TRUE - Enable chopper
FALSE - Disable chopper
-
void EPWM_tzTriggerTripAction(uint32_t baseAddr, uint32_t tripAction, uint32_t pwmOutputCh)
This API configures the o/p on PWM channel when a trip event is recognized. The output can be set to high or low or high impedance.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tripAction – Action to be taken on the PWM output. This parameter can take values from the following enum
pwmOutputCh – PWM Output channel type either A or B ‘pwmOutputCh’ can take values from the following enum
-
void EPWM_tzTripEventEnable(uint32_t baseAddr, uint32_t tzEventType, uint32_t pinNum)
This API enables the trip event.
The trip signals indicates external fault, and the ePWM outputs can be programmed to respond accordingly when faults occur.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tzEventType – Enable OST or CBC trip zone event This parameter can take values from the following enum
pinNum – Pin number on which trip zone event has to be enabled.
-
void EPWM_tzTripEventDisable(uint32_t baseAddr, uint32_t tzEventType, uint32_t pinNum)
This API disable the trip event. The disabled trip events will be ignored.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tzEventType – Disable OST or CBC trip zone event This parameter can take values from the following enum
pinNum – Pin number on which trip zone event has to be disabled.
-
void EPWM_tzIntrEnable(uint32_t baseAddr, uint32_t tzEventType)
This API enables the trip interrupt. When trip event occurs the sub-module can be configured to interrupt CPU.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tzEventType – Trip zone event for which interrupt has to be enabled. This parameter can take values form the following enum
-
void EPWM_tzIntrDisable(uint32_t baseAddr, uint32_t tzEventType)
This API disables the trip interrupt.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tzEventType – Trip zone event for which interrupt has to be enabled. This parameter can take values form the following enum
-
uint16_t EPWM_tzEventStatus(uint32_t baseAddr, uint32_t eventMask)
This API returns the selected trip zone event status.
Note
The return status depends on the type of status flag passed.
Zero - No one-shot trip event has occurred.
NonZero - Indicates a trip event has occurred on a pin selected as a one-shot trip source.
Zero - No cycle-by-cycle trip event has occurred.
NonZero - Indicates a trip event has occurred on a pin selected as a cycle-by-cycle trip source.
Zero - Indicates no interrupt has been generated.
NonZero - Indicates an EPWMxTZINT interrupt was generated because of a trip condition.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
eventMask – Type of status which has to be read. This parameter can take values from the following enum
- Return values:
Status – Status of the required status flag.
-
void EPWM_tzEventStatusClear(uint32_t baseAddr, uint32_t eventMask)
This API clears the selected trip zone event status.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
eventMask – Type of status which has to be read. This parameter can take values from the following enum
-
void EPWM_tzTriggerSwEvent(uint32_t baseAddr, uint32_t tzEventType)
This API enables to generate Software forced trip condition.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
tzEventType – Type of trip condition which has to be generated. This parameter can take values from the following enum
-
void EPWM_etIntrCfg(uint32_t baseAddr, uint32_t intrEvtSrc, uint32_t intrPrd)
This API configures the Event Trigger sub-module. This API configures the interrupt source and interrupt period.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
intrEvtSrc – Event source which triggers interrupt. This parameter can take values from the following enum
intrPrd – prescalar value(This determines how may selected events need to occur before an interrupt is generated). This parameter can take values from the following enum
-
void EPWM_etIntrEnable(uint32_t baseAddr)
This API enables the ePWM Event interrupt.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
-
void EPWM_etIntrDisable(uint32_t baseAddr)
This API disables the ePWM Event interrupt.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
-
uint16_t EPWM_etIntrStatus(uint32_t baseAddr)
This API returns the ePWM event interrupt status.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
- Return values:
0 – Interrupt is not generated.
1 – Interrupt is generated.
-
void EPWM_etIntrClear(uint32_t baseAddr)
This API clears the interrupt. This will clear the interrupt flag bit and enable further interrupts pulses to be generated.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
-
void EPWM_etIntrTrigger(uint32_t baseAddr)
This API forces interrupt to be generated. This API is used for testing purpose.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
-
uint16_t EPWM_etGetEventCount(uint32_t baseAddr)
This API returns the number of events occurred.
- Parameters:
baseAddr – Base Address of PWMSS instance used.
- Return values:
eventCount – number of events occurred. This will have values in the range 0 to 3.
-
struct EPWM_TimebaseCfg
- #include <epwm.h>
Structure holding the TimeBase sub-module configuration parameters.
Public Members
-
uint32_t tbClk
Time base clock.
-
uint32_t pwmtbCounterFreqPrd
PWM Time base counter Frequency/Period.
-
uint32_t tbCntrDirection
Time base counter direction. This can take values from the following enum EPWM_TbCounterDir_t.
-
uint32_t enableSynchronization
Enable synchronization inside the timebase sub-module. This can take following two values TRUE or FALSE.
-
uint32_t cntDirAfterSync
Direction of the counter after the sync event is occurred. This can take values from the following enum EPWM_TbCntDirAftSync_t.
-
uint32_t phsCountAfterSync
Value of the phase counter to be loaded after the sync event.
-
uint32_t syncOutSrc
Source of synchronization output signal. This can take values from the following enum EPWM_TbSyncOutEvt_t.
-
uint32_t tbClk
-
struct EPWM_CounterCmpCfg
- #include <epwm.h>
Structure holding the Counter Comparator values.
-
struct EPWM_AqActionCfg
- #include <epwm.h>
Structure holding the Action Qualifier actions to be taken on the PWM output at the specific events.
Public Members
-
uint32_t zeroAction
Action to be taken when counter equals zero. This can take values from the following enum EPWM_AqAction_t.
-
uint32_t prdAction
Action to be taken when the counter equals the period. This can take values from the following enum EPWM_AqAction_t.
-
uint32_t cmpAUpAction
Action to be taken when the counter equals the active CMPA register and the counter is incrementing. This can take values from the following enum EPWM_AqAction_t.
-
uint32_t cmpADownAction
Action to be taken when the counter equals the active CMPA register and the counter is decrementing. This can take values from the following enum EPWM_AqAction_t.
-
uint32_t cmpBUpAction
Action to be taken when the counter equals the active CMPB register and the counter is incrementing. This can take values from the following enum EPWM_AqAction_t.
-
uint32_t cmpBDownAction
Action to be taken when the time-base counter equals the active CMPB register and the counter is decrementing. This can take values from the following enum EPWM_AqAction_t.
-
uint32_t zeroAction
-
struct EPWM_DeadbandCfg
- #include <epwm.h>
Structure holding the dead band generation sub-module configuration parameters.
Public Members
-
uint32_t inputMode
Input mode control that selects the input source to the falling-edge and rising-edge delay. This can take values from the following enum EPWM_DbInMode_t.
-
uint32_t outputMode
Output mode control that selectively enable or bypass the dead-band generation for the falling-edge and rising-edge delay. This can take values from the following enum EPWM_DbOutMode_t.
-
uint32_t polaritySelect
Polarity selection control that allows selectively invert one of the delayed signals before it is sent out of the dead-band sub-module. This can take values from the following enum EPWM_DbPolSel_t.
-
uint32_t risingEdgeDelay
Rising edge delay count in cycles.
-
uint32_t fallingEdgeDelay
Falling edge delay count in cycles.
-
uint32_t inputMode
-
struct EPWM_ChopperCfg
- #include <epwm.h>
Structure holding the configuration parameters of Chopper sub-module.
Public Members
-
uint32_t dutyCycle
Chopping clock duty cycle. This can take values from the following enum EPWM_ChpDutyCycle_t.
-
uint32_t clkFrequency
Chopping clock frequency. This can take values from the following enum EPWM_ChpClkFreq_t.
-
uint32_t oneShotPulseWidth
One shot pulse width: pulse width of first pulse. This can take values from the following enum EPWM_ChpOshtWidth_t.
-
uint32_t dutyCycle
-
struct EPWM_TripzoneCfg
- #include <epwm.h>
Structure holding the trip-zone sub-module configuration parameters.
Public Members
-
uint32_t tripAction
Action to be taken on Output when trip condition occurs. This can take values from the following enum EPWM_TzTripAction_t.
-
uint32_t tripEvtType
Type of trip event One Shot or Cycle by cycle. This can take values from the following enum EPWM_TzEvent_t.
-
uint32_t tripPin
Trip Pin number on which trip condition has to be monitored.
-
uint32_t enableTripIntr
Enable Trip Zone Interrupt.
-
uint32_t tripAction
-
struct EPWM_EtCfg
- #include <epwm.h>
Structure holding the Event Trigger Sub-Module configuration parameters.
Public Members
-
uint32_t intrEvtSource
Event which is the source of the interrupt. This can take values from the following enum EPWM_EtIntrEvt_t.
-
uint32_t intrPrd
Interrupt period which determine how many selected events need to occur before an interrupt is generated. This can take values from the following enum EPWM_EtIntrPeriod_t.
-
uint32_t intrEvtSource