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.

CC1310: Using multiple instances of Timer_construct() of timer.h

Part Number: CC1310
Other Parts Discussed in Thread: TIMAC, SYSBIOS

Hi,

I would like to know if its fine to use multiples of Timer_construct() function of timer.h.

in the 15.4 stack, the function Ssf_initializeReadingClock(); is used to initialize a timer for the stack activities.

I would like to know, if I initialize a second timer parallel to the one used in the stack using a new handle and a structure, if it will be fine.

Ex: The stack uses,

void Ssf_initializeReadingClock(void)
{
/* Initialize the timers needed for this application */
readingClkHandle = Timer_construct(&readingClkStruct,
processReadingTimeoutCallback,
READING_INIT_TIMEOUT_VALUE,
0,
false,
0);
}

If I have my function as below with the above.

void Ssf_initializeSavingClock(void)
{
/* Initialize the timers needed for this application */
savingClkHandle = Timer_construct(&savingClkStruct,
processSavingTimeoutCallback,
SAVING_INIT_TIMEOUT_VALUE,
0,
false,
0);
}

Will these 2 initialization use the same timer hardware or different ones?

Can one hardware timer be used for multiple timer instances running in parallel?

Thank you in advance.

Abrar

  • Hi Abrar,

    The number of Timer instances are device specific, in this case it is limited to one (It is based on the RTC) and can not be used to implement multiple timers. Generally, TI-RTOS is depending on this timer, and users should use the 'Clock' module to implement timers. The 'Clock' module sits on top of the Timer and allow multiple clock instances.

    The clock module should be sufficient if a resolution of ~30 us is ok, otherwise I would recommend using the TI-RTOS GPTimer driver (GPTimerCC26xx.h).
  • Hi, Thanx for the reply,

    Could you please explain which function I should be using to create multiple clock instances.

    Also when I looked inside the Timer_construct() function, what it executes is a Clock_construct() function. 

    Is this the clock module you are referring to?

    Clock_Handle Timer_construct(Clock_Struct *pClock, Clock_FuncPtr clockCB, uint32_t clockDuration, uint32_t clockPeriod, uint8_t startFlag, UArg arg)
    {
    Clock_Params clockParams;

    /* Convert clockDuration in milliseconds to ticks. */
    uint32_t clockTicks = clockDuration * (1000 / Clock_tickPeriod);

    /* Setup parameters. */
    Clock_Params_init(&clockParams);

    /* Setup argument. */
    clockParams.arg = arg;

    /* If period is 0, this is a one-shot timer. */
    clockParams.period = clockPeriod * (1000 / Clock_tickPeriod);

    /*
    Starts immediately after construction if true, otherwise wait for a
    call to start.
    */
    clockParams.startFlag = startFlag;

    /*/ Initialize clock instance. */
    Clock_construct(pClock, clockCB, clockTicks, &clockParams);

    return Clock_handle(pClock);
    }

    So can I use multiple instances of Timer_construct() function?



    Thanks.

    Abrar

  • Hi,

    Yes that is the clock module I was referring to. I have confused what Timer we was talking about from the beginning (it is an unfortunate naming of the TIMAC timer utility as it conflicts with the kernel naming of the TI-RTOS Timer module.

    Assuming it is the Timer utility you are using, then it should be fine to implement multiple Timer instances as it wraps the Clock module. These timers will be software timers and share the same hardware.

    There is a small on-line training that goes over the difference between (sysbios) Timers and Clocks if you want to get some additional informations on how the Clock module work: 

  • Hi,

    Thank you very much for your reply.

    It was very helpful.

    Best regards,

    Abrar