![]() |
CANopen Master Protocol Stack
Version 7.00.02
|
There are a number of CANopen services which require an internal timer (e.g. Heartbeat, timer-driven PDO). The timer values for these services are set in a multiple of 1 microsecond or 1 millisecond (depends on the service).
The stack works internally with timer ticks. The duration of one timer tick equals the configured timer period, which is expressed in microseconds and defined by COM_TIMER_PERIOD inside the com_conf.h file. The default value is 1000 microseconds (1 millisecond). This default is applied during ComMgrInit().
The timer period can be read at run-time with ComTmrGetPeriod() and changed with ComTmrSetPeriod(). The requested time values are converted into timer ticks and vice versa with the functions ComTmrCalcTicks() and ComTmrCalcTime() respectively.
Functions | |
| uint32_t | ComTmrCalcTicks (uint32_t ulReqTimingV) |
| uint32_t | ComTmrCalcTime (uint32_t ulTicksV) |
| uint32_t | ComTmrGetPeriod (void) |
| void | ComTmrSetPeriod (uint32_t ulPeriodV) |
| uint32_t ComTmrCalcTicks | ( | uint32_t | ulReqTimingV | ) |
| [in] | ulReqTimingV | requested time in microseconds |
The function calculates the number of required timer ticks based on the required time ulReqTimingV (in microseconds) and the current timer period (see ComTmrGetPeriod()). The result is rounded to the nearest tick.
| uint32_t ComTmrCalcTime | ( | uint32_t | ulTicksV | ) |
| [in] | ulTicksV | number of timer ticks |
The function calculates the time (in microseconds) based on the given number of timer ticks and the currently configured timer period (see ComTmrGetPeriod()).
| uint32_t ComTmrGetPeriod | ( | void | ) |
The function returns the current configured timer period in microseconds.
| void ComTmrSetPeriod | ( | uint32_t | ulPeriodV | ) |
| [in] | ulPeriodV | timer period in microseconds |
The function sets the timer period which is used to call the function ComMgrTimerEvent(). The parameter ulPeriodV is a multiple of 1 microsecond. The default value of the timer period is defined by the constant value COM_TIMER_PERIOD, which is applied by ComMgrInit(). This function can be used to override the default value at run-time.
If ulPeriodV is 0, the function has no effect and the current period is retained.