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.

RTOS/LAUNCHXL-CC2640R2: GPTimerCC26XX.h - Timer won't count up from 0

Part Number: LAUNCHXL-CC2640R2

Tool/software: TI-RTOS

Hi E2E, 

I've tried to setup a counter based interrupt in my BLE application, but the counter doesn't seem to start, ever. 
The project is based on the simplePeripheral project, and the timer related code can be seen below: 

/*************************************************************************************************
                                            Timer START
**************************************************************************************************/
#include <ti/drivers/timer/GPTimerCC26XX.h> 

GPTimerCC26XX_Handle LEDTimer_handle;
GPTimerCC26XX_Params timerParams;
/*************************************************************************************************
                                             Timer END
**************************************************************************************************/

void main()
{
    /* Create timer for LED control */
    GPTimerCC26XX_Params_init(&timerParams);
    timerParams.width          = GPT_CONFIG_16BIT;
    timerParams.mode           = GPT_MODE_PERIODIC_UP; //GPT_MODE_ONESHOT_UP;
    timerParams.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
    LEDTimer_handle = GPTimerCC26XX_open(CC2640R2_LAUNCHXL_GPTIMER3A, &timerParams);
    if(LEDTimer_handle != NULL){
        PIN_setOutputValue(ledPinHandle, Board_PIN_LED0, !PIN_getOutputValue(Board_PIN_LED0));
    }
    int matchValue = 48000000; // every sec
    GPTimerCC26XX_setMatchValue(LEDTimer_handle, matchValue);
    GPTimerCC26XX_setLoadValue(LEDTimer_handle, 0);
    GPTimerCC26XX_registerInterrupt(LEDTimer_handle, timerCallback, GPT_INT_MATCH);
    GPTimerCC26XX_start(LEDTimer_handle);
}

void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
{
    PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1));
}

I can see from the LED, than the timer opens correct, and as try to debug the code, I can also see that the timer is started with the start-function. But, when I try to to call the "GPTimerCC26XX_getValue(LEDTimer_handle);" function over and over again, the counter seems to be stuck at 0. 

Am I doing anything wrong? 

Kind regards, Peter

  • Hi Peter,

    You have forgotten to enable the GPTimer interrupts. Adding the following line should solve your problem:

    GPTimerCC26XX_enableInterrupt(LEDTimer_handle, 0xFFFF);

    I hope this will help you,

  • Hi Clément, and thanks for your answer.

    But unfortunately, it didn't help anything.

    TI's manal for the Driver: (software-dl.ti.com/.../_g_p_timer_c_c26_x_x_8h.html
    According to TI's manual for the driver , the "GPTimerCC26XX_registerInterrupt"-function should enable the interrupt itself. Furthermore, according to several examples of Timer setups, the enableInterrupt isn't needed, as the registerInterrupt-function is enroled.

    I can come with some more info though:
    The timer seems to provoke a single interrupt some time after it has been started but onle once, which is strange as it should be configured to be periodic. After the callback function of the interrupt is called, the timer is stuck at 0.
    Furthermore, if I start the timer again, in the callback function of the interrupt, the timer is still stuck at 0.
    This seems weird to me, as the timer seems to be configured to be one-shot, even though it's not - and furthermore, that even though if it is somehow set up to be one-shot, why can't I start the timer again, after the interrupt?
  • Which SDK version are you using?
  • SimpleLink CC2640R2 SDK - v:2.40.00.32
  • It seems that I've figured it out.

    When the timer is loaded with 0, it wont start - ever. As soon as I load the timer with a number != 0, it works as intended.