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.

TMS320F28027: The PWM pin EPWM2B / GPIO3 automatically changes to High

Part Number: TMS320F28027
Other Parts Discussed in Thread: SYSCONFIG, C2000WARE

Hi Team,

After debugging with XDS100V3, the customer finds that a PWM pin (EPWM2B / GPIO3) goes directly high when it do not run, causing hardware corruption. When the program is run, the state returns to normal. It will occur every time and is reproducible and the difference is after using the XDS100V3 burn, the wait time varies, approximately 15s to 30s. 

Please see below for the code of the initialization:

 void devPWM_HVCtrl_Init(CLK_Handle myClk, PWM_Handle myPwm2)
{

    CLK_enablePwmClock(myClk, PWM_Number_2);

    // Set timer period
    PWM_setPeriod(myPwm2, HVCTRL_PWM_COUNT);
    PWM_setPhase(myPwm2, 0x0000);   // Phase is 0
    PWM_setCount(myPwm2, 0x0000);   // Clear counter

    // Setup TBCLK
    PWM_setCounterMode(myPwm2, PWM_CounterMode_Up);
    PWM_disableCounterLoad(myPwm2);                     // Disable phase loading
    PWM_setHighSpeedClkDiv(myPwm2, PWM_HspClkDiv_by_1); // Clock ratio to SYSCLKOUT
    PWM_setClkDiv(myPwm2, PWM_ClkDiv_by_1);

    PWM_setShadowMode_CmpA(myPwm2, PWM_ShadowMode_Shadow);  // Load registers every ZERO
    PWM_setShadowMode_CmpB(myPwm2, PWM_ShadowMode_Shadow);
    PWM_setLoadMode_CmpA(myPwm2, PWM_LoadMode_Zero);
    PWM_setLoadMode_CmpB(myPwm2, PWM_LoadMode_Zero);

    // Setup compare
    PWM_setCmpA(myPwm2, 0);
    PWM_setCmpB(myPwm2, HVCTRL_PWM_COUNT);

    // Set actions
    PWM_setActionQual_CntUp_CmpA_PwmA(myPwm2, PWM_ActionQual_Set);
    PWM_setActionQual_CntUp_CmpB_PwmA(myPwm2, PWM_ActionQual_Clear);

    PWM_setActionQual_CntUp_CmpA_PwmB(myPwm2, PWM_ActionQual_Clear);
    PWM_setActionQual_CntUp_CmpB_PwmB(myPwm2, PWM_ActionQual_Set);


    // Active Low PWMs - Setup Deadband
    devPWM_DeadbandEnable(myPwm2, true);

}

void devPWM_DeadbandEnable(PWM_Handle myPwm1, bool bEn)
{
    if(bEn)
    {

        EALLOW;

        EPwm2Regs.TZFLG.bit.CBC = 0;
        EPwm2Regs.TZFLG.bit.OST = 0;

        EPwm2Regs.TZCTL.bit.DCBEVT1 = 2;
        EPwm2Regs.TZCTL.bit.DCBEVT2 = 2;
        EPwm2Regs.TZCTL.bit.TZB = 2;

        EPwm2Regs.TZFRC.bit.DCBEVT1 = 1;
        EPwm2Regs.TZFRC.bit.DCBEVT2 = 1;
        EPwm2Regs.TZFRC.bit.CBC = 1;


        EDIS;


        // Active Low PWMs - Setup Deadband
        PWM_setDeadBandOutputMode(myPwm1,            PWM_DeadBandOutputMode_EPWMxA_Rising_EPWMxB_Falling);
        PWM_setDeadBandPolarity(myPwm1, PWM_DeadBandPolarity_EPWMxB_Inverted);

        PWM_setDeadBandInputMode(myPwm1, PWM_DeadBandInputMode_EPWMxA_Rising_and_Falling);
        PWM_setDeadBandRisingEdgeDelay(myPwm1, EPWM1_MIN_DB);
        PWM_setDeadBandFallingEdgeDelay(myPwm1, EPWM1_MIN_DB);
    }
    else
    {
        PWM_disableDeadBand(myPwm1);
    }

//================================================================================//

The customer also attempted to select the following settings in CCS but still did not improve: (RealTime options) 

Could you please help check this case? Thanks.

Best Regards,

Cherry

  • Hi Cherry,

    What does their device initialization look like? Also their GPIO configurations? Are they using SysConfig to help develop their init code? Have they checked to see the status of the GPIO Pin to make sure there is no initial value set to that GPIO?

    Best,

    Ma

  • Hi Ma,

    Thank you for the suppport.

    What does their device initialization look like?

    Could you help specify which part of the initialization?

    Also their GPIO configurations?

    The software changes itself when it is not running. The customer is wondering would it be possible to do with the initial setting?

    Thanks and regards,

    Cherry

  • Hi Cherry,

    There is usually a function called Device_init() in the main C code. Are they using this function provided? I would like to see their GPIO initialization to make sure they are not setting a gpio signal high. 

        CLK_enablePwmClock(myClk, PWM_Number_2);

    This function call seems to enable the PWM clock, does this modify the TBCLKSYNC bit? If so, this should be called AFTER initialization of theirPWM.

    Best,

    Ma

  • Hi Ma,

    There is usually a function called Device_init() in the main C code. Are they using this function provided?

    No, they don't use Device_init() in their initialization.

    I would like to see their GPIO initialization to make sure they are not setting a gpio signal high. 

    If the GPIO you refer to is the GPIO initialization for the PWM, please see below:

        GPIO_setMode(myGpio, GPIO_Number_2, GPIO_2_Mode_EPWM2A);
        GPIO_setMode(myGpio, GPIO_Number_3, GPIO_3_Mode_EPWM2B);

    This function call seems to enable the PWM clock, does this modify the TBCLKSYNC bit? If so, this should be called AFTER initialization of theirPWM.

    Yes, TBCLKSYNC is modified. Dose the "irPWM" refer to PWM?

    Thanks and regards,

    Cherry

  • Hi Cherry,

    Their PWM initialization seems to be fine. I suspect it's something else that is causing an issue for their PWM output to get set high.

    This is an example of gpio initialization for ePWM2A/B could they try this?

    //
    // EPWM2_A - GPIO Settings
    //
    #define GPIO_PIN_EPWM2_A 2
    #define myEPWM2_EPWMA_GPIO 2
    #define myEPWM2_EPWMA_PIN_CONFIG GPIO_2_EPWM2_A
    //
    // EPWM2 -> myEPWM2 Pinmux
    //
    GPIO_setPinConfig(myEPWM2_EPWMA_PIN_CONFIG);
    GPIO_setPadConfig(myEPWM2_EPWMA_GPIO, GPIO_PIN_TYPE_STD);
    GPIO_setQualificationMode(myEPWM2_EPWMA_GPIO, GPIO_QUAL_SYNC);
    
    GPIO_setPinConfig(myEPWM2_EPWMB_PIN_CONFIG);
    GPIO_setPadConfig(myEPWM2_EPWMB_GPIO, GPIO_PIN_TYPE_STD);
    GPIO_setQualificationMode(myEPWM2_EPWMB_GPIO, GPIO_QUAL_SYNC);

    goes directly high when it do not run

    When it is not running, does that mean the application is halted with either software/hardware breakpoint? If you halt the program when TBCLK is running for the ePWM, the PWM output will be stuck at some state since TBCTR is no longer incrementing. Depending on what is set in the emulation mode bit for TBCTL[FREE_SOFT]. By default it will stop the TBCTR after the next time base counter increment or decrement.

    For safe initializations, it's important to follow our C2000WARE examples, where we 

    1. Set up device initializations and gpio initializations

    2. Initialize any interrupts

    3. Configure ePWMs / other peripherals (making sure the clk to ePWM is disabled before configuring the settings)

    4. Enable TBCLKSYNC

    5. rest of control loop

    Best,

    Ma

  • Hi Ma,

    When it is not running, does that mean the application is halted with either software/hardware breakpoint?

    No, it's halted suddenly and without any actions after press "Debug".

    Would this be an issue with XDS100V3?

    Thanks and regards,

    Cherry

  • Hi Cherry,

    Before we look at possibility of the issue with XDS, could you have them run a C2000WARE PWM example first to see if they see the same behavior like ex13 or ex2? 

    Best,

    Ma