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 input at tms320f28027

Other Parts Discussed in Thread: TMS320F28027, DRV8301, CONTROLSUITE

Hello! I'm design a project at TMS320F28027 and DRV8301 for controlling the motor . I used a GPIO32 and 33 to enter the state of Hall sensors. When I run in debug mode - all works well. When I run out of flash , input from GPIO don't work, but all over function work well - UART communication, confrol the motor and main loop. What problem maybe with my project?

  • Hi,

    Иван said:
    When I run in debug mode - all works well.

    When you say all works well while in debug mode - do you mean you run the code from flash while debugging?

    Regards,

    Gautam

  • Yes, I run program from flash. I have defined FLASH symbol. In the code I have this:

    // Only used if running from FLASH
    // Note that the variable FLASH is defined by the project
    #ifdef FLASH
    // Copy time critical code and Flash setup code to RAM
    // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
    // symbols are created by the linker. Refer to the linker files.
    memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);
    #endif

    Init of my gpios are:

    GPIO_setPullUp(obj->gpioHandle,GPIO_Number_32,GPIO_PullUp_Enable);
    GPIO_setMode(obj->gpioHandle,GPIO_Number_32,GPIO_32_Mode_GeneralPurpose);
    GPIO_setHigh(obj->gpioHandle,GPIO_Number_32);
    GPIO_setDirection(obj->gpioHandle,GPIO_Number_32,GPIO_Direction_Input);

    GPIO_setPullUp(obj->gpioHandle,GPIO_Number_33,GPIO_PullUp_Enable);
    GPIO_setMode(obj->gpioHandle,GPIO_Number_33,GPIO_33_Mode_GeneralPurpose);
    GPIO_setHigh(obj->gpioHandle,GPIO_Number_33);
    GPIO_setDirection(obj->gpioHandle,GPIO_Number_33,GPIO_Direction_Input);

  • Have you checked boot mode selection pins (GPIO 37 ,GPIO34 and TRST ) state refer datasheet page number 25 once
  • This pins set for boot from flash. GPIO 37 ,GPIO34 set to high, TRST set to low. And program load normally, everything works except GPIO input...

  • In debugging mode You are checking GPIO register or using any  variable ?

    and that is written in isr or some where else.please send the code which you have written

  • Otherwise use capture(ECAP) for Hall sensor state reading.using capture interrupt you will get exact Hall sensor state.
  • I use next code for get state of GPIO:

    iHall1Now=GPIO_getData(drvobj->gpioHandle,GPIO_Number_32);
    iHall2Now=GPIO_getData(drvobj->gpioHandle,GPIO_Number_33);
    if(CheckFallEdge0(iHall1Now))
    bRevers=1;
    else if(CheckFallEdge1(iHall2Now))
    bRevers=0;

    Function for check fall edge:

    int CheckFallEdge0(int iItem)
    {
    static int iPrev0=0;
    int iRet=0;
    if((iPrev0!=iItem)&&(iItem==0))
    iRet=1;
    else
    iRet=0;
    iPrev0=iItem;
    return iRet;
    }

    int CheckFallEdge1(int iItem)
    {
    static int iPrev1=0;
    int iRet=0;
    if((iPrev1!=iItem)&&(iItem==0))
    iRet=1;
    else
    iRet=0;
    iPrev1=iItem;
    return iRet;
    }

    For GPIO32 and GPIO33 f28027 don't have interrupt processing.

  • Are you using watch dog timer in your code?
  • No, watchdog timer disable.
  • That's pretty odd! Can you try commenting the rest of the code and check again. Also, try creating a new project or cleaning the current project and then rebuilding. Seems like compiler is misbehaving.

    Also, you've an option to try using the structured approach?
    Example codes here: C:\ti\controlSUITE\device_support\f2802x\v230\f2802x_examples_structs

    Regards,
    Gautam