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.

LAUNCHXL-CC26X2R1: GPTIMER0A in periodic up mode does not fire interrupt anymore after setting new loadvalue with GPTimerCC26XX_setLoadValue()

Part Number: LAUNCHXL-CC26X2R1

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(&params);
    params.width          = GPT_CONFIG_32BIT;
    params.mode           = GPT_MODE_PERIODIC_UP;
    params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;

    hTimer = GPTimerCC26XX_open(CC26X2R1_LAUNCHXL_GPTIMER0A, &params);
    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

  • Here the registers when the green Led is blinking (GPT_INT_TIMEOUT is working as expected):

    And here when no timerCallback is executed any more (but i don't know why?):

  • hello Albert,

    We are able to replicate this issue and will get back to you early next week with suggestions.

    Regards,
  • hello SVS,
    any news regarding my timer problem? I would be grateful for an early solution...
    regards, Albert
  • Hello Albert,

    Apologize for the delay!

    I will be working on this. Give me time till Wednesday to identify the issue and a workaround.

    Thanks,
    Sai
  • Hello Sai,
    I'm still waiting for a solution and I'm grateful for any advice....
    regards, Albert
  • Hello Albert,

    I suspect the issue is with updating the load value of the timer when the timer is counting up. Here is a scenario that I believe is playing out:

    • Timer is counting up
    • TAILR (loadVal) = 9,000,000 and TAV (Free running Counter value) = 4,000,000 (any value > 3,000,000).
    • Here TAILR is updated (loadVal) to 3,000,000.
    • Now TAV will count from 4,000,000 to 0xFFFFFFFF (that is 4,294,967,295; since it is counting up) roll over and then counts from 0 to 3,000,000.

    When I tried the example, I noticed that after pressing the Button 2 few times, the Green LED stops blinking. But if you wait long enough, it will resume blinking. This confirms the scenario that I mentioned above.

    If you change the Timer mode to down counting, then the above mentioned scenario will not occur. The version that you are using (simplelink_cc26x2_sdk_2_20_00_36) does not have support for down counting. Please update to the latest version of the SDK (simplelink_cc13x2_26x2_sdk_2_40_00_81). Then make the following changes to the code that you provided in the first post. In my limited testing with this change I did not notice the LED stopping blinking.

        /* add timer code */
        GPTimerCC26XX_Params params;
        GPTimerCC26XX_Params_init(&params);
        params.width          = GPT_CONFIG_32BIT;
        params.mode           = GPT_MODE_PERIODIC;
        params.direction      = GPTimerCC26XX_DIRECTION_DOWN;
        params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
    
        hTimer = GPTimerCC26XX_open(CC26X2R1_LAUNCHXL_GPTIMER0A, &params);
        if(hTimer == NULL) {
            return (NULL);
        }

    Thanks,

    Sai

  • Hello Sai,
    for my tests i use a CC2652R1-Launchpad with Revision C chip. On the website it is written: "Please note that this version of the SimpleLink CC13x2 and CC26x2 SDK is validated with Rev. E devices only. For Rev C or earlier please use v2.30.00.xx of the SimpleLink CC13x2 or SimpleLink CC26x2 SDK."
    So did you successfully used this SDK version (simplelink_cc13x2_26x2_sdk_2_40_00_81) with a Rev. C CC2652R1 Launchpad?

    I just tried to copy the two files GPTimerCC26XX.c/.h from the new SDK (\ti\simplelink_cc13x2_26x2_sdk_2_40_00_81\source\ti\drivers\timer) to the old one (simplelink_cc26x2_sdk_2_20_00_36) but your code suggestion did not worked (led was not flashing at all).
    Should i change other files also for this minimalistic example?
    thanks, Albert

    Btw, i tried the unmodified "gpiointerrupt"-example from the new SDK on my Launchpad, and i was not able to debug/run it at all.
  • Hello Albert,

    You are correct about the SDK and silicon version compatibility.

    We are not able to support rev C version of silicon anymore since rev E silicon version is already available. Please upgrade to rev E version of the silicon and let us know if you are still having any trouble with resolving this issue.

    Regards,

  • Hello all,
    Thank you for your answers, even if they are a bit unsatisfactory. I already have some Rev C Launchpads lying around and I just can not accept that with these boards such a minimal example as my blinking-Led-timer problem should not be feasible.

    Why are there no functions for resetting the current timer value? eg in the way of "GPTimerCC26XX_setFreeRunValue()" or "GPTimerCC26XX_resetTimer" ?
    This could solve my problem while maintaining the up-counting timer mode. What is the reason why such a function does not exist?

    If someone has a different idea, how I can control a Led on the LAUNCHXL-CC26X2R1 (Rev C chip) with two different flashing frequencies with a simple held program, I would be very grateful.

    best regards, Albert

  • Hello Albert,

    The only solution I can think of is using Driverlib APIs instead of using the TI-Driver.

    Thanks,
    Sai