COTmrService
Description
This function updates the timer states. The function is used to generate a periodic time base and must be called cyclic.
Prototype
CPU_INT16S COTmrService(CO_TMR *tmr);
Parameter | Description |
---|---|
tmr | Pointer to timer structure |
Returned Value
=0 no timer is elapsed
>0 at least one timer is elapsed
<0 an error is detected
Example
The following interrupt service function generates the time base for the CANopen timed actions with periodic calls of the function COTmrService()
. When using a RTOS, the return value may be used to decide of triggering a separate timer task to process the elapsed events.
void HardwareTimerISR (void) { CPU_INT16S num; num = COTmrService(&AppNode.Tmr); if (num > 0) { /* post an event to the timer processing task */ } }
Note: The configuration setting CO_TMR_TICKS_PER.SEC
is assumed to be 1000, e.g. 1 tick is equal to 1ms. Therefore the hardware timer must be setup to generate an interrupt every 1ms. See CANopen Config Manual for details.