This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] TMS320F28379D: How can I generate an ePWM interrupt on both CMPA and CMPB events?

Part Number: TMS320F28379D

QUESTION: How can I generate an interrupt for both CMPA and CMPB events? There is no option to select both CMPA AND CMPB to generate an interrupt for my ePWM module, can this be done?

  • ANSWER:

    Yes. The most efficient way of doing this is using two ePWM modules, enabling the sync between the two, and linking the CMPx and TBPRD registers.

    This allows the two ePWM modules to generate IDENTICAL waveform. Next you can set up the interrupts for the first ePWM module to occur at CMPA and the interrupts for the second ePWM module to occur at CMPB.

    The example below showcases ePWM1 and ePWM2 accomplishing this.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    #define EPWM_TIMER_TBPRD 1000
    //
    // Function Prototypes
    //
    void initEPWM(uint32_t epwm_base);
    __interrupt void epwm1ISR(void);
    __interrupt void epwm2ISR(void);
    //
    // Main
    //
    void main(void)
    {
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Same thing can be done to generate an ePWM interrupt on both count UP and count DOWN of a CMPx. Minor changes to the code such as changing the TB mode to UP/DOWN and the interrupt source events must take place.

    The code above generates Identical waveform for ePWM1 and ePWM2. The TBPRD, CMPA and CMPB of the two modules are linked, therefor a write to CMPA of ePWM1 will also have the same effect on ePWM2.

    ePWM1 and ePWM2 Identical Outputs

    GPIO6 and GPIO7 Toggled in Interrupts