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.

How to set cc2640 GPIO interrupt?

Other Parts Discussed in Thread: CC2640, SYSBIOS

I am using CCS for cc2640. I am trying to add a GPIO interrupt to sample project "SimpleBLEPeripheral". I followed swru393, the cc26xx software developer guide, section 6.3.1, page 81 to set a GPIO interrupt. But the interrupt does not work. The pin's input can be read correctly by polling with PIN_getIntputValue. However, it never triggers interrupt when I press the button. I have a button connected to ground and a GPIO, I set the GPIO with input enabled, internal pull up resistor, and set the interrupt triggered on negative edge, which is when I press the button. Can anyone help me? Please do not suggest me to refer to SimpleBLECentral or Sensortag's interrupt as I have done that. Thanks.

Following is the code I added to SimpleBLEPeripheral, with reference from cc26xx software developer guide.

static PIN_Config SBP_configTable[]={
IOID_3 | PIN_GPIO_OUTPUT_DIS |PIN_INPUT_EN | PIN_PULLUP |PIN_HYSTERESIS, /* Button is active low */
PIN_TERMINATE
};

PIN_init(SBP_configTable);

#include <ti/drivers/pin/PINCC26XX.h>

static PIN_State sbpPins;
static PIN_Handle hSbpPins;

#define SBP_BTN_EVT 0x0010

// Open pin structure for use
hSbpPins =PIN_open(&sbpPins,SBP_configTable);
// Register ISR
PIN_registerIntCb(hSbpPins,buttonHwiFxn);
// Configure interrupt
PIN_setConfig(hSbpPins,PIN_BM_IRQ,IOID_3|PIN_IRQ_BOTHEDGES);
// Enable wakeup
PIN_setConfig(hSbpPins,PINCC26XX_BM_WAKEUP,IOID_3|PINCC26XX_WAKEUP_NEGEDGE);

static void buttonHwiFxn(PIN_Handle hPin,PIN_Id pinId)
{
if (sem != NULL){
// set event in SBP task to process outside of hwi context
events |= SBP_BTN_EVT;
// Wake up the application.
Semaphore_post(sem);
}
}

if(events &SBP_BTN_EVT)

{
//clear event

events &= ~SBP_BTN_EVT;

//toggle LED1
//some codes for interrupt

}

  • You add PIN_INPUT_EN to your pin configuration.
  • Yes, I added here, but interrupt did not work.
    static PIN_Config SBP_configTable[]={
    IOID_3 | PIN_GPIO_OUTPUT_DIS |PIN_INPUT_EN | PIN_PULLUP |PIN_HYSTERESIS, /* Button is active low */
    PIN_TERMINATE
    };
    The input is enabled, I tested the input with "PIN_getIntputValue", it returns the correct result. But interrupt can not be triggered.
  • You have to add IRQ bit flag (PIN_IRQ_NEGEDGE, PIN_IRQ_POSEDGE, or PIN_IRQ_BOTHEDGES) too.
  • Hi,
    You can refer to SimpleBLECentral project -->board_key.c
  • Thank you, but I have tried that before as below, also did not work.
    static PIN_Config SBP_configTable[]={
    IOID_3 | PIN_GPIO_OUTPUT_DIS |PIN_INPUT_EN | PIN_IRQ_BOTHEDGES | PIN_PULLUP |PIN_HYSTERESIS, /* Button is active low */
    PIN_TERMINATE
    };
  • I would suggest you to change "#define Board_KEY_UP IOID_19 /* RF1.10 */" to "#define Board_KEY_UP IOID_3" in Board.h and test again. By the way, what HW do you use?
  • I am using cc2640 5mm package. What you suggested is for "SimpleBLECentral" not "SimpleBLEPeripheral", right?

  • When building "SimpleBLECentral", I encountered 3 errors: constI2C_Config, Board_SDA, Board_SCL is undefined. But I did not change anything in SimpleBLECentral, can you suggest a solution?
  • "SimpleBLECentral" or "SimpleBLEPeripheral" doesn't matter. You can revise "#define Board_KEY_UP IOID_6 /* RF1.10 */" to "#define Board_KEY_UP IOID_3" in Board.h for 5x5 packag.
  • I think you modify something in your BLE stack by accident and cause this compile issue "constI2C_Config, Board_SDA, Board_SCL is undefined". I suggest you to reinstall a fresh new BLE stack and test again.
  • It turned out that the cause of "constI2C_Config, Board_SDA, Board_SCL is undefined" is that I modified something in board file under the directory "C:\ti\tirtos_simplelink_2_13_00_06\packages\ti\boards\SRF06EB\CC2650EM_7lD". I solved this error by replacing it with the original board file.

    But some other errors popped up: 

    error #10008-D: cannot find file "C:\Lexiwave\software\ccs\SimpleBLECentral\FlashROM\configPkg\package\cfg\appBLE_pem3.oem3"

     undefined                                                                  first referenced                                                                                                                         

      symbol                                                                        in file                                                                                                                              

     ---------                                                                  ----------------                                                                                                                         

     LCD_config                                                                 <whole-program>    

     error #10234-D: unresolved symbols remain

    "./configPkg/linker.cmd", line 690: error #10104: undefined symbol "ti_sysbios_knl_Task_Object__table__V" used in expression

    Have you any idea about this error? Actually I have tried other example projects and modified something in various files in other example projects, board.c board.h etc... to add functionalities to other projects. And they could be built without error. In a single CCS project, I could not find all the sources and headers in one single folder, the file system confuses me. I noticed that different CCS projects can share a lot of same source files: board.c board.h etc... So these new errors may be due to my modifications in other project, right? Actually I never modified any stacks, I only modified apps, so BLE stack should have no problem. To solve these errors, I deleted the SimpleBLECentral projects, both app and stack, then reimported from CCS->Project->Examples->SimpleBLECentral, and built again, but still facing the above red errors.

    I noticed that delete and reimport can not get a fresh new original example project, its content is still modified as I did. Could you suggest a way to restore original example projects? I do not want to reinstall CCS. Thank you very much.

  • This is nothing to do with CCS. It should be caused by your modification on source file of BLE stack. Since I don't know what your modifications are, I suggest you to reinstall BLE Stack to fix the issue.