I am running lab 5b for the F2802x FOC chip. I have modified the system to include external on/off switch and a short circuit protection circuit. The short circuit protection circuit makes the GPIO pin 17 low for about 30 ms. Whenever this happens I want the motor to shut down so I added the following code to the 5b code:
// My variables
bool gOnOff;
bool gSckt
#define JED_GPIO_SW1 GPIO_Number_7 // External on off switch
#degine JED_GPIO_SW# GPIO_Number_17 // Short Circuit protection
for (;;)
{
//My Code
gOnOff = HAL_readGpio(halHandle, JED_GPIO_SW1); // On off switch
gSckt = HAL_readGpio(halHandle, JED_GPIO_SW3); // Short CIrcuit
if (gOnOff == true)
{
gMotorvars.Flag_Run_Identify = false;
gMotorvars.Flag_enableSys = false;
}
if (gOnOff == flase && gSckt == false)
{
HAL_disablePwm(halHandle);
gMotorvars.Flag_Run_Identify = false;
gMotorvars.Flag_enableSys = false;
}
if (gOnOff == false && gSckt == true)
{
gMotorvars.Flag_Run_Identify = true;
gMotorvars.Flag_enableSys = true;
}
// End of my code
In this code the on off part seems to be working fine, but the short circuit protection is not working. I suspect that the system gets disabled for the duration that the pin is low and comes back up as soon as the pin becomes high, which I don't want. How can I rectify this issue?