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.

TMS320F28379D: ePWM/GPIO problem

Part Number: TMS320F28379D


I am trying to develop functions to shut on and off ePWM.

ePWM settings are done in different functions and it is working perfectly when the ePWM is running.

I have written the following functions to manipulate the pins running the ePWM.

To turn on ePWM.

void start_pwm_gpio(void)
{

    InitEPwm1Gpio();
    InitEPwm2Gpio();
    InitEPwm5Gpio();


}

To turn off all ePWM pins

void stop_pwm_gpio(void)
{

    EALLOW;

    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;
    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
    GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;

    GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;
    GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;
    GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;

    GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0;
    GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO8 = 1;
    GpioCtrlRegs.GPADIR.bit.GPIO9 = 1;

    EDIS;

    GpioDataRegs.GPADAT.bit.GPIO0 = 0;
    GpioDataRegs.GPADAT.bit.GPIO1 = 0;

    GpioDataRegs.GPADAT.bit.GPIO2 = 0;
    GpioDataRegs.GPADAT.bit.GPIO3 = 0;

    GpioDataRegs.GPADAT.bit.GPIO8 = 0;
    GpioDataRegs.GPADAT.bit.GPIO9 = 0;

}

To turn off lower IGBTs

void stop_lower_gpio(void)
{

    InitEPwm1Gpio();
    InitEPwm2Gpio();
    InitEPwm5Gpio();



    EALLOW;

    GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;

    GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;

    GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO9 = 1;

    EDIS;

    GpioDataRegs.GPADAT.bit.GPIO1 = 0;

    GpioDataRegs.GPADAT.bit.GPIO3 = 0;

    GpioDataRegs.GPADAT.bit.GPIO9 = 0;


}

To turn off upper IGBTs

void stop_upper_gpio(void)
{

    InitEPwm1Gpio();
    InitEPwm2Gpio();
    InitEPwm5Gpio();


    EALLOW;

    GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;

    GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;

    GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0;

    GpioCtrlRegs.GPADIR.bit.GPIO8 = 1;

    EDIS;

    GpioDataRegs.GPADAT.bit.GPIO0 = 0;

    GpioDataRegs.GPADAT.bit.GPIO2 = 0;

    GpioDataRegs.GPADAT.bit.GPIO8 = 0;

}

I run these functions during runtime from commands through UART using putty.

Surprisingly when I try to make upper IGBTs off (GPIO0, GPIO2, GPIO8), instead of 'OFF' they turn 'ON' 'sometimes'. IN such a scenario when the lower ePWM is ON, at one instant both the ePWMxA and ePWMxB are ON leading to short circuit. After this commands if I attempt to turn off the entire PWM, I see ePWM tied to upper IGBT 'ON' and that tied to lower IGBT 'OFF'.

This is a bug. It does not happen always, it happens sometimes and persists being the same on turning OFF of the ePWM.

Is this the correct approach to shut off the ePWM through GPIO. One can also do that through AQCTLA settings. I am using GPIO just to make it a hard 'OFF'.

Below is a snip looking from the register contents. When the command is being sen to stop the ePWM and turn off GPIO0, 1, 2, 3, 8, 9 still GPIO2 is on.

My application has pull down resistors, I tried the same code on the 180 pin HSEC docking station as well as my application and same problem persists. Not only GPIO2 but also all other GPIOs connected to the ePWM abruptly turn 'ON' when commanded to turn 'OFF'.

  • Hi Soham,

    The best way to do this would be the tripzone function built into the ePWM. You could actually set all of these up to trip simultaneously which would seemingly have some inherent benefit in both CPU cycles and system performance.

    There is nothing wrong with changing the GPIO mux though if you choose to go that route. However, remember that the potential for the mux to get switched back is inherently there, and if it does, your PWM is still running and will become active on the pin. The other advantage to the tripzone is you can control how and when the PWM restarts (start of cycle).

    If you choose to stay the GPIO mux route, your issue is likely with the R-M-W operations of the ".bit" access to the GPxDAT registers. Take a look at 6.1.2 GPxDAT Registers in the following document:

    www.ti.com/lit/an/spraa85e/spraa85e.pdf

    I would also recommend doing the writes BEFORE switching the mux as they will take effect upon the switch. You current method risks a glitch on the IO if the DAT register currently contains a '1'.

    Regards,
    Kris