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.

DRV8301BoostXL and C2000F28027f launchpad

i dont know why once i add the GPIO_setHigh(gpioHandle, GPIO_Number_1); and GPIO_setLow(gpioHandle, GPIO_Number_1);, my motor could not run smoothly, current increased. I want LED 4 to light up when speed is positive and off when speed is negative.

int Count_Pulse ( HAL_Handle handle)
{
static int CurrentState = 0;
    int x;
    x = HAL_GPIO_getData(handle);
    if(x != CurrentState)
    {
        if(x==1)
        {
         if ( gMotorVars.SpeedRef_krpm ==_IQ(0.09999996462))
         {
            GPIO_setLow(gpioHandle, GPIO_Number_1);
            gcount1++;
            CurrentState=x;
            gcount=gcount1;
         }
         else  if ( gMotorVars.SpeedRef_krpm ==_IQ(-0.09999996462))
         {
            GPIO_setHigh(gpioHandle, GPIO_Number_1);
             gcount1--;
             CurrentState=x;
             gcount=gcount1;
         }
        }
        else
        {

            gcount2++;
            CurrentState=x;
        }
    }
return gcount;
}


void Shaft_Position ( HAL_Handle handle)

{
             if( gcount>=163) {

                gMotorVars.SpeedRef_krpm =_IQ(-0.09999996462); //reverse direction
           
             }

             else if( gcount <=30) {
                 gMotorVars.SpeedRef_krpm =_IQ(0.09999996462);
              
             }


}

  • Hi,

    Unfortunately the 27 launch pad uses the same pins for LEDs and for PWMs that control the motor. So using LEDs while controlling a motor would cause overcurrents in the motor, since the outputs, instead of being PWMed, will be set low or high.

    I suggest using a pin that is not used for PWM, and checking that pin with an external LED.

    Regards,
    -Jorge