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.

Declaring GPIO Pins?

I am new to TI-RTOS and CCS and am having a hard time trying to do something quite simple: Read or write binary values to an arbitrary GPIO pin. The board I am working with is the MSP-EXP432P401R

My main question is: What is the "right" way to add a GPIO pin to a task in TI-RTOS? 

I read the TI-RTOS manual entry for the GPIO driver and I understand that the GPIO pins and ports need to be configured in MSP_EXP432P401R.c and .h. I am not sure where each of the parameters come from in the GPIO_PinConfig gpioPinConfigs[] definition, or which other definitions I need to be sure to complete and how. 

Could someone help me in the right direction by giving an example for how I would set up a pin/port (say, P2.7)  as an input/output with TI-RTOS?

Thank you!

  • Update: I think I've almost got this working but I have tripped one of the asserts in GPIOMSP432.c.

    Specifically, this is the error I got:
    [CORTEX_M4_0] xdc.runtime.Main: "gpio/GPIOMSP432.c", line 497: assertion failure
    xdc.runtime.Error.raise: terminating execution

    Here's line 497 (the assertion that failed):
    DebugP_assert(initCalled && index < GPIOMSP432_config.numberOfPinConfigs);

    So something must be wrong with the way I added the target pin to gpioPinConfigs[] in the board configuration .c file and to "typedef enum MSP_EXP432P401R_GPIOName" in the board configuration header file.

    Here is my code, for reference. I am trying to assign P1_6 as a GPIO output:


    *~*~*~*~*~*~* in the .c file:
    GPIO_PinConfig gpioPinConfigs[] = {
    /* Input pins */

    GPIOMSP432_P1_4 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,

    /* Output pins */
    /* MSP_EXP432P401R_LED1 */
    GPIOMSP432_P1_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* MSP_EXP432P401R_LED_RED */
    GPIOMSP432_P2_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,

    // MSP_EXP432P401R_DIR_LEFT -->Direction Pin for Left motor
    GPIOMSP432_P1_6 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,

    /*
    * MSP_EXP432P401R_LED_GREEN & MSP_EXP432P401R_LED_BLUE are used for
    * PWM examples. Uncomment the following lines if you would like to control
    * the LEDs with the GPIO driver.
    */
    /* MSP_EXP432P401R_LED_GREEN */
    //GPIOMSP432_P2_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    /* MSP_EXP432P401R_LED_BLUE */
    //GPIOMSP432_P2_2 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW
    };

    *~*~*~*~*in the header file:

    typedef enum MSP_EXP432P401R_GPIOName {
    MSP_EXP432P401R_S1 = 0,
    MSP_EXP432P401R_S2,
    MSP_EXP432P401R_LED1,
    MSP_EXP432P401R_LED_RED,
    MSP_EXP432P401R_DIR_LEFT,

    /*
    * MSP_EXP432P401R_LED_GREEN & MSP_EXP432P401R_LED_BLUE are used for
    * PWM examples. Uncomment the following lines if you would like to control
    * the LEDs with the GPIO driver.
    */
    //MSP_EXP432P401R_LED_GREEN,
    //MSP_EXP432P401R_LED_BLUE,

    MSP_EXP432P401R_GPIOCOUNT
    } MSP_EXP432P401R_GPIOName;
  • Hi Daniel,

    I believe you might be missing the first entry of your pin configuration array.

    {
    /* Input pins */
    /* MSP_EXP432P401R_S1 */

    // >>>>>>>>> MISSING THE FIRST ENTRY <<<<<<<<<<<<<// GPIOMSP432_P1_1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING, //>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<//

    /* MSP_EXP432P401R_S2 */ GPIOMSP432_P1_4 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING, /* Output pins */ /* MSP_EXP432P401R_LED1 */ GPIOMSP432_P1_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, /* MSP_EXP432P401R_LED_RED */ GPIOMSP432_P2_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, // Your extra gpio here // MSP_EXP432P401R_DIR_LEFT -->Direction Pin for Left motor GPIOMSP432_P1_6 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW };

    You GPIOName table counts up to 5 entries, but you only had 4 because of the first one missing.

    Regards,

    Michel