SPRAD12A July   2022  – February 2023 TMS320F280021 , TMS320F280021-Q1 , TMS320F280023 , TMS320F280023-Q1 , TMS320F280023C , TMS320F280025 , TMS320F280025-Q1 , TMS320F280025C , TMS320F280025C-Q1 , TMS320F280033 , TMS320F280034 , TMS320F280034-Q1 , TMS320F280036-Q1 , TMS320F280036C-Q1 , TMS320F280037 , TMS320F280037-Q1 , TMS320F280037C , TMS320F280037C-Q1 , TMS320F280038-Q1 , TMS320F280038C-Q1 , TMS320F280039 , TMS320F280039-Q1 , TMS320F280039C , TMS320F280039C-Q1 , TMS320F280040-Q1 , TMS320F280040C-Q1 , TMS320F280041 , TMS320F280041-Q1 , TMS320F280041C , TMS320F280041C-Q1 , TMS320F280045 , TMS320F280048-Q1 , TMS320F280048C-Q1 , TMS320F280049 , TMS320F280049-Q1 , TMS320F280049C , TMS320F280049C-Q1 , TMS320F28075 , TMS320F28075-Q1 , TMS320F28076 , TMS320F28374D , TMS320F28374S , TMS320F28375D , TMS320F28375S , TMS320F28375S-Q1 , TMS320F28376D , TMS320F28376S , TMS320F28377D , TMS320F28377D-EP , TMS320F28377D-Q1 , TMS320F28377S , TMS320F28377S-Q1 , TMS320F28378D , TMS320F28378S , TMS320F28379D , TMS320F28379D-Q1 , TMS320F28379S , TMS320F28384D , TMS320F28384D-Q1 , TMS320F28384S , TMS320F28384S-Q1 , TMS320F28386D , TMS320F28386D-Q1 , TMS320F28386S , TMS320F28386S-Q1 , TMS320F28388D , TMS320F28388S , TMS320F28P550SJ , TMS320F28P559SJ-Q1 , TMS320F28P650DH , TMS320F28P650DK , TMS320F28P650SH , TMS320F28P650SK , TMS320F28P659DK-Q1

 

  1.   Abstract
  2.   Trademarks
  3. Introduction
  4. SysConfig
  5. Time-Base (TB) Submodule
    1. 3.1 Setting the Frequency
    2. 3.2 Applying a Phase Shift
    3. 3.3 Setting up the Synchronization (Sync) Scheme
  6. Counter-Compare (CC) and Action-Qualifier (AQ) Submodules
    1. 4.1 Calculating the Duty Cycle
  7. Deadband (DB) Submodule
    1. 5.1 Setting up Signal Pairs
  8. Verifying the Output
    1. 6.1 Checking the Duty Cycle and Dead-Time Insertion
    2. 6.2 Checking the Phase Shift Applied
  9. Trip-Zone (TZ) and Digital Compare (DC) Submodules
    1. 7.1 Drive Outputs Low for an ePWM Cycle Upon Trip Condition Set Through CMPSS
    2. 7.2 Drive Outputs Low Until Cleared Through Software Upon Trip Condition set Through GPIO
  10. Event-Trigger (ET) Submodule
    1. 8.1 Setting Up Time-Base Interrupts
  11. Global Load
    1. 9.1 Applying Global Loading and One-Shot Load Feature
    2. 9.2 Linking the ePWM Modules
    3. 9.3 Updating Action Qualifier Settings and Counter Compare Values Through Global Loading
  12. 10Summary
  13. 11References
  14. 12Revision History

Drive Outputs Low for an ePWM Cycle Upon Trip Condition Set Through CMPSS

A cycle-by-cycle (CBC) trip is used for current limiting operations. When a cycle-by-cycle trip is detected, the trip-zone submodule drives EPWMxA and EPWMxB to a certain specified state. The outputs go back to their pre-trip state at the next ZRO, PRD, or ZRO/PRD events.

A comparator from the comparator subsystem (CMPSS) is set up to cause a trip event that then generates a CBC trip on EPWM2.

The CMPSS consists of analog comparators and supporting circuits that are useful for power applications. The comparators have a positive and negative input. A high digital output is generated when the voltage on the positive input is greater than the voltage on the negative input, and a low digital output when the voltage on the positive input is less than the voltage on the negative input.

GUID-F192F605-5935-4DFC-8E53-FEDDCC70C476-low.gifFigure 7-1 Comparator Block Diagram

In order to cause a high digital output, a trip condition needs to occur when the positive input (voltage A) is greater than the negative input (voltage B). Therefore, the positive input is connected to an external voltage source that you need to monitor to make sure it does not exceed a certain state. The negative input can come from the reference digital-to-analog converter (DAC) on the device. For this application, a value of 2500 is written to DACVALA, the value driven to the negative terminal.

The ideal output of the reference 12-bit DAC can be calculated as:

Equation 22. DACOUT=DACVALA*DACREF4096

Applying the known values, you get a DACOUT value of 2 V. Therefore, whenever the voltage applied to the positive input of the comparator exceeds 2 V, the trip signal is asserted.

Equation 23. DACOUT=2500*3.34096=2.01 V

Comparator 1 is utilized for this use-case. #FIG_OGT_FDV_4TB displays the setup for the CMPSS1 module based on the above calculation.

Note: Comparator pins are typically shared with other analog functionality. To determine the analog pin for the positive input of Comparator 1, see the Analog Subsystem section within the device-specific TRM. As an example on the F2838x device, CMPIN1P is shared with ADCINA2, so the voltage would be applied to the A2 pin of the device.
Figure 7-2 Comparator Pins
Figure 7-3 CMPSS Configuration

The following code is generated from SysConfig for the CMPSS configuration:

void CMPSS_init(){
// myCMPSS1 initialization
// Sets the configuration for the high comparator. 
CMPSS_configHighComparator(myCMPSS1_BASE,(CMPSS_INSRC_DAC));
// Sets the configuration for the high comparator. 
CMPSS_configLowComparator(myCMPSS1_BASE,(CMPSS_INSRC_DAC));
// Sets the configuration for the internal comparator DACs. 
CMPSS_configDAC(myCMPSS1_BASE,(CMPSS_DACVAL_SYSCLK | CMPSS_DACREF_VDDA | CMPSS_DACSRC_SHDW));
// Sets the value of the internal DAC of the high comparator. 
CMPSS_setDACValueHigh(myCMPSS1_BASE,2500U);
// Sets the value of the internal DAC of the low comparator. 
CMPSS_setDACValueLow(myCMPSS1_BASE,0U);
// Configures the digital filter of the high comparator. 
CMPSS_configFilterHigh(myCMPSS1_BASE, 0U, 1U, 1U);
// Configures the digital filter of the low comparator. 
CMPSS_configFilterLow(myCMPSS1_BASE, 0U, 1U, 1U);
// Sets the output signal configuration for the high comparator. 
CMPSS_configOutputsHigh(myCMPSS1_BASE,(CMPSS_TRIPOUT_ASYNC_COMP | CMPSS_TRIP_ASYNC_COMP));
// Sets the output signal configuration for the low comparator. 
CMPSS_configOutputsLow(myCMPSS1_BASE,(CMPSS_TRIPOUT_ASYNC_COMP | CMPSS_TRIP_ASYNC_COMP));
// Sets the comparator hysteresis settings. 
CMPSS_setHysteresis(myCMPSS1_BASE,0U);
// Configures the comparator subsystem's ramp generator. 
CMPSS_configRamp(myCMPSS1_BASE,0U,0U,0U,1U,true);
// Disables reset of HIGH comparator digital filter output latch on PWMSYNC 
CMPSS_disableLatchResetOnPWMSYNCHigh(myCMPSS1_BASE);
// Disables reset of LOW comparator digital filter output latch on PWMSYNC 
CMPSS_disableLatchResetOnPWMSYNCLow(myCMPSS1_BASE);
// Sets the ePWM module blanking signal that holds trip in reset. 
CMPSS_configBlanking(myCMPSS1_BASE,1U);
// Disables an ePWM blanking signal from holding trip in reset. 
CMPSS_disableBlanking(myCMPSS1_BASE);
// Configures whether or not the digital filter latches are reset by PWMSYNC 
CMPSS_configLatchOnPWMSYNC(myCMPSS1_BASE,false,false);
// Enables the CMPSS module. 
CMPSS_enableModule(myCMPSS1_BASE);
// Delay for CMPSS DAC to power up. 
DEVICE_DELAY_US(500);
}

It is important to note that the external signal applied to the positive input of the comparator needs to remain for a minimum of 3*TBCLK for the signal to be properly detected and cause a trip condition.

There is no direct path from the comparator subsystem to the trip zone submodule of the ePWM submodule, therefore the digital compare submodule must be utilized to route the signal. In order to figure out how to properly route the CMPSS signal through the digital compare submodule, you must first start with the ePWM X-BAR. The TRM of each device has a table that describes the mux positioning of the ePWM X-BAR, known as “ePWM X-BAR Mux Configuration Table”. #GUID-03FCFA41-747E-4F6E-8306-A10ABC3D5ADE shows an example of an ePWM X-BAR configuration table. From #GUID-51A414E5-D471-411A-8B38-5C013FDD598C, you can see that `CMPSS1.CTRIPH` is in position 0 of Mux 0. From the Input X-BAR configuration, you can route this to any trip signal between 4 and 12; for this application, Trip 4 is chosen.

Figure 7-4 Partial Example of an EPWM X-BAR Mux Configuration Table
Figure 7-5 Input X-BAR Block Diagram

#FIG_S14_13V_4TB shows how to configure the ‘EPWMXBAR’ within the system options of SysConfig.

Figure 7-6 SysConfig Configuration for EPWMXBAR

The following code is generated from SysConfig:

void EPWMXBAR_init(){
//myEPWMXBAR4 initialization 
XBAR_setEPWMMuxConfig(XBAR_TRIP4, XBAR_EPWM_MUX00_CMPSS1_CTRIPH); 
XBAR_enableEPWMMux(XBAR_TRIP4, XBAR_MUX00);
}

The DC submodule can generate up to four events DCAEVT1, DCAEVT2, DCBEVT1, and DCBEVT2. Only event 2 can cause a cycle-by-cycle trip, so you need to focus on DCAEVT2 for this application use-case. The digital compare event has a high (DCAH) and low (DCAL) signal. These two signals can be used to cause DCAEVT2. For this case, route the CMPSS1 output to either of the two signals since you only need one. DCAH was chosen. The condition in which the event is generated is when this signal goes high, meaning the value applied to the comparator’s positive input is above the voltage at the negative input.

Figure 7-7 ePWM Digital Compare: Setting up DCAEVT2

The following code is generated from SysConfig:

EPWM_selectDigitalCompareTripInput(myEPWM2_BASE, EPWM_DC_TRIP_TRIPIN4, EPWM_DC_TYPE_DCAH); 
EPWM_setTripZoneDigitalCompareEventCondition(myEPWM2_BASE, EPWM_TZ_DC_OUTPUT_A2, EPWM_TZ_EVENT_DCXH_HIGH);

You can now set up the trip-zone settings to drive both A and B outputs to a low state through a cycle by cycle trip whenever there is a DCAEVT2 event. An interrupt is also generated whenever the trip occurs to allow you to clear the flags.

Figure 7-8 ePWM Trip-Zone: Configuration for CBC Trip Based on DCAEVT2

The following code is generated from SysConfig:

EPWM_setTripZoneAction(myEPWM2_BASE, EPWM_TZ_ACTION_EVENT_TZA, EPWM_TZ_ACTION_LOW); 
EPWM_setTripZoneAction(myEPWM2_BASE, EPWM_TZ_ACTION_EVENT_TZB, EPWM_TZ_ACTION_LOW); 
EPWM_enableTripZoneSignals(myEPWM2_BASE, EPWM_TZ_SIGNAL_DCBEVT2); 
Note: To find the correct interrupt group, see the PIE Channel Mapping table within the device-specific TRM.
void epwm2TZISR(void){
    epwm2TZIntCount++;

    // Clear the flags
    EPWM_clearTripZoneFlag(myEPWM2_BASE, (EPWM_TZ_INTERRUPT | EPWM_TZ_FLAG_CBC));

    // Acknowledge this interrupt to receive more interrupts from group 2
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP2);
}

After configuring EPWM2 to have a trip condition when a positive voltage of greater than 2 V is applied to the positive input on comparator 1, EPWM2 should be driven low.