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.

CCS/CC2640R2F: GPIO_write isn't working

Part Number: CC2640R2F

Tool/software: Code Composer Studio

Hello all,

I've configured the BLED (Blue LED) on my board file BoardGpioInitTable[] like this:

const PIN_Config  BoardGpioInitTable[] = {

    Board_GLED       | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH   | PIN_PUSHPULL | PIN_DRVSTR_MAX,    /* LED initially off             */
    Board_BLED       | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW    | PIN_PUSHPULL | PIN_DRVSTR_MIN,    /* LED initially off             */
    Board_RLED       | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH   | PIN_PUSHPULL | PIN_DRVSTR_MAX,    /* LED initially off             */
    Board_KEY1       | PIN_INPUT_EN  | PIN_PULLUP | PIN_HYSTERESIS | PINCC26XX_WAKEUP_NEGEDGE,  /* Button is active low          */
    Board_KEY2       | PIN_INPUT_EN  | PIN_PULLUP | PIN_HYSTERESIS,                             /* Button is active low          */
    Board_SPI0_CSN   | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH   | PIN_PUSHPULL,                     /* CS pin at inactive level      */
    Board_ADC0       | PIN_INPUT_EN  | PIN_PULLDOWN,                                            /* ADC Enable                    */

    Board_UART_TX    | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN   | PIN_PULLUP,                       /* UART TX pin at inactive level */
    Board_UART_RX    | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN   | PIN_PULLUP,                       /* UART RX pin at inactive level */
    PIN_TERMINATE

The BLED pin is defined like this:

//LEDs
#define Board_LED_ON                        0 /* LEDs on SaBLE-x EM board LEDs are active low */
#define Board_LED_OFF                       1
#define Board_GLED                          IOID_14
#define Board_BLED                          IOID_7
#define Board_RLED                          IOID_4

In SimplePeripheral.c I want to simply turn on the BLED when advertising starts. So I tried to call GPIO_write(Board_BLED, Board_LED_ON) like this:

static void SimplePeripheral_processAppMsg(spEvt_t *pMsg)
{
  bool dealloc = TRUE;

  switch (pMsg->event)
  {
    case SP_CHAR_CHANGE_EVT:
      SimplePeripheral_processCharValueChangeEvt(*(uint8_t*)(pMsg->pData));
      break;

    case SP_KEY_CHANGE_EVT:
      SimplePeripheral_handleKeys(*(uint8_t*)(pMsg->pData));
      break;

    case SP_ADV_EVT:
      GPIO_write(Board_BLED, Board_LED_ON);
      SimplePeripheral_processAdvEvent((spGapAdvEventData_t*)(pMsg->pData));
      break;

Unfortunately the blue LED doesn't turn on. Am I doing something wrong? BTW if I change the state in the BoardGpioInitTable[] in the board file from low to high and vice versa I can change the state of the LED off->on / on->off.

Help please.

Patrick

  • Hi Patrick,
    How is the LED physically connected? You say changing PIN_GPIO_LOW to _HIGH makes it work?
  • Hi Joakim,

    This is a simple surface mount LED mounted on our custom PCB. It's connected directly to DIO7 with a series current limiting resistor to ground. I know that this LED works because when I change state of the gpioTable in the board file from high to low the LED changes state at start up. Do you see anything wrong in my code? Is there a safe place in SimplePeripheral to simply turn on and off the LED. Maybe I should not have placed in the function that I did.

    Thanks,

    Patrick

  • Hi Patrick,

    At your Board Init Table you set initially the BLED as high so it will be off on device power up.

    Board_BLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MIN,

    Then you re-initialize the the led in your c file same with what is done at pininterrupt example proram

    /*
    * Initial LED pin configuration table
    * - LEDs Board_PIN_LED0 is on.
    * - LEDs Board_PIN_LED1 is off.
    */
    PIN_Config ledPinTable[] = {
    Board_BLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MIN,
    PIN_TERMINATE
    };

    The you use Pin_open to get the handle like this below.

    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, ledPinTable);

    to turn on the led

    PIN_setOutputValue(ledPinHandle,Board_BLED, 0);

    -kel
  • Thanks very much!