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.

F29H85X-SOM-EVM: Queries related to Linked ePWM

Part Number: F29H85X-SOM-EVM
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi,

In F29x, there is common link region where the entire ePWM register has been maaped as opposed to C28x design. In C28x, Only TBPRD, CMPx and DBx ould be linked.

  • Since the entire ePWM registers are mapped to a common linked region, I wanted to know what parameters of ePWM can be linked?
  • Is there any example which showcases the linking behavior of ePWM for F29x?
  • Further in Sys config , how can I use linking feature to update ePWM for multiple modules all at once?

Thanks,

Mukul

  • Hi Mukul,

    This example will be in our next release of F29x SDK in August time frame.

    In F29x, there is a significant enhancement in the linking capabilities compared to C28x. Here are the key points:

    Since the entire ePWM registers are mapped to a common linked region, I wanted to know what parameters of ePWM can be linked?
    • All ePWM registers can be linked across modules in F29x
    • There is a dedicated XLINK region in the memory map that supports writes to any of the ePWM registers to reflect in other ePWM instances
    • The linking is controlled by configuring the SYSCTL's EPWMXLINKCFG bit 
    • When enabled, any writes to the XLINK region of an ePWM instance will reflect in all other ePWM instances that have the linking feature enabled 
    Is there any example which showcases the linking behavior of ePWM for F29x?

    Here is the early access example including SysConfig file that you can copy and paste the contents for the peripheral configurations.

    /**
     * Import the modules used in this configuration.
     */
    const cmpss  = scripting.addModule("/driverlib/cmpss.js", {}, false);
    const cmpss1 = cmpss.addInstance();
    const epwm   = scripting.addModule("/driverlib/epwm.js");
    const epwm1  = epwm.addInstance();
    const epwm2  = epwm.addInstance();
    const epwm3  = epwm.addInstance();
    const jtag   = scripting.addModule("/driverlib/jtag.js");
    
    /**
     * Write custom configuration values to the imported modules.
     */
    cmpss1.$name              = "myCMPSS1";
    cmpss1.dacValHigh         = 2500;
    cmpss1.enableModule       = true;
    cmpss1.periphClock.$name  = "driverlib_perClock0";
    cmpss1.periphConfig.$name = "driverlib_perConfig0";
    
    const analog  = scripting.addModule("/driverlib/analog.js", {}, false);
    const analog1 = analog.addInstance({}, false);
    analog1.$name = "myANALOGPinMux0";
    cmpss1.analog = analog1;
    
    epwm.generateInitFunctions = true;
    
    epwm1.epwmDeadband_polarityFED                                   = "EPWM_DB_POLARITY_ACTIVE_LOW";
    epwm1.epwmDeadband_enableFED                                     = true;
    epwm1.$name                                                      = "myEPWM1";
    epwm1.epwmTimebase_counterMode                                   = "EPWM_COUNTER_MODE_UP_DOWN";
    epwm1.epwmTimebase_syncOutPulseMode                              = ["EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO"];
    epwm1.epwmDeadband_enableRED                                     = true;
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA   = "EPWM_AQ_OUTPUT_HIGH";
    epwm1.epwmTimebase_hsClockDiv                                    = "EPWM_HSCLOCK_DIVIDER_1";
    epwm1.epwmTimebase_period                                        = 125;
    epwm1.epwmEventTrigger_enableInterrupt                           = true;
    epwm1.epwmEventTrigger_registerInterrupts                        = true;
    epwm1.epwmEventTrigger_interruptSource                           = "EPWM_INT_TBCTR_ZERO";
    epwm1.epwmEventTrigger_interruptEventCount                       = "1";
    epwm1.epwmCounterCompare_cmpAGld                                 = true;
    epwm1.epwmCounterCompare_cmpBGld                                 = true;
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_gld                   = true;
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_shadowMode            = true;
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_shadowMode            = true;
    epwm1.epwmDeadband_delayRED                                      = 20;
    epwm1.epwmDeadband_delayFED                                      = 20;
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_gld                   = true;
    epwm1.epwmCounterCompare_cmpB                                    = 69;
    epwm1.epwmCounterCompare_cmpA                                    = 69;
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB   = "EPWM_AQ_OUTPUT_HIGH";
    epwm1.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
    epwm1.epwmGlobalLoad_gld                                         = true;
    epwm1.epwmGlobalLoad_enableOneShot                               = true;
    epwm1.epwmGlobalLoad_oneShotMode                                 = true;
    epwm1.epwmTimebase_emulationMode                                 = "EPWM_EMULATION_FREE_RUN";
    epwm1.epwm.$assign                                               = "EPWM1";
    epwm1.periphClock.$name                                          = "driverlib_perClock1";
    epwm1.periphConfig.$name                                         = "driverlib_perConfig1";
    
    epwm2.epwmTimebase_hsClockDiv                                    = "EPWM_HSCLOCK_DIVIDER_1";
    epwm2.epwmTimebase_period                                        = 125;
    epwm2.epwmTimebase_counterMode                                   = "EPWM_COUNTER_MODE_UP_DOWN";
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA   = "EPWM_AQ_OUTPUT_HIGH";
    epwm2.epwmDeadband_polarityFED                                   = "EPWM_DB_POLARITY_ACTIVE_LOW";
    epwm2.epwmDeadband_enableRED                                     = true;
    epwm2.epwmDeadband_enableFED                                     = true;
    epwm2.$name                                                      = "myEPWM2";
    epwm2.epwmTimebase_phaseEnable                                   = true;
    epwm2.epwmTimebase_phaseShift                                    = 42;
    epwm2.epwmDigitalCompare_EPWM_DC_TYPE_DCAH                       = "EPWM_DC_TRIP_TRIPIN4";
    epwm2.epwmDigitalCompare_EPWM_TZ_DC_OUTPUT_A2                    = "EPWM_TZ_EVENT_DCXH_HIGH";
    epwm2.epwmTripZone_EPWM_TZ_ACTION_EVENT_TZA                      = "EPWM_TZ_ACTION_LOW";
    epwm2.epwmTripZone_EPWM_TZ_ACTION_EVENT_TZB                      = "EPWM_TZ_ACTION_LOW";
    epwm2.epwmCounterCompare_cmpAGld                                 = true;
    epwm2.epwmCounterCompare_cmpBGld                                 = true;
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_gld                   = true;
    epwm2.epwmTripZone_tzInterruptSource                             = ["EPWM_TZ_INTERRUPT_CBC"];
    epwm2.epwmTripZone_registerInterrupts                            = true;
    epwm2.epwmCounterCompare_cmpA                                    = 69;
    epwm2.epwmDeadband_delayRED                                      = 20;
    epwm2.epwmDeadband_delayFED                                      = 20;
    epwm2.epwmCounterCompare_cmpB                                    = 69;
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB   = "EPWM_AQ_OUTPUT_HIGH";
    epwm2.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
    epwm2.epwmTripZone_cbcSource                                     = ["EPWM_TZ_SIGNAL_DCAEVT2"];
    epwm2.epwmGlobalLoad_gld                                         = true;
    epwm2.epwmGlobalLoad_enableOneShot                               = true;
    epwm2.epwmGlobalLoad_oneShotMode                                 = true;
    epwm2.epwmTimebase_emulationMode                                 = "EPWM_EMULATION_FREE_RUN";
    epwm2.epwm.$assign                                               = "EPWM2";
    epwm2.periphClock.$name                                          = "driverlib_perClock2";
    epwm2.periphConfig.$name                                         = "driverlib_perConfig2";
    
    epwm3.epwmTimebase_hsClockDiv                                    = "EPWM_HSCLOCK_DIVIDER_1";
    epwm3.epwmTimebase_period                                        = 125;
    epwm3.epwmTimebase_counterMode                                   = "EPWM_COUNTER_MODE_UP_DOWN";
    epwm3.epwmTimebase_phaseEnable                                   = true;
    epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_UP_CMPA   = "EPWM_AQ_OUTPUT_HIGH";
    epwm3.epwmDeadband_polarityFED                                   = "EPWM_DB_POLARITY_ACTIVE_LOW";
    epwm3.epwmDeadband_enableRED                                     = true;
    epwm3.epwmDeadband_enableFED                                     = true;
    epwm3.$name                                                      = "myEPWM3";
    epwm3.epwmTimebase_phaseShift                                    = 83;
    epwm3.epwmTripZone_oneShotSource                                 = ["EPWM_TZ_SIGNAL_OSHT1"];
    epwm3.epwmTripZone_tzInterruptSource                             = ["EPWM_TZ_INTERRUPT_OST"];
    epwm3.epwmTripZone_registerInterrupts                            = true;
    epwm3.epwmTripZone_EPWM_TZ_ACTION_EVENT_TZA                      = "EPWM_TZ_ACTION_LOW";
    epwm3.epwmTripZone_EPWM_TZ_ACTION_EVENT_TZB                      = "EPWM_TZ_ACTION_LOW";
    epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_gld                   = true;
    epwm3.epwmCounterCompare_cmpA                                    = 69;
    epwm3.epwmDeadband_delayRED                                      = 20;
    epwm3.epwmDeadband_delayFED                                      = 20;
    epwm3.epwmCounterCompare_cmpB                                    = 69;
    epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_A_ON_TIMEBASE_DOWN_CMPA = "EPWM_AQ_OUTPUT_LOW";
    epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_UP_CMPB   = "EPWM_AQ_OUTPUT_HIGH";
    epwm3.epwmActionQualifier_EPWM_AQ_OUTPUT_B_ON_TIMEBASE_DOWN_CMPB = "EPWM_AQ_OUTPUT_LOW";
    epwm3.epwmGlobalLoad_gld                                         = true;
    epwm3.epwmGlobalLoad_enableOneShot                               = true;
    epwm3.epwmGlobalLoad_oneShotMode                                 = true;
    epwm3.epwmTimebase_emulationMode                                 = "EPWM_EMULATION_FREE_RUN";
    epwm3.periphClock.$name                                          = "driverlib_perClock3";
    epwm3.periphConfig.$name                                         = "driverlib_perConfig3";

    //###########################################################################
    //
    // FILE:   epwm_ex14_global_load.c
    //
    // TITLE:  Use Case Example Code for EPWM Developers Guide
    //
    //
    // This example contains the solution for the use case described in the
    // C2000 ePWM Developer's Guide (www.ti.com/lit/SPRAD12).
    //
    // The use case described in the application report is the following:
    //
    // Output frequency of 400 kHz for EPWM1/2/3
    // Phase shift of 120 degrees for EPWM2 with respect to EPWM1
    // Phase shift of 240 degrees for EPWM3 with respect to EPWM1
    // Duty cycle of 45% for EPWM1/2/3
    // Active high complementary signal pairs with 200 nsec of rising/falling edge delay for EPWM1/2/3
    // Cycle-by-Cycle trip zone protection through comparator signal on EPWM2
    // One-Shot trip protection through GPIO on EPWM3
    // Interrupt generation everytime the time base counter equals zero on EPWM1
    // Global loading to support asynchronous updates of action qualifier settings
    // Link CMPA/CMPB of EPWM1 to EPWM2 and EPWM3
    //
    //###########################################################################
    //
    //
    // $Copyright: $
    //###########################################################################
    
    //
    // Included Files
    //
    #include "board.h"
    
    //
    // Defines
    //
    
    
    //
    // Globals
    //
    uint16_t  perform_one_shot_load=0;
    
    //
    //  Function Prototypes
    //
    
    
    
    //
    // Main
    //
    int main(void)
    {
        //
        // Initialize device clock, peripheral clocks and interrupts
        //
        Device_init();
    
        //
        // Disable sync(Freeze clock to PWM as well)
        //
        SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    
        //
        // Configure GPIO pins and EPWM Modules
        //
        Board_init();
        SysCtl_enableEPWMXLINK(SYSCTL_EPWM1_XLINK);
        SysCtl_enableEPWMXLINK(SYSCTL_EPWM2_XLINK);
        SysCtl_enableEPWMXLINK(SYSCTL_EPWM3_XLINK);
    
        //
        // Enable sync and clock to PWM
        //
        SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
    
        //
        // Enable interrupts required for this example
        //
        Interrupt_enable(INT_EPWM1);
        Interrupt_enable(INT_EPWM2);
        Interrupt_enable(INT_EPWM3);
    
        //
        // Enable PIPE Global Interrupt (for INTs and RTINTs) and INT enable in CPU.
        //
        ENINT;
        Interrupt_enableGlobal();
    
        //
        // IDLE loop. Just sit and loop forever (optional):
        //
        for(;;)
        {
            if(perform_one_shot_load==1)
            {
                //
                // EPWM1, EPWM2, EPWM3 are linked so only EPWM1 needs to be updated
                //
                EPWM_setCounterCompareValue(EPWM1XLINK_BASE, EPWM_COUNTER_COMPARE_A, 100);
                EPWM_setCounterCompareValue(EPWM1XLINK_BASE, EPWM_COUNTER_COMPARE_B, 100);
    
                //
                // Change the Action Qualifier Settings for EPWM1, EPWM2, and EPWM3
                // using XLINKBASE
                EPWM_setActionQualifierAction(EPWM1XLINK_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_LOW,
                                                EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
                EPWM_setActionQualifierAction(EPWM1XLINK_BASE,EPWM_AQ_OUTPUT_A,EPWM_AQ_OUTPUT_HIGH,
                                                EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);
                // PWM outputs will not change until the global one shot latch is set
                // Using XLINKBASE will set the global one shot latch for ePWM1/2/3 (Similar to F28P65x or any devices with XLINK)
                ESTOP0;
                // EPWM1, EPWM2, EPWM3 are linked
                EPWM_setGlobalLoadOneShotLatch(EPWM1XLINK_BASE);
    
                // Clear the setting
                perform_one_shot_load = 0;
            }
        }
    }
    
    
    void INT_myEPWM1_ISR(void){
        //
        // Acknowledge this interrupt to receive more interrupts from group 2
        //
    }
    
    void INT_myEPWM2_TZ_ISR(void){
    
         //
         // Clear the flags
         //
         EPWM_clearTripZoneFlag(myEPWM2_BASE, (EPWM_TZ_INTERRUPT | EPWM_TZ_FLAG_CBC));
    
    
    }
    
    void INT_myEPWM3_TZ_ISR(void){
    
        //
        // Re-enable the OST Interrupt
        //
         EPWM_clearTripZoneFlag(myEPWM3_BASE, (EPWM_TZ_INTERRUPT | EPWM_TZ_FLAG_OST));
    }

    Further in Sys config , how can I use linking feature to update ePWM for multiple modules all at once?

    Sysconfig doesn't have this feature.However it's simply one call to set up. Then run time driverlib api's that can be called to write to XLINK Base regions.

    Best regards,

    Ryan Ma