MotoHawk Free Running Timer

From NewEagleWiki
Jump to navigation Jump to search

The Free Running Timer is a way to access the 32-bit system clock. The attached model uses an internal API (Timer_FreeRunningCounter_Get32Bits()) and loads the result into a MotoHawk Data Store. There are two things to keep in mind: First, the system clock tick will roll over faster than the max size of a 32-bit integer, so the value will never count as high as 0xFFFFFFFF micro-seconds. Second, no protection for rollover is implied in this sample, so that should be taken into account if you would like to use this mechanism.

The reason to use code instead of the MotoHawk_Abs_Time lock is it allows a 10X speed increase (17µsec/call --> now 1.5 µsec/call). It saves 1ms of execution time every 80 instances in a model. Here is a sample of the VarDecs you see in MotoTune from this model:

Abs_Time_Value 2023331

Abs_Time_Value_Delta 5001

Faster_FreeRunning_Time_Value 28963072

Faster_FreeRunning_Time_Value_Delta 5000

SystemClockTicks 2317445755

The example model of how to use Free Running Timer is located here: http://www.neweagle.net/support/wiki/files/FreeRunningTimer.zip .