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.

CC1310: Why I use GPIO_setConfig() to config CC1310 GPIO ,the GPIO not output my write value?

Part Number: CC1310


here is my code :

/* Analog capable DIOs */
#define CC1310_LAUNCHXL_DIO23_ANALOG          IOID_23
#define CC1310_LAUNCHXL_DIO24_ANALOG          IOID_24
#define CC1310_LAUNCHXL_DIO25_ANALOG          IOID_25
#define CC1310_LAUNCHXL_DIO26_ANALOG          IOID_26
#define CC1310_LAUNCHXL_DIO27_ANALOG          IOID_27
#define CC1310_LAUNCHXL_DIO28_ANALOG          IOID_28
#define CC1310_LAUNCHXL_DIO29_ANALOG          IOID_29
#define CC1310_LAUNCHXL_DIO30_ANALOG          IOID_30

/* Digital IOs */
#define CC1310_LAUNCHXL_DIO0                  IOID_0
#define CC1310_LAUNCHXL_DIO1                  IOID_1
#define CC1310_LAUNCHXL_DIO12                 IOID_12
#define CC1310_LAUNCHXL_DIO15                 IOID_15
#define CC1310_LAUNCHXL_DIO16_TDO             IOID_16
#define CC1310_LAUNCHXL_DIO17_TDI             IOID_17
#define CC1310_LAUNCHXL_DIO21                 IOID_21
#define CC1310_LAUNCHXL_DIO22                 IOID_22

/* Discrete Inputs */
#define CC1310_LAUNCHXL_PIN_BTN1              IOID_13
#define CC1310_LAUNCHXL_PIN_BTN2              IOID_14

/* GPIO */
#define CC1310_LAUNCHXL_GPIO_LED_ON           1
#define CC1310_LAUNCHXL_GPIO_LED_OFF          0

/* I2C */
#define CC1310_LAUNCHXL_I2C0_SCL0             IOID_4
#define CC1310_LAUNCHXL_I2C0_SDA0             IOID_5

/* I2S */
#define CC1310_LAUNCHXL_I2S_ADO               IOID_25
#define CC1310_LAUNCHXL_I2S_ADI               IOID_26
#define CC1310_LAUNCHXL_I2S_BCLK              IOID_27
#define CC1310_LAUNCHXL_I2S_MCLK              PIN_UNASSIGNED
#define CC1310_LAUNCHXL_I2S_WCLK              IOID_28

/* LEDs */
#define CC1310_LAUNCHXL_PIN_LED_ON            1
#define CC1310_LAUNCHXL_PIN_LED_OFF           0
#define CC1310_LAUNCHXL_PIN_RLED              IOID_6
#define CC1310_LAUNCHXL_PIN_GLED              IOID_7

/* PWM Outputs */
#define CC1310_LAUNCHXL_PWMPIN0               CC1310_LAUNCHXL_PIN_RLED
#define CC1310_LAUNCHXL_PWMPIN1               CC1310_LAUNCHXL_PIN_GLED
#define CC1310_LAUNCHXL_PWMPIN2               PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN3               PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN4               PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN5               PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN6               PIN_UNASSIGNED
#define CC1310_LAUNCHXL_PWMPIN7               PIN_UNASSIGNED

/* SPI */
#define CC1310_LAUNCHXL_SPI_FLASH_CS          IOID_20
#define CC1310_LAUNCHXL_FLASH_CS_ON           0
#define CC1310_LAUNCHXL_FLASH_CS_OFF          1

/* 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_SPI1_MISO             PIN_UNASSIGNED
#define CC1310_LAUNCHXL_SPI1_MOSI             PIN_UNASSIGNED
#define CC1310_LAUNCHXL_SPI1_CLK              PIN_UNASSIGNED
#define CC1310_LAUNCHXL_SPI1_CSN              PIN_UNASSIGNED

/* UART Board */
#define CC1310_LAUNCHXL_UART_RX               IOID_2          /* RXD */
#define CC1310_LAUNCHXL_UART_TX               IOID_3          /* TXD */
#define CC1310_LAUNCHXL_UART_CTS              IOID_19         /* CTS */
#define CC1310_LAUNCHXL_UART_RTS              IOID_18         /* RTS */


/*
 *  =============================== PIN ===============================
 */
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>

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,                                             /* SPI clock */
    CC1310_LAUNCHXL_DIO21 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,       /* LED initially off          */
    CC1310_LAUNCHXL_DIO22 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};

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 */

};


void *mainThread(void *arg0)
{

    uint32_t    currentOutputVal;
    uint32_t    standbyDuration = 500000;

    GPIO_init();
    
    /* Configure the control pins */
    GPIO_setConfig(Board_PIN_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    GPIO_setConfig(Board_DIO22, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);


    while(1) {

        GPIO_write(Board_PIN_LED0, Board_GPIO_LED_OFF);
        GPIO_write(Board_DIO22, Board_GPIO_LED_ON);
        usleep(50000);
        GPIO_write(Board_PIN_LED0, Board_GPIO_LED_ON);
        GPIO_write(Board_DIO22, Board_GPIO_LED_OFF);
        usleep(50000);
    }
}

  • Hi Tian,

    It seems like you are using both PIN.h and GPIO.h drivers, which is leading to conflicts in the GPIO initialization.

    From the empty project, you can use the following source file to achieve what you want to do:

    /*
     * Copyright (c) 2015-2019, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== empty.c ========
     */
    
    /* For usleep() */
    #include <unistd.h>
    #include <stdint.h>
    #include <stddef.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    // #include <ti/drivers/I2C.h>
    // #include <ti/drivers/SPI.h>
    // #include <ti/drivers/UART.h>
    // #include <ti/drivers/Watchdog.h>
    
    /* Board Header file */
    #include "Board.h"
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        /* 1 second delay */
        uint32_t time = 50000;
    
        /* Call driver init functions */
        GPIO_init();
        // I2C_init();
        // SPI_init();
        // UART_init();
        // Watchdog_init();
    
        /* Configure the LED pin */
        GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
        GPIO_setConfig(Board_DIO22, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Set LED0 to high so it toggles to a different state than DIO22 */
        GPIO_write(Board_PIN_LED0, Board_GPIO_LED_ON);
    
        while (1) {
            GPIO_toggle(Board_GPIO_LED0);
            GPIO_toggle(Board_DIO22);
            usleep(time);
        }
    }
    

    Regards,

    Arthur

  • thanks for your reply, it seems  I  use PIN driver defined paramter in GPIO driver API cause this problem.