Get system time resolved to microseconds.

unsigned long RTX_GetTick_us (void);

Return Value

System time in microseconds


This function converts the high resolution system time data collected by the RTX_GetFineTick API to microseconds and returns this unsigned long 32 bit count value.

Note that this count rolls over to zero after each 2**32 microseconds of operation, which is about 71.582 minutes.

If the RTX_FineTickInit API has not been called, then this call will be made here one time.   (This initialization function is also called if the lower power mode of operation has been changed.)   Making this additional API call is time consuming and results in the interrupts being enabled.   Therefore calling RTX_FineTickInit prior to using this API may be advisable for time critical applications.

Once this initialization has been handled by the RTX_FineTickInit API, this RTX_GetTick_us() API function is then suitable for use within an Interrupt Service Routine.   Interrupts are masked here and then restored to their state on entry.   Note that no call into the @Chip-RTOS API is required by this API following the initialization step.

Refer to RTX_GetFineTick description for more details.

SC1x3/SC2x Comments


If the system's real-time interrupt has been configured for kHz rates which do not divide into 1000 an integral number of times, then this API is inaccurate due to fixed point arithmetic truncation problems and therefore should not be used.   The problem arises with the _us_per_RTI constant used here, computed as:

    _us_per_RTI = 1000 / _RTI_kHz

So for RTI rates like 15 kHz this integer arithmetic truncates and the results from this API are not accurate.

The following RTI settings allow this API to function:

    [1, 2, 4, 5, 8, 10, 20, 25, 40, 50]

Any RTI settings from the following set will cause this API to not work properly :

    [3, 6, 12, 15, 16, 24, 30, 32, 48]

See Also


After RTX_FineTickInit has been invoked a single time, this library function makes no entry into the RTOS.

Related Topics

RTX API   Overview

Supported since or modified in @CHIP-RTOS version


Supported by @CHIP-RTOS C Library since version


This API List
List of C Libraries
@CHIP-RTOS Main Index

End of document