Skip to Content

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.



TIM Get Time block

Table of Contents

Inputs

This block has no inputs.

Outputs

Output NameTypeDescription
TimeDiff [ms]uint32Conditional output
The time difference in milliseconds between successive block executions. This output depends on the Get time difference parameter.
TimeDiff [us]uint32Conditional output
The time difference in microseconds between successive block executions. This output depends on the Get time difference parameter.
Timer counteruint32Conditional output
The current raw value of the timer counter. This output depends on the Enable output tick parameter.

Block Parameters

ParameterDescription
Get time differenceConfigures 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 tickEnables or disables the clock counter output port:
Enable – the output port is enabled.
Disable – the output port is disabled.
TimerConditional 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).

TIM Get Time block


CubeMX Configuration for a Given MCU Model

No.NamePathSettingDescriptionScreenshot
1Timebase sourcePinout & Configuration > System Core > SYS > Timebase SourceBased on user preferenceConditional Parameter
The hardware timer designated as the millisecond timebase source when Get time difference is set to millisecond (user timebase source).
TIM Get Time block
2Clock SourcePinout & Configuration > Timers > TIM* > Clock SourceInternal clockConditional Parameter
The clock source for the timer designated to measure time in microseconds when Get time difference is set to microsecond (use timer).
TIM Get Time block
3Global interrupt / Update interruptPinout & Configuration > TIM* > NVIC Settings > Global interrupt / Update interruptEnabledConditional Parameter
Enables interrupts for the designated timer. Some timers utilize a Global or Update interrupt; one of these options must be enabled.
CubeMX global interrupt
CubeMX update interrupt

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