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.

LAUNCHXL-CC1310: Configuration process for a GPIO Pin

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310

Greetings

I am looking to configure a GPIO pin, to be set (go "high) in the mainThread. However, when toggling the pin to go "high", it sits at 0V, when I measure the pin's voltage. I am using a CC1310 launchpad and editing the uartEcho example for this, where I want to configure IOID_25 specifically. This will be the CS pin for SPI communication for SPI0. I've referred to the documentation of creating a custom board and I have created a define in CC1310_LAUNCHPADXL.h; 

#define CC1310_LAUNCHXL_GPIO_TEST_PIN     IOID_25;

and I've defined the pin in Board.h as;

#define Board_TEST_GPIO_PIN25   CC1310_LAUNCHXL_GPIO_TEST_PIN. 

I have also added configuration parameters for the pin itself in CC1310_LAUNCHPADXL.c, in the BoardGpioInitTable array;

CC1310_LAUNCHXL_GPIO_TEST_PIN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW| PIN_PUSHPULL | PIN_DRVSTR_MAX,

To use the GPIO pin I've defined, I have created a function in a separate .c/.h file that includes <ti/drivers/GPIO.h> and Board.h and toggles the pin in the while(1) loop in the mainThread by;

GPIO_write(Board_TEST_GPIO_PIN25, Board_GPIO_LED_ON). 

The pin however, does not go high when flashing the board. Other than the steps above, I am unsure where else I should make changes as beyond the steps I've implemented, the docs state that the GPIO_PinConfig be altered, however that is an array which seems to initialise the unused pins. I've made sure that GPIOCC26XX_DIO_25 is not present in that array.

Any help would be appreciated to find out why the pin is not going "high". 

Regards

  • I took the uartEcho echo example and did the following modifications:

    Board.h

    #define Board_GPIO_BUTTON0      CC1310_LAUNCHXL_GPIO_S1
    #define Board_GPIO_BUTTON1      CC1310_LAUNCHXL_GPIO_S2
    #define Board_GPIO_BTN1         CC1310_LAUNCHXL_GPIO_S1
    #define Board_GPIO_BTN2         CC1310_LAUNCHXL_GPIO_S2
    #define Board_GPIO_LED0         CC1310_LAUNCHXL_GPIO_LED_RED
    #define Board_GPIO_LED1         CC1310_LAUNCHXL_GPIO_LED_GREEN
    #define Board_GPIO_RLED         CC1310_LAUNCHXL_GPIO_LED_RED
    #define Board_GPIO_GLED         CC1310_LAUNCHXL_GPIO_LED_GREEN
    #define Board_GPIO_LED_ON       CC1310_LAUNCHXL_GPIO_LED_ON
    #define Board_GPIO_LED_OFF      CC1310_LAUNCHXL_GPIO_LED_OFF
    #define Board_GPIO_TMP116_EN    CC1310_LAUNCHXL_GPIO_TMP116_EN
    #define Board_GPIO_TEST_DIO25   CC1310_LAUNCHXL_GPIO_TEST_DIO25 ///////////
    

    CC1310_LAUNCHXL.h

    typedef enum CC1310_LAUNCHXL_GPIOName {
        CC1310_LAUNCHXL_GPIO_S1 = 0,
        CC1310_LAUNCHXL_GPIO_S2,
        CC1310_LAUNCHXL_SPI_MASTER_READY,
        CC1310_LAUNCHXL_SPI_SLAVE_READY,
        CC1310_LAUNCHXL_GPIO_LED_GREEN,
        CC1310_LAUNCHXL_GPIO_LED_RED,
        CC1310_LAUNCHXL_GPIO_TMP116_EN,
        CC1310_LAUNCHXL_GPIO_SPI_FLASH_CS,
        CC1310_LAUNCHXL_SDSPI_CS,
        CC1310_LAUNCHXL_GPIO_LCD_CS,
        CC1310_LAUNCHXL_GPIO_LCD_POWER,
        CC1310_LAUNCHXL_GPIO_LCD_ENABLE,
        CC1310_LAUNCHXL_GPIO_TEST_DIO25,////////////////
        CC1310_LAUNCHXL_GPIOCOUNT
    } CC1310_LAUNCHXL_GPIOName;
    

    CC1310_LAUNCHXL.c

    GPIO_PinConfig gpioPinConfigs[] = {
        /* Input pins */
        GPIOCC26XX_DIO_13 | GPIO_DO_NOT_CONFIG,  /* Button 0 */
        GPIOCC26XX_DIO_14 | GPIO_DO_NOT_CONFIG,  /* Button 1 */
    
        GPIOCC26XX_DIO_15 | GPIO_DO_NOT_CONFIG,  /* CC1310_LAUNCHXL_SPI_MASTER_READY */
        GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,  /* CC1310_LAUNCHXL_SPI_SLAVE_READY */
    
        /* Output pins */
        GPIOCC26XX_DIO_07 | GPIO_DO_NOT_CONFIG,  /* Green LED */
        GPIOCC26XX_DIO_06 | GPIO_DO_NOT_CONFIG,  /* Red LED */
        GPIOCC26XX_DIO_30 | GPIO_DO_NOT_CONFIG,  /* TMP116_EN */
    
        /* SPI Flash CSN */
        GPIOCC26XX_DIO_20 | GPIO_DO_NOT_CONFIG,
    
        /* SD CS */
        GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,
    
        /* Sharp Display - GPIO configurations will be done in the Display files */
        GPIOCC26XX_DIO_24 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
        GPIOCC26XX_DIO_22 | GPIO_DO_NOT_CONFIG, /* LCD power control */
        GPIOCC26XX_DIO_23 | GPIO_DO_NOT_CONFIG, /*LCD enable */
    
        GPIOCC26XX_DIO_25 | GPIO_DO_NOT_CONFIG, ///////////////////////////////////
    
    };
    
    
    
    const PIN_Config BoardGpioInitTable[] = {
    
        CC1310_LAUNCHXL_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off          */
        CC1310_LAUNCHXL_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off          */
        CC1310_LAUNCHXL_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low       */
        CC1310_LAUNCHXL_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES | PIN_HYSTERESIS,          /* Button is active low       */
        CC1310_LAUNCHXL_SPI_FLASH_CS | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,  /* External flash chip select */
        CC1310_LAUNCHXL_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN,                                              /* UART RX via debugger back channel */
        CC1310_LAUNCHXL_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,                         /* UART TX via debugger back channel */
        CC1310_LAUNCHXL_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master out - slave in */
        CC1310_LAUNCHXL_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN,                                            /* SPI master in - slave out */
        CC1310_LAUNCHXL_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN,                                             
        IOID_25 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW| PIN_PUSHPULL,///////////
        PIN_TERMINATE
    };

    I could control the DIO25 from the application:

    void *mainThread(void *arg0)
    {
    char input;
    const char echoPrompt[] = "Echoing characters:\r\n";
    UART_Handle uart;
    UART_Params uartParams;
    
    /* Call driver init functions */
    GPIO_init();
    UART_init();
    
    /* Configure the LED pin */
    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
    
    GPIO_setConfig(Board_GPIO_TEST_DIO25, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
    GPIO_write(Board_GPIO_TEST_DIO25, 1);
    GPIO_write(Board_GPIO_TEST_DIO25, 0);

    Siri

  • Hi Siri

    Thank you for responding.

    I have added CC1310_LAUNCHXL_GPIO_TEST_DIO25 to my CC1310_LAUNCHXL.h file and upon building, I get the following error:

    error #41: expected an identifier

    Also, I believe you made a mistake in the 3rd code segment above. I was only able to find the BoardGpioInitTable array in  CC1310_LAUNCHXL.c

     

  • I have modified the code in my first reply.

    I did the above changes in a new project, and verified that I could toggle DIO25.

    Siri


  • Hi Siri

    Thank you for the response. This was correct. However, can you please detail your answer? Must the enum value of CC1310_LAUNCHXL_GPIO_TEST_DIO25 correspond to its element number in the BoardGpioInitTable array? 

    Why was GPIOCC26XX_DIO_25 | GPIO_DO_NOT_CONFIG, added to the gpioPinConfigs array? 

  • The order of the pin configurations:

    /*
     * Array of Pin configurations
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in CC1310_LAUNCHXL.h
     * NOTE: Pins not used for interrupts should be placed at the end of the
     *       array. Callback entries can be omitted from callbacks array to
     *       reduce memory usage.
     */
    GPIO_PinConfig gpioPinConfigs[] = {
        /* Input pins */
        GPIOCC26XX_DIO_13 | GPIO_DO_NOT_CONFIG,  /* Button 0 */
        GPIOCC26XX_DIO_14 | GPIO_DO_NOT_CONFIG,  /* Button 1 */
    
        GPIOCC26XX_DIO_15 | GPIO_DO_NOT_CONFIG,  /* CC1310_LAUNCHXL_SPI_MASTER_READY */
        GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,  /* CC1310_LAUNCHXL_SPI_SLAVE_READY */
    
        /* Output pins */
        GPIOCC26XX_DIO_07 | GPIO_DO_NOT_CONFIG,  /* Green LED */
        GPIOCC26XX_DIO_06 | GPIO_DO_NOT_CONFIG,  /* Red LED */
        GPIOCC26XX_DIO_30 | GPIO_DO_NOT_CONFIG,  /* TMP116_EN */
    
        /* SPI Flash CSN */
        GPIOCC26XX_DIO_20 | GPIO_DO_NOT_CONFIG,
    
        /* SD CS */
        GPIOCC26XX_DIO_21 | GPIO_DO_NOT_CONFIG,
    
        /* Sharp Display - GPIO configurations will be done in the Display files */
        GPIOCC26XX_DIO_24 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
        GPIOCC26XX_DIO_22 | GPIO_DO_NOT_CONFIG, /* LCD power control */
        GPIOCC26XX_DIO_23 | GPIO_DO_NOT_CONFIG, /*LCD enable */
    
        GPIOCC26XX_DIO_25 | GPIO_DO_NOT_CONFIG, ///////////////////////////////////
    };

    must match the order of CC1310_LAUNCHXL_GPIOName:

    typedef enum CC1310_LAUNCHXL_GPIOName {
        CC1310_LAUNCHXL_GPIO_S1 = 0,
        CC1310_LAUNCHXL_GPIO_S2,
        CC1310_LAUNCHXL_SPI_MASTER_READY,
        CC1310_LAUNCHXL_SPI_SLAVE_READY,
        CC1310_LAUNCHXL_GPIO_LED_GREEN,
        CC1310_LAUNCHXL_GPIO_LED_RED,
        CC1310_LAUNCHXL_GPIO_TMP116_EN,
        CC1310_LAUNCHXL_GPIO_SPI_FLASH_CS,
        CC1310_LAUNCHXL_SDSPI_CS,
        CC1310_LAUNCHXL_GPIO_LCD_CS,
        CC1310_LAUNCHXL_GPIO_LCD_POWER,
        CC1310_LAUNCHXL_GPIO_LCD_ENABLE,
        CC1310_LAUNCHXL_GPIO_TEST_DIO25,////////////////
        CC1310_LAUNCHXL_GPIOCOUNT
    } CC1310_LAUNCHXL_GPIOName;

    The pin configuration is explained here:

    GPIO.h File Reference (ti.com)

    Siri

  • Hi Siri

    Apologies for responding to this issue even though its resolved but given the above configuration, these are for GPIO-specific pins i.e. they aren't associated with any peripheral?

    The reason I ask, is because I now have a custom board with a CC1310, where the SPI pins have been remapped. From the uartEcho example, I can see the default SPI pins except the CSN PIN are configured in BoardGpioInitTable[]. May I ask, why is this the case? Is the CSN pin GPIO-specific?

    I am confused with this because the gpioPinConfigs array and enum do not include SPI pins (or pins used by other peripheral).

    In addition, another spanner in the works, is that the convention among my colleagues, is that the BoardGpioInitTable array is not used (except for PIN_TERMINATE), and all pin config is done in the gpioPinConfigs array. If I do not use the BoardGpioInitTable array, where would I do the pin configuration for the SPI pins?

  • I am sorry, but I have not been able to get hold of the right people to answer why the implementation is as it is.

    However, I did a test on the CC1310 LP where I change the location of the SPI.

    I changed it from the default DIO8, DIO9, DIO10 and DIO11, to DIO12, DIO15, DIO21, and DIO22.

    The only change I had to do in the code was the following (in CC1310_LAUNCHXL.h):

    /* SPI Board */
    //#define CC1310_LAUNCHXL_SPI0_MISO             IOID_8          /* RF1.20 */
    //#define CC1310_LAUNCHXL_SPI0_MOSI             IOID_9          /* RF1.18 */
    //#define CC1310_LAUNCHXL_SPI0_CLK              IOID_10         /* RF1.16 */
    //#define CC1310_LAUNCHXL_SPI0_CSN              IOID_11
    
    
    #define CC1310_LAUNCHXL_SPI0_MISO             IOID_12         
    #define CC1310_LAUNCHXL_SPI0_MOSI             IOID_15        
    #define CC1310_LAUNCHXL_SPI0_CLK              IOID_21       
    #define CC1310_LAUNCHXL_SPI0_CSN              IOID_22
    
    

    BR

    Siri