Other Parts Discussed in Thread: MOTORWARE
I am using InstaSpin motorware lab 5b to run my motor. In the board I have added an external switch connected to GPIO 7 which I want to use to turn on and off the motor. I followed the procedure given in the HAL tutorial document.
In hal.c I have
GPIO_setMode(obj->gpioHandle,GPIO_Number_7,GPIO_7_Mode_GeneralPurpose);
In hal.h I creaded this funciton
static inline bool HAL_readGpio(HAL_Handle handle, const GPIO_Number_e gpioNumber)
{
HAL_Obj *obj = (HAL_Obj*)handle;
return (GPIO_read(obj->gpioHandle, gpioNumber));
}//End of Read GPIO Pin function.
And in project_lab5b.c I added these lines:
bool gOnOff;
.
.
.
for(;;)
{
// enable or disable the system
gOnOff = HAL_readGpio(halHandle, GPIO_Number_7);
if (gOnOff==true)
{
gMotorVars.Flag_enableSys = true;
gMotorVars.Flag_Run_Identify = true;
}
else
{
gMotorVars.Flag_enableSys = false;
gMotorVars.Flag_Run_Identify = false;
}
.
.
.
I did not define the GPIO7 the way it was done in the pdf, because I felt that it was unnecessarily increasing the complexity. But when I started the debug session, the gOnOff is always zero. I added an LED on my switch to make sure that it is indeed working properly. So no problems on hardware side. The system simply does not read anything on the pin.
If I force the two flags to 1 from CCS debug window, the motor that was running before I added this code doesn't run with this new patch in. I have added a POT to control the speed which seems to be working properly, but with this patch of code in, nothing is happening.