MotoHawk Free Running Timer: Difference between revisions

From NewEagleWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
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 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 execution time with 80 instances in a model.  
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:
Here is a sample of the VarDecs you see in MotoTune from this model:


Line 14: Line 14:
SystemClockTicks 2317445755
SystemClockTicks 2317445755


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]'''.
The example model of how to use Free Running Timer is located here: http://www.neweagle.net/support/wiki/files/FreeRunningTimer.zip .

Latest revision as of 17:46, 2 March 2023

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 .