Skip to Content
Block descriptionsTIMTIM Capture

TIM Capture Block Description

This block enables PWM signal measurement using the TIM peripheral in STM microcontrollers.



TIM Capture block

Table of Contents

Inputs

This block has no inputs.

Outputs

Output NameTypeDescription
New data CH*uint8New measurement from channel CH*. Returns:
1 new measurement available
0 no new measurement
Duty CH*doubleDuty cycle of the PWM signal on channel CH*.
Period CH* [sec]doublePeriod of the PWM signal on channel CH*.

CH* - the * symbol in the output name represents the channel number configured in the block parameters. Depending on the block settings, multiple outputs may exist for different channels.

Block Parameters

ParameterDescription
TimerThe timer number that will be used to measure the PWM signal.
Timer clock (MHz)The timer clock frequency in MHz set within the CubeMX file.
PrescalerThe timer prescaler value. This parameter can be configured inside the block instead of the CubeMX configuration.
Show signal propertiesEnables the display of timer properties to facilitate correct calculations.

TIM Capture block


ParameterDescription
Combined channelsConfigures combined channels for full PWM signal measurement:
(Disable) - option is disabled
PWM input on CH1 - measured PWM signal input on channel CH1
PWM input on CH2 - measured PWM signal input on channel CH2
CHANNEL_*Timer channel configuration for PWM signal measurement (PWM Input mode):
Disable – channel is disabled
Input capture direct mode – direct mode; the PWM signal is connected to the physical pin associated with this channel (e.g., CH1 for IC1)
Input capture indirect mode – indirect mode; the channel measures the signal routed internally from the adjacent pin (e.g., CH2 for IC1)

CHANNEL_* - the * symbol in the parameter name represents the channel number configured in the block parameters. Depending on the block settings, multiple parameters may exist for different channels.



Block parameters for TIM Capture

CubeMX Configuration for a Given MCU Model

CubeMX Settings

No.NamePathSettingDescriptionScreenshot
1Clock SourcePinout & Configuration > TIM* > Mode > Clock SourceInternal ClockSelects the clock source for the timer.CubeMX clock source
2Channel* / Combined Channels ConfigurationPinout & Configuration > TIM* > Mode > Channel* / Combined ChannelsSetting matching the block parameters configurationSelects the timer channel operating mode or configures the Combined Channels option. These options are mutually exclusive.CubeMX channel configuration
CubeMX combined channels
3Global interrupt / Update interruptPinout & Configuration > TIM* > NVIC Settings > Global interrupt / Update interruptEnabledEnables timer interrupts. Some timers feature a Global or Update interrupt; one of these options must be enabled.CubeMX global interrupt
CubeMX update interrupt
4Polarity SelectionPinout & Configuration > TIM* > Parameter Settings > PWM Input CH* > Polarity SelectionDirect channel as Rising Edge, indirect channel as Falling EdgeConditional setting
When Combined Channels mode is selected, the polarity of the Direct channel should be set to Rising Edge, and the indirect channel to Falling Edge.
CubeMX polarity

TIM* / Channel* - the * symbol in the parameter name represents the timer or channel number configured in the block parameters. Depending on the block settings, multiple parameters may exist for different timers or channels.

See Also

Last updated on