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-CC26X2R1: question about timers in Simplelink CC26x2

Guru 18595 points
Part Number: LAUNCHXL-CC26X2R1

Tool/software: TI-RTOS

Dear,

my BLE application has several tasks, all working fine concurrently.

Now, I create a new one to be executed every some time, with this code inside its _taskfxn():

#if 0
    GPTimerCC26XX_Params params;
    GPTimerCC26XX_Params_init(&params);
    params.width          = GPT_CONFIG_16BIT;
    params.mode           = GPT_MODE_PERIODIC_UP;
    params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;
    ti_td_minion = GPTimerCC26XX_open(CC26X2R1_LAUNCHXL_GPTIMER0A, &params);
    if(ti_td_minion == NULL)
    {
      Log_error0("Failed to open GPTimer");
      Task_exit();
    }
    Types_FreqHz  freq;
    BIOS_getCpuFreq(&freq);
    GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; // 47999
    GPTimerCC26XX_setLoadValue(ti_td_minion, loadVal);
    GPTimerCC26XX_registerInterrupt(ti_td_minion, TDMinion_ti_fxn, GPT_INT_TIMEOUT);
    GPTimerCC26XX_start(ti_td_minion);
#endif

#if 1
    Error_init(&eb_td_minion);
    Timer_Params timerParams;
    Timer_Params_init(&timerParams);
    timerParams.period = 50000 * 1000;
    timerParams.periodType = Timer_PeriodType_MICROSECS;
    timerParams.startMode = Timer_StartMode_USER;
    timerParams.runMode = Timer_RunMode_CONTINUOUS;
    ti_td_minion = Timer_create(Timer_ANY, my_isr,
            &timerParams, &eb_td_minion);
    if (ti_td_minion == NULL)
    {
        System_abort("***ERROR*** >> ti_td_minion CREATE FAILED");
    }

First approach works. Second one, however, leads me always to the System_abort line. my_isr() is

void my_isr(xdc_UArg arg1)
{
    Log_info0("my_isr()");
}

I discard first approach based on GPTimer because according to the documentation "The device will only go to Idle power mode since the high-frequency clock is needed for timer operation".

So, my question is twofold, well threefold:

  1.     For the second approach, I suspect it does not work because Timer API tries to use RTC, needed by BLE stack. Am I right? If so, why such approach is not picking, for example, TimerA, since I indicate Timer_ANY?
  2.     For the first approach, having a timer like this on during all the time, it would prevent my BLE code going to low power mode, am I right?
  3.     So, the remaining possibility would be using Clocks API as in the simple_ble_peripheral example?


So, let's see if I can understand better this with your help.

Have a really nice day.

  • Hi Kazola,
    I'm assigning one of the experts to comment, although there might be some delay due to national holidays until 22nd. Meanwhile, maybe the community has some fruitful feedback.
  • Hi Kazola,

    RTC channel 0 is used by the system (RTOS) and I suppose you could technically use a different channel for yourself, but the easiest solution is to use the Clock API, which uses the RTC, and on interrupt (Hwi) will generate Swi that calls your clockFxn callback. In this callback you can take some limited action, but most RTOS APIs and all stack APIs are unavailable in Swi context, so the orthodox approach here is to post an event to and/or send a message to your Task for processing.

    Best regards,
    Aslak