td_get_otm

Get System Operating Time

[C Language Interface]

ER ercd = td_get_otm ( SYSTIM *tim, UINT *ofs ) ;

[Parameters]

SYSTIM* tim Packet address for returning operating time (ms)

UNIT* ofs Location for returning elapsed time from tim (nanoseconds)

[Return Parameters]

ER ercd Error code

tim detail:

Operating time (ms)

ofs detail:

Elapsed time from tim (nanoseconds)

[Error Codes]

E_OK Normal completion

[Description]

Gets the system operating time (uptime, as elapsed milliseconds since the system was booted). The value returned in tim is the same as that obtained by tk_get_otm. tim is the resolution of time interrupt intervals (cycles), but even more precise time information is obtained in ofs as the elapsed time from tim in nanoseconds. The resolution of ofs is implementation-dependent, but generally is the timer hardware resolution.

Since tim is time counted based on timer interrupts, in some cases time is not refreshed, when a timer interrupt cycle arrives while interrupts are disabled and the timer interrupt handler is not started (is delayed). In such cases, the time as updated by the previous timer interrupt is returned in tim, and the elapsed time from the previous timer interrupt is returned in ofs. Accordingly, in some cases ofs will be a longer time than the timer interrupt cycle. The length of elapsed time that can be measured by ofs depends on the hardware, but preferably it should be able to measure at least up to twice the timer interrupt cycle (0 . ofs < twice the timer interrupt cycle).

Note that the time returned in tim and ofs is the time at some point between the calling of and return from td_get_otm. It is neither the time at which td_get_otm was called nor the time of return from td_get_otm. In order to obtain more accurate information, this function should be called in interrupts disabled state.

Comments