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_setConfig() in ti-rtos 2.12.0.24 bug causes input pin not to be configured correctly

Other Parts Discussed in Thread: MSP430F5638

I had problems configuring input pin as GPIO_CFG_INPUT with GPIO_setConfig() and GPIO_Init() in the latest TI-RTOS and think there is a bug in the GPIO_setConfig() routing in GPIOMSP430.c

 

The code uses the defines from GPIO.h

#define GPIO_CFG_INPUT             (((uint32_t) 1) << GPIO_CFG_IO_LSB) /*! Pin is an input. */
#define GPIO_CFG_IN_NOPULL         (((uint32_t) 1) << GPIO_CFG_IO_LSB) /*! Input pin has no PU/PD */
#define GPIO_CFG_IN_PU             (((uint32_t) 3) << GPIO_CFG_IO_LSB) /*! Input pin has Pullup */
#define GPIO_CFG_IN_PD             (((uint32_t) 5) << GPIO_CFG_IO_LSB) /*! Input pin has Pulldown */

and in GPIOMSP430.c/GPIO_setConfig()
if (!(pinConfig & GPIO_CFG_IN_INT_ONLY)) {
        if (pinConfig & GPIO_CFG_INPUT) {
            /* Configure as input */
            if (pinConfig & GPIO_CFG_IN_PU) {
                GPIO_setAsInputPinWithPullUpResistor(gpioPort, gpioPin);
            }
            else if (pinConfig & GPIO_CFG_IN_PD) {
                GPIO_setAsInputPinWithPullDownResistor(gpioPort, gpioPin);
            }
            else {
                GPIO_setAsInputPin(gpioPort, gpioPin);
            }
        }

Any input line will always be configured as a GPIO_CFG_IN_PU as (pinConfig & GPIO_CFG_IN_PU) will always be true if the input is GPIO_CFG_INPUT as (1&3) and (1&5) will always result in true.

The workaround I've used for now is to use the GPIO_setAsInputPin(gpioPort, gpioPin); API directly and not the RTOS API.