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.

Clock_setTimeout; ticks and events

Other Parts Discussed in Thread: SYSBIOS

Hi,

When using  Clock_setTimeout (clock module from TI RTOS), we create a delay for n Ticks the question is if the event come at the n tick or that we create delay of n Ticks and the event will come after n+1 Ticks?  
For example if the Ticker is 1 msec and we set the clock 200usec after the Tick, does the callback event will come after 800usec(option A) or after 1800usec(option B)?

Do I need to account for  same behavior when using periodic clock (by using Clock_setPeriod)?

  • Fred,

    Both Clock_setTimeout() and Clock_setPeriod() can only be called on Clock objects that are stopped.  And both of these APIs will simply update the corresponding fields within the clock object (“timeout” and “period” respectively).  

    It is when specifically Clock_start() is called, that the Clock object becomes “active”, and the “currTimeout” field in the object gets set.  It is the “currTimeout” field that determines when the specific Clock object times out, and its function gets run.  The Clock_start() logic is essentially:

            obj->currTimeout = (current tick count)  + obj->timeout;
            obj->active = TRUE;

    So in your picture, if Clock_start() were called where you show Clock_setTimeout(), the callback would happen at “A”.

    For reference, you can find the source for the Clock functions within the SYS/BIOS kernel installation (for example, at a path similar to: .. \bios_6_45_01_29\packages\ti\sysbios\knl\Clock.c),

    Regards,
    Scott