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'.