1.2.11.4.10 SYS_TIME_CounterGet Function

C

uint32_t SYS_TIME_CounterGet ( void )

Summary

Get the common 32-bit system counter value.

Description

Returns the current "live" value of the common 32-bit system counter.

Precondition

The SYS_TIME_Initialize function should have been called before calling this function.

Parameters

None

Returns

The current "live" value of the common 32-bit system counter.

Example

uint32_t timeStamp1;
uint32_t timeStamp2;
uint32_t timeDiffMs;

// Take first time stamp
timeStamp1 = SYS_TIME_CounterGet();

//Perform some tasks....

// Take second time stamp
timeStamp2 = SYS_TIME_CounterGet();

//Calculate the time difference. Use the appropriate function -
//SYS_TIME_CountToMS or SYS_TIME_CountToUS to calculate the time difference.

timeDiffMs = SYS_TIME_CountToMS((timeStamp2 - timeStamp1));

Remarks

The value returned may be stale as soon as it is provided, as the timer is live and running at full frequency resolution (as configured and as reported by the SYS_TIME_FrequencyGet function). If additional accuracy is required, use a hardware timer instance.