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.

TMS320F28377S: EPWM not synchronising

Part Number: TMS320F28377S
Other Parts Discussed in Thread: CONTROLSUITE

I want to synchronise my EPWM1 to EPWM10, that is with 0 phase delay between each module. I have implemented the dead band output with complimentary A and B signal, but i am not able to synchronise output of individual module. I referred to the datasheet flow chart for synchoronisation , and understood thar the modules are arranged in groups of three, and i can configure SYNCOUTPUT of each module etc. I am attaching my code here , where am i doing wrong.

// Included Files
//
#include "driverlib.h"
#include "device.h"
#define base10 EPWM10_BASE
#define base2 EPWM2_BASE
#define base6 EPWM6_BASE
#define delay 0X080U
#define time_base 0X1388 //EQUIVALENT TO 5000U
//
// Main
//
void initgpio(void);
void initEPWM1(void);
void initEPWM2(void);
void initEPWM3(void);
void initEPWMgen(uint32_t,uint32_t);
__interrupt void epwm1ISR(void);
__interrupt void epwm2ISR(void);
__interrupt void epwm3ISR(void);
int i=2000;
int set=0;

_Bool enable=1;
void main(void)
{
    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pull ups.
    //
    Device_initGPIO();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();
   // Interrupt_register(INT_EPWM1, &epwm1ISR);
     Interrupt_register(INT_EPWM10, &epwm2ISR);
    // Interrupt_register(INT_EPWM3, &epwm3ISR);
initgpio();

SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

//initEPWM1();

//initEPWM2();

//initEPWM3();


initEPWMgen(EPWM1_BASE,1);
initEPWMgen(EPWM2_BASE,0);
initEPWMgen(EPWM3_BASE,0);
initEPWMgen(EPWM4_BASE,1);
initEPWMgen(EPWM5_BASE,0);
initEPWMgen(EPWM6_BASE,0);
initEPWMgen(EPWM7_BASE,1);
initEPWMgen(EPWM8_BASE,0);
initEPWMgen(EPWM9_BASE,0);
initEPWMgen(EPWM10_BASE,1);
//synchronisation
EPWM_setSyncOutPulseMode(EPWM1_BASE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO);
EPWM_setSyncOutPulseMode(EPWM2_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
EPWM_setSyncOutPulseMode(EPWM3_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
EPWM_setSyncOutPulseMode(EPWM4_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
EPWM_setSyncOutPulseMode(EPWM5_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
EPWM_setSyncOutPulseMode(EPWM6_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
EPWM_setSyncOutPulseMode(EPWM7_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
EPWM_setSyncOutPulseMode(EPWM8_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
EPWM_setSyncOutPulseMode(EPWM9_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
EPWM_setSyncOutPulseMode(EPWM10_BASE, EPWM_SYNC_OUT_PULSE_ON_EPWMxSYNCIN);
SysCtl_setSyncInputConfig(SYSCTL_SYNC_IN_EPWM4, SYSCTL_SYNC_IN_SRC_EPWM1SYNCOUT);
SysCtl_setSyncInputConfig(SYSCTL_SYNC_IN_EPWM7, SYSCTL_SYNC_IN_SRC_EPWM4SYNCOUT);
SysCtl_setSyncInputConfig(SYSCTL_SYNC_IN_EPWM10, SYSCTL_SYNC_IN_SRC_EPWM7SYNCOUT);

//
// Enable sync and clock to PWM
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);

//Interrupt_enable(INT_EPWM1);
Interrupt_enable(INT_EPWM10);
//Interrupt_enable(INT_EPWM3);

EINT;
ERTM;
    for(;;)
    {
while(set==0);

set=0;
    }
}
void initgpio(void)
{
    GPIO_setPadConfig(18, GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_18_EPWM10A);
    GPIO_setPadConfig(19, GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_19_EPWM10B);
    GPIO_setPadConfig(2, GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_2_EPWM2A);
    GPIO_setPadConfig(3, GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_3_EPWM2B);
    GPIO_setPadConfig(10, GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_10_EPWM6A);
    GPIO_setPadConfig(11, GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_11_EPWM6B);

}
void initEPWMgen(uint32_t q, uint32_t sync)
{

    EPWM_setCountModeAfterSync(q, EPWM_COUNT_MODE_UP_AFTER_SYNC);


        //
        // Set-up TBCLK
        //
        EPWM_setTimeBasePeriod(q, time_base);
        //phase shift not needed
        EPWM_setPhaseShift(q, 0U);
        EPWM_enablePhaseShiftLoad(q);
        EPWM_setTimeBaseCounter(q, 0U);

        //
        // Set Compare values
        //
        EPWM_setCounterCompareValue(q,
                                    EPWM_COUNTER_COMPARE_A,
                                    i);


        //
        // Set up counter mode
        //
        EPWM_setTimeBaseCounterMode(q, EPWM_COUNTER_MODE_UP_DOWN);
        EPWM_disablePhaseShiftLoad(q);
        EPWM_setClockPrescaler(q,
                               EPWM_CLOCK_DIVIDER_1,
                               EPWM_HSCLOCK_DIVIDER_1);

        //
        // Set up shadowing
        //
        EPWM_setCounterCompareShadowLoadMode(q,
                                             EPWM_COUNTER_COMPARE_A,
                                             EPWM_COMP_LOAD_ON_CNTR_ZERO);

        //
        // Set actions
        // Note : EPWM_B is not set as its the complimentary of A
        EPWM_setActionQualifierAction(q,
                                      EPWM_AQ_OUTPUT_A,
                                      EPWM_AQ_OUTPUT_HIGH,
                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_UP_CMPA);
        EPWM_setActionQualifierAction(q,
                                      EPWM_AQ_OUTPUT_A,
                                      EPWM_AQ_OUTPUT_LOW,
                                      EPWM_AQ_OUTPUT_ON_TIMEBASE_DOWN_CMPA);

    EPWM_setDeadBandOutputSwapMode(q, EPWM_DB_OUTPUT_A, false);
    EPWM_setDeadBandOutputSwapMode(q, EPWM_DB_OUTPUT_B, false);
    //We don't have to swap
    EPWM_setDeadBandDelayMode(q, EPWM_DB_RED, true);
    EPWM_setDeadBandDelayMode(q, EPWM_DB_FED, true);
    //Configuration set for inverter leg
    EPWM_setDeadBandDelayPolarity(q, EPWM_DB_RED, EPWM_DB_POLARITY_ACTIVE_HIGH);
    EPWM_setDeadBandDelayPolarity(q, EPWM_DB_FED, EPWM_DB_POLARITY_ACTIVE_LOW);

    EPWM_setRisingEdgeDeadBandDelayInput(q, EPWM_DB_INPUT_EPWMA);
    EPWM_setFallingEdgeDeadBandDelayInput(q, EPWM_DB_INPUT_EPWMA);
    //I think these will work only if we are changing db during run time
    EPWM_setDeadBandControlShadowLoadMode(q, EPWM_DB_LOAD_FREEZE);
    EPWM_disableDeadBandControlShadowLoadMode(q);


    //self explanatory
    EPWM_setDeadBandCounterClock(q, EPWM_DB_COUNTER_CLOCK_FULL_CYCLE);
    EPWM_setRisingEdgeDelayCount(q, delay);
    EPWM_setFallingEdgeDelayCount(q, delay);
}

__interrupt void epwm2ISR(void)
{
    //
    // Update the CMPA and CMPB values
    //

    // EPWM_setSyncOutPulseMode(base2, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO);


    //
    // Clear INT flag for this timer
    //
    EPWM_clearEventTriggerInterruptFlag(base10);

    //
    // Acknowledge interrupt group
    //
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP3);
}

//
// End of File
//





  • Hi Ranjith,

    My suggestions for debugging would be:
    1) Look at the values of the EPWM registers using the Registers window during a debug session in CCS. Understand the significance of these registers/bits by using the EPWM chapter in the Technical Reference Manual. Check if there are any registers that aren't configured as you expected by the code.

    2) Look at this example, it uses bit-field code unlike your code in Driverlib, but it can be a good reference for the steps involved:
    C:\ti\controlSUITE\libs\app_libs\digital_power\f28x7x_v1.0\CNF\PWM_1ch_Cnf.c

    Regards,
    Elizabeth
  • Hi Ranjith,

    It looks like you are going from EPWM1 to EPWM7 to EPWM10 for your sync pulse. Is that intentional? You should use the shortest path possible and go straight from EPWM1 to EPWM10 if you can.

    What are you seeing on the waveforms? Note that there is a known 2 cycle delay in the sync chain. It may be extended due to the EPWM7 step your code is using. To compensate for the expected delay load the TBPHS register with a 2.

    Regards,

    Kris

  • Hi Ranjith,

    I haven't heard from you in a few weeks, so I'm writing to see if this is now resolved. If you don't have any more questions, you can press the "This resolved my issue" button on the relevant replies. If you do, please let us know by responding with the details.

    Regards,
    Elizabeth