I have modified the pinInterrupt example for the CC2650DK and essentially removed the callbackfunction and replaced it with an HWI for edge detection on IOID6 (previously connected to LED4). I was having problems with the hwi creation in that if I had the error_block field set to null, the program would hit the exit breakpoint after calling the hwi_construct function.
I resolved this issue by adding the error_block variable to record the error message and code but I can make no sense of it the error message string is: 0x1EB4 ""; and the error code is 0.
The program will now continue to run however I can never get it to enter the ISR which leads me to believe something with the hwi_construct failed.. Any ideas?
Edit: Also I tried statically creating the hwi in the .cfg file and the program just exits as was happening before.
My code is as follows:
/* XDCtools Header files */ #include <xdc/std.h> #include <xdc/cfg/global.h> #include <xdc/runtime/System.h> #include <xdc/runtime/Error.h> /* BIOS Header files */ #include <ti/sysbios/BIOS.h> #include <ti/sysbios/family/arm/cc26xx/Power.h> #include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h> #include <ti/sysbios/knl/Task.h> /* TI-RTOS Header files */ #include <ti/drivers/PIN.h> #include <ti/drivers/pin/PINCC26XX.h> #include <driverlib/ioc.h> #include <driverlib/timer.h> #include <driverlib/prcm.h> /* Example/Board Header files */ #include "Board.h" /* Pin driver handles */ static PIN_Handle buttonPinHandle; static PIN_Handle ledPinHandle; static String errormsg; static uint16_t errorcode; /* Global memory storage for a PIN_Config table */ static PIN_State buttonPinState; static PIN_State ledPinState; void Edge_Isr(UArg x); //ISR PIN_Config ledPinTable[] = { Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, #if defined(Board_LED3) Board_LED3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, #endif PIN_TERMINATE }; /* * Application button pin configuration table: * - Buttons interrupts are configured to trigger on falling edge. * - If the UP, DOWN, SELECT inputs are defined add them to the table. */ PIN_Config buttonPinTable[] = { Board_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, Board_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, Board_LED4 | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_POSEDGE, // make IOID6/LED4 pin an input(I've physically disconnected LED4 from IOID6) #if defined(Board_LED3) Board_KEY_UP | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, Board_KEY_DOWN | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, Board_KEY_SELECT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, #endif PIN_TERMINATE }; int main(void) { Hwi_Struct hwiStruct; Hwi_Params hwiParams; xdc_runtime_Error_Block eb; /* Call board init functions */ Board_initGeneral(); /* Open LED pins */ ledPinHandle = PIN_open(&ledPinState, ledPinTable); if(!ledPinHandle) { System_abort("Error initializing board LED pins\n"); } buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable); if(!buttonPinHandle) { System_abort("Error initializing button pins\n"); } //setup the HWI Hwi_Params_init(&hwiParams); Error_init(&eb); Hwi_construct(&hwiStruct, INT_EDGE_DETECT, Edge_Isr, &hwiParams,&eb); errormsg = Error_getMsg(&eb); errorcode = Error_getCode(&eb); /* Start kernel. */ BIOS_start(); return (0); } void Edge_Isr(UArg x) { //never reaches breakpoints here!!! uint32_t currVal = 0; currVal = PIN_getOutputValue(Board_LED1); PIN_setOutputValue(ledPinHandle,Board_LED1,!currVal); }