Part Number: TMS320F28379D
Tool/software: Code Composer Studio
Hello,
I have configured a GPIO as an input and have connected it to hall sensor of a BLDC, I want to read the state of the GPIO in my code and have some if...else... condition on it. My code is only reading the GPIO once and although it is in a loop, it only reads the state at the start of the code and not anymore. I appreciate the help.
#define Hall_a GpioDataRegs.GPADAT.bit.GPIO6
int Hall_a_result =0;
void Hall_Sensor(void);
void main(void)
{ .....
.....
Hall_Sensor();
while(1);
}
void Hall_Sensor(void)
{
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO6 = 0;
GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0;
EDIS;
if (Hall_a==1)
{
Hall_a_result =1;
}
else
{
Hall_a_result = 2;
}
}