TIM Get Time Block Description
This block enables the measurement of execution time differences between successive block invocations and reads the current timer counter value in STM microcontrollers.

Table of Contents
Inputs
This block has no inputs.
Outputs
| Output Name | Type | Description |
|---|---|---|
| TimeDiff [ms] | uint32 | Conditional output The time difference in milliseconds between successive block executions. This output depends on the Get time difference parameter. |
| TimeDiff [us] | uint32 | Conditional output The time difference in microseconds between successive block executions. This output depends on the Get time difference parameter. |
| Timer counter | uint32 | Conditional output The current raw value of the timer counter. This output depends on the Enable output tick parameter. |
Block Parameters
| Parameter | Description |
|---|---|
| Get time difference | Configures the source for the time difference calculation:millisecond (user timebase source) – time is returned in milliseconds, measured by the timer specified as the Timebase source in the CubeMX configuration file.microsecond (use timer) – time is returned in microseconds, measured by the user-defined timer specified in the Timer parameter. |
| Enable output tick | Enables or disables the clock counter output port:Enable – the output port is enabled.Disable – the output port is disabled. |
| Timer | Conditional Parameter Selects the specific timer hardware used to track the elapsed time. This parameter is accessible when Get time difference is set to microsecond (use timer). |
| Timer clock [MHz] | Conditional Parameter The clock frequency of the selected timer used for tracking time. This parameter is accessible when Get time difference is set to microsecond (use timer). |

CubeMX Configuration for a Given MCU Model
H7
| No. | Name | Path | Setting | Description | Screenshot |
|---|---|---|---|---|---|
| 1 | Timebase source | Pinout & Configuration > System Core > SYS > Timebase Source | Based on user preference | Conditional Parameter The hardware timer designated as the millisecond timebase source when Get time difference is set to millisecond (user timebase source). | ![]() |
| 2 | Clock Source | Pinout & Configuration > Timers > TIM* > Clock Source | Internal clock | Conditional Parameter The clock source for the timer designated to measure time in microseconds when Get time difference is set to microsecond (use timer). | ![]() |
| 3 | Global interrupt / Update interrupt | Pinout & Configuration > TIM* > NVIC Settings > Global interrupt / Update interrupt | Enabled | Conditional Parameter Enables interrupts for the designated timer. Some timers utilize a Global or Update interrupt; one of these options must be enabled. | ![]() ![]() |
TIM* / Channel* - the * symbol in the parameter name denotes the specific timer or channel number configured within the block parameters. Depending on your model configuration, multiple parameters might exist for different timers or channels.
See Also
Last updated on



