Jump to content

Component: Timer (Timing)

From Flowcode Help
Revision as of 14:15, 13 July 2026 by SteveT (talk | contribs) (Text replacement - "class="wikitable" style="width:60%; background-color:#FFFFFF;"" to "class="mtx-class-macrotable wikitable"")
Author Matrix TSL
Version 14.0
Category Timing


Timer component

Allows you to measure the passage of time via the use of a hardware timer peripheral. Works like a stopwatch with macros to start, stop and reset the timer counter. Returns time as integer Seconds, Milliseconds, Microseconds and also Floating Point and String.

Version information

Library Version, Component Version, Date, Author, Info
14, 14.0, 10-07-24, MW, Fixed a bug to reset simulation timer value when TimerReset() is called
18, 14.0, 07-02-25, BR, Hidden Postscaler property as it will cause issues with reported timings if used
19, 14.0, 07-02-25, BR, Changed default to TMR0 with 1:1 prescaler
20, 14.0, 07-02-25, BR, Added timer resolution property to show what resolution of timings can be acheived
21, 14.0, 07-02-25, BR, Hidden some of the less useful properties from the user
22, 14.0, 07-02-25, BR, Fixed a bug where the timer wouldn't correctly report the time when stopped


Detailed description

No detailed description exists yet for this component

Examples

Here is a basic example showing the operation of the timer component used to time a section of code or the duration of a specific event.

Timer Example

Macro reference

GetCountMicroSeconds

GetCountMicroSeconds
Returns the count value as a number of whole microseconds, rounded down to the nearest microsecond 
- ULONG Return


GetCountMilliseconds

GetCountMilliseconds
Returns the count value as a number of whole milliseconds, rounded down to the nearest millisecond 
- ULONG Return


GetCountReal

GetCountReal
Returns the count value as a floating point value in seconds. 
- FLOAT Return


GetCountSeconds

GetCountSeconds
Returns the count value as a number of whole seconds, rounded down to the nearest second 
- ULONG Return


GetCountString

GetCountString
Returns the count value as a floating point string in seconds. 
- BYTE Precision
Number of decimal places to display in string 
- STRING Return


GetRawCount

GetRawCount
Efficient command to collect the integer number of instructions since the timer was started. 
- ULONG Return


ResetCounter

ResetCounter
 
- VOID Return


StartCounter

StartCounter
Starts the timer counting. 
- BOOL ResetCounters
Range: 0-1 where 0=Do Not Reset and 1=Reset 
- VOID Return


StopCounter

StopCounter
Stops the timer counting. 
- VOID Return


Property reference

Properties
Timer
Timer Peripheral to use to monitor the passage of time. 
Prescaler
 
Bit Depth
Number of bits in the timer peripheral. 8-bit timers can count from 0-255 before overflowing. 16-bit timers can count from 0 to 65535 before overflowing. 
Instruction Rate
 
Timer Resolution (ms)
 
Max Time Measurement (s)
Max time in seconds that we can measure before rolling over and starting again. 
Simulation
Timer Delay (ms)
Number of milliseconds between timer events which increment the simulated timer counter variable. 10ms will yield the highest resolution. Values less than this will likely just increase the error and making the timer run slow. Higher delays will yield greater accuracy. 
Decimal Points
 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_TimerComponent.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_TimerComponent.fcfx