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.

GPIO as input for Hall sensor

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE

Hi

I have a custom DSP board with TMS320F28335 that has GPIO port to use GPIO as input on GPIO 33,34 and 35. I want to use these three GPIO inputs to chek the states of Hall sensors to drive BLDC machine. I have defined hall sensor as:

#define Hall_A_ON (GpioDataRegs.GPBSET.bit.GPIO33 = 1); // Hall a-->1

#define Hall_A_OFF (GpioDataRegs.GPBCLEAR.bit.GPIO33 = 1); //Hall a-->0

#define Hall_B_ON (GpioDataRegs.GPBSET.bit.GPIO34 = 1); // Hall a-->1

#define Hall_B_OFF (GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1); //Hall a-->0

#define Hall_C_ON (GpioDataRegs.GPBSET.bit.GPIO35 = 1); // Hall a-->1

#define Hall_C_OFF (GpioDataRegs.GPBCLEAR.bit.GPIO35 = 1); //Hall a-->0

 

I have also configured GPIO ports as input

 

GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 0; // Set GPIO function of the pins

GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;

GpioCtrlRegs.GPBMUX1.bit.GPIO35 = 0;

GpioCtrlRegs.GPBDIR.bit.GPIO33 = 0; // Set GPIO as inputs

GpioCtrlRegs.GPBDIR.bit.GPIO34 = 0;

GpioCtrlRegs.GPBDIR.bit.GPIO35 = 0;

GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0; // Enable pullup on GPIO33

GpioCtrlRegs.GPBPUD.bit.GPIO34 = 0;

GpioCtrlRegs.GPBPUD.bit.GPIO35 = 0;

My question is how I can use if else statement using GPIO signal

for example

if(Hall_A ==1)

Iq=500;             // Where Iq is an arbitrary signal to generate square wave

if(Hall_A==0)

Iq=-500;

 

Best Regards

Shahid Atiq

 

  • Hi Shahid,

    I would recommend doing something similar to what was done in the digital motor control library's f2803xhall_gpio.h file (only with the GPIOs that are appropriate to your hardware setup):
    \controlSUITE\libs\app_libs\motor_control\drivers\f2803x_v2.1\f2803xhall_gpio.h


    #define HALL3_DETERMINE_STATE_MACRO(v)                                                        \
                                                                                                \
        /* temp.2-0 = GPIO26.GPIO25.GPIO24 */                                                    \
        temp = (GpioDataRegs.GPADAT.all>>24)&0x00000007; /* read all three GPIOs at once*/        \
                                                                                                \
        HallGpioBitA = (temp&0x00000001);            /* save GPIO24 - A*/                        \
        HallGpioBitB = (temp&0x00000002)>>1;        /* save GPIO25 - B*/                        \
        HallGpioBitC = (temp&0x00000004)>>2;        /* save GPIO26 - C*/       

    Read all three hall sensor input GPIOs at once.  Next bit manipulate that variable to get the status of each sensor.


    Thank you,
    Brett