MotoHawk Free Running Timer: Difference between revisions

From NewEagleWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:
SystemClockTicks 2317445755
SystemClockTicks 2317445755


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

Revision as of 18:28, 19 December 2011

The Free Running Timer is a way to access the 32 bit system clock. The attached model uses an internal API (Timer_FreeRunningCoutner_Get32Bits()) and loads the result into a MotoHawk Data Store. There are two things to keep in mind: 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. Secondly, no protection for roll over 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 MotoHawk_Abs_Time lock is it allows a 10X speed increase (17µsec/call --> now 1.5 µsec/call). It saves 1ms execution time with 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: ::*Free Running Timer.