Hello E2E community,
i want to try a simple blink-led demo for CC2652R1-Launchpad by using a slightly modified version of the "gpiointerrupt_CC26X2R1_LAUNCHXL_nortos_ccs"-example of the CC26x2-SDK (ti\simplelink_cc26x2_sdk_2_20_00_36\examples\nortos\CC26X2R1_LAUNCHXL\drivers\gpiointerrupt).
The program should do the following:
- Btn1 on Launchpad toggles red Led
- Btn2 changes between slow and fast blinking of green Led by setting a new load value to the GPTIMER0.
Blinking of the green Led is done within a timerCallback using GPTIMER0 in 32bit periodic up mode.
Now my problem:
When i press Btn2 i toggle the loadvalue of the timer using GPTimerCC26XX_setLoadValue() between a "fast" and a "slow" blinkking frequency. I still can see the change in the TAILR register, but after two or three Btn2 presses the timerCallback is not executed any more (green Led stop toogling) and the interrupt registers RIS and MIS are both set to zero.
So, it seems to me that the Timer Overflow interrupt is not enabled any more, but why?.
Here is my source for the single mainThread (nortos):
GPTimerCC26XX_Value loadVal = 3000000; //value for "fast" blinking of green Led bool blinkmodeFast = true; GPTimerCC26XX_Handle hTimer; void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { GPIO_toggle(CC26X2R1_LAUNCHXL_GPIO_LED_GREEN); } /* * ======== gpioButtonFxn0 ======== * Callback function for the GPIO interrupt on Board_GPIO_BUTTON0. */ void gpioButtonFxn0(uint_least8_t index) { GPIO_toggle(Board_GPIO_LED0); /* Clear the GPIO interrupt and toggle an LED */ } /* * ======== gpioButtonFxn1 ======== * Callback function for the GPIO interrupt on Board_GPIO_BUTTON1. */ void gpioButtonFxn1(uint_least8_t index) { //toggle blinking-intervall between slow and fast if(blinkmodeFast){ loadVal = 9000000; blinkmodeFast = false; }else{ loadVal = 3000000; blinkmodeFast = true; } //update timer interval GPTimerCC26XX_setLoadValue(hTimer, loadVal); //update of TAILR is always working ok, but why is the timerCallback not invoked any more after changing the load value 2 or 3 times?? //is it allowed to call GPTimerCC26XX_setLoadValue() from within ISR-context?? } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { /* Call driver init functions */ GPIO_init(); /* Configure the LED and button pins */ GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_setConfig(Board_GPIO_BUTTON0, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING); /* Turn on user LED */ GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON); //CC26X2R1_LAUNCHXL_GPIO_LED_RED = Board_GPIO_LED0 /* install Button callback */ GPIO_setCallback(Board_GPIO_BUTTON0, gpioButtonFxn0); /* Enable interrupts */ GPIO_enableInt(Board_GPIO_BUTTON0); /* * If more than one input pin is available for your device, interrupts * will be enabled on Board_GPIO_BUTTON1. */ if (Board_GPIO_BUTTON0 != Board_GPIO_BUTTON1) { /* Configure BUTTON1 pin */ GPIO_setConfig(Board_GPIO_BUTTON1, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING); /* Install Button callback */ GPIO_setCallback(Board_GPIO_BUTTON1, gpioButtonFxn1); // CC26X2R1_LAUNCHXL_GPIO_LED_GREEN = Board_GPIO_LED1 GPIO_enableInt(Board_GPIO_BUTTON1); } //add timer code GPTimerCC26XX_Params params; GPTimerCC26XX_Params_init(¶ms); params.width = GPT_CONFIG_32BIT; params.mode = GPT_MODE_PERIODIC_UP; params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; hTimer = GPTimerCC26XX_open(CC26X2R1_LAUNCHXL_GPTIMER0A, ¶ms); if(hTimer == NULL) { return (NULL); } GPTimerCC26XX_setLoadValue(hTimer, loadVal); GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT); //GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT | GPT_INT_MATCH); GPTimerCC26XX_start(hTimer); while (1){ sleep(1);/* Sleep for 1 second */ } return (NULL); }
Any help appreciated,
Best regards, Albert