Timer functions

execKillTimer()

Function prototype:

boolean execKillTimer(word or byte Timer);

Parameters: Timer the number of the timer to disable (kill)

Returns: true if it succeeded or false if it failed. It will fail if an invalid timer number is passed (but not if the timer has already been killed).

This disables the timer, but does not remove any pending events posted by that timer. Use execPurgeTimer if this is required.

execProcessTimeouts()

Function prototype:

word execProcessTimeouts(word TickCount);

Parameters: TickCount the current main timer value

Returns: the tick count at which the next timeout is due to occur. If the value returned is the same as the value passed, it implies that all timers have timed out, and the timer subsystem can be disabled.

This function is designed to be called from within the timer interrupt routine only. For this reason there is no queue locking performed on the timer queue.

This function may be called without detrimental effects if no timeout is due. It may also be called late, that is, if a small number of tick counts have passed since the pending timeout has become due. For the sake of accuracy and performance, it is preferable, though, that this is called exactly at the point of timeout and only on the point of timeout.

execPurgeTimer()

Function prototype:

boolean execPurgeTimer(word or byte Timer);

Parameters: Timer the number of the timer to disable (kill)

Returns: true if it succeeded or false if it failed. It will fail if an invalid timer number is passed (but not if the timer has already been killed).

This disables the timer and removes any pending events posted by that timer. (Note that all occurrences of the event stored as the EventToPost for that timer will be removed from the event queues. The implication is that this event would be unique to this timer, i.e. not used by any other timer or function. Use execKillTimer in preference to this function unless this action is definitely required. This is because removing events from the queues is time consuming.

execSetTimer()

Function prototype:

boolean execSetTimer(word or byte Timer, word TimeDelay, 
                     word or byte Event);

Parameters: Timer the number of the timer to set TimeDelay the value of the time delay
Event the event number to post on timeout

Returns: true if it succeeded or false if it failed. It will fail if an invalid timer or event number is passed.

Setting a time delay or event number of 0 will disable the timer. The macro execKillTimer is provided for this purpose.

Calling an already-running timer will restart it with the new time delay value and event.

Note that the timer units are user defined, and depend on the programming of execAppTimerControl and its associated interrupt routine.