5.1.3.2.1. Informational Requirements for the Timer Module

Requirement: label REQ_INT3_1732897578 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Timers in the STM32F411 microcontroller are versatile components used for precise time-related tasks. They help with measuring elapsed time, generating pulses, and controlling time-based processes.

Requirement: label REQ_INT3_1732897596 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The STM32 microcontrollers include general-purpose timers, advanced-control timers (for PWM), and dedicated timers.

Requirement: label REQ_INT3_1732897628 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

General-purpose timers TIM2, TIM3, TIM4, and TIM5 are versatile and support PWM generation, input capture, output compare, and event counting.

Requirement: label REQ_INT3_1732897641 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The advanced-control timer TIM1 is designed for complex tasks like motor control and advanced PWM generation with features like complementary outputs and dead-time insertion.

Requirement: label REQ_INT3_1732897656 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Complementary outputs refer to two outputs that are opposite in polarity, typically used in applications like motor control or H-bridge circuits, where one output is high while the other is low.

Requirement: label REQ_INT3_1732897673 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Dead-time insertion introduces a small delay between switching the complementary outputs to prevent short circuits, ensuring that both outputs are never high simultaneously.

Requirement: label REQ_INT3_1732897701 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Smaller dedicated timers TIM9, TIM10, and TIM11 are used for specific purposes, such as single-channel PWM or precise time-based operations.

Requirement: label REQ_INT3_1732897713 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

In the STM32F411, APB1 timers include TIM2, TIM3, TIM4, and TIM5, operating at a frequency of up to 50 MHz, while APB2 timers include TIM1, TIM9, TIM10, and TIM11, running at a frequency of up to 100 MHz.

Requirement: label REQ_INT3_1732897727 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Each timer has dedicated output pins that support alternate functions for tasks like PWM or input capture.

Requirement: label REQ_INT3_1732897741 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Timer pins are configured for alternate functions using the AF settings in the GPIO registers.

Requirement: label REQ_INT3_1732897783 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Enabling the timer clock for TIM2, TIM3, TIM4, and TIM5 can be done by setting the TIMxEN bit in the RCC_APB1ENR register (‘x’ represents the timer number).

Requirement: label REQ_INT3_1732897798 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Enabling the timer clock for TIM1, TIM9, TIM10, and TIM11 can be done by setting the TIMxEN bit in the RCC_APB2ENR register (‘x’ represents the timer number).

Requirement: label REQ_INT3_1732897825 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM1 has four channels.

Requirement: label REQ_INT3_1732897832 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM1_CH1 is available on pins PA8 and PE9.

Requirement: label REQ_INT3_1732897858 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM1_CH2 is available on pins PA9 and PE11.

Requirement: label REQ_INT3_1732897998 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM1_CH3 is available on pins PA10 and PE13.

Requirement: label REQ_INT3_1732898008 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM1_CH4 is available on pins PA11 and PE14.

Requirement: label REQ_INT3_1732898041 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM2 has four channels.

Requirement: label REQ_INT3_1732898061 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM2_CH1 is available on pins PA0, PA5, and PA15.

Requirement: label REQ_INT3_1732898232 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM2_CH2 is available on pins PA1 and PB3.

Requirement: label REQ_INT3_1732898242 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM2_CH3 is available on pins PA2 and PB10.

Requirement: label REQ_INT3_1732898269 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM2_CH4 is available on pins PA3 and PB11.

Requirement: label REQ_INT3_1732898293 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM3 has four channels.

Requirement: label REQ_INT3_1732898318 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM3_CH1 is available on pins PA6, PB4, and PC6.

Requirement: label REQ_INT3_1732898407 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM3_CH2 is available on pins PA7, PB5, and PC7.

Requirement: label REQ_INT3_1732898417 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM3_CH3 is available on pins PB0 and PC8.

Requirement: label REQ_INT3_1732898436 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM3_CH4 is available on pins PB1 and PC9.

Requirement: label REQ_INT3_1732898513 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM4 has four channels.

Requirement: label REQ_INT3_1732898525 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM4_CH1 is available on pins PB6 and PD12.

Requirement: label REQ_INT3_1732898536 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM4_CH2 is available on pins PB7 and PD13.

Requirement: label REQ_INT3_1732898550 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM4_CH3 is available on pins PB8 and PD14.

Requirement: label REQ_INT3_1732898597 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM4_CH4 is available on pins PB9 and PD15.

Requirement: label REQ_INT3_1732898631 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM5 has four channels.

Requirement: label REQ_INT3_1732898653 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM5_CH1 is available on pin PA0.

Requirement: label REQ_INT3_1732898686 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM5_CH2 is available on pin PA1.

Requirement: label REQ_INT3_1732898690 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM5_CH3 is available on pin PA2.

Requirement: label REQ_INT3_1732898715 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM5_CH4 is available on pin PA3.

Requirement: label REQ_INT3_1732898740 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM9 has two channels.

Requirement: label REQ_INT3_1732898755 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM9_CH1 is available on pins PA2 and PE5.

Requirement: label REQ_INT3_1732898773 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM9_CH2 is available on pins PA3 and PE6.

Requirement: label REQ_INT3_1732898806 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM10 has one channel.

Requirement: label REQ_INT3_1732898818 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM10_CH1 is available on pin PB8.

Requirement: label REQ_INT3_1732898832 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM11 has one channel.

Requirement: label REQ_INT3_1732898842 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM11_CH1 is available on pin PB9.

Requirement: label REQ_INT3_1732899018 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Each timer in the STM32F411 can have up to two Capture/Compare Mode Registers (CCMRs), depending on how many channels the timer supports.

Requirement: label REQ_INT3_1732899027 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The TIMx_CCMR1 register is used to configure channels 1 and 2. (‘x’ represents the timer number)

Requirement: label REQ_INT3_1732899023 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The TIMx_CCMR2 register is responsible for configuring channels 3 and 4. (‘x’ represents the timer number)

Requirement: label REQ_INT3_1732899087 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The CCMR register configures the timer channels, including PWM mode, output compare settings, and capture/compare functionality.

Requirement: label REQ_INT3_1732899073 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The TIMx_CCMRy register bits include OCxM (output compare mode) and OCxPE (preload enable).(‘x’ represents the timer number, ‘y’ depends on the channel)

Requirement: label REQ_INT3_1732899068 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Pulse Width Modulation (PWM) is a technique for generating variable output signals by modifying the duty cycle. In STM32F411, PWM signals are created using timers, which control the output on specific GPIO pins.

Requirement: label REQ_INT3_1732899062 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Duty Cycle is the percentage of time the signal remains high during one cycle. For instance, a 50% duty cycle means the signal is high for half of its period.

Requirement: label REQ_INT3_1732899058 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Frequency defines how many times the PWM signal cycles from high to low per second.

Requirement: label REQ_INT3_1732899054 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Period defines the length of time for one full cycle of the signal — from the start of one pulse to the start of the next pulse.

Requirement: label REQ_INT3_1732899218 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

PWM generation can use different modes, such as edge-aligned or center-aligned mode, typically configured using advanced-control timers like TIM1.

Requirement: label REQ_INT3_1732899229 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The center-aligned mode is a timer mode used to generate a symmetric PWM signal. In this mode, the timer counts up to a specified value and then counts back down, completing a full cycle within the PWM period.

Requirement: label REQ_INT3_1732899244 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The edge-aligned mode is a timer mode used to generate a standard PWM signal. In this mode, the timer counts in a single direction (either up or down) during the PWM period.

Requirement: label REQ_INT3_1732899288 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

To set the PWM frequency, the prescaler and ARR registers need to be configured. These two parameters together define the period and frequency of the PWM signal.

Requirement: label REQ_INT3_1732899281 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The timer frequency depends on the APB bus the timer is on (either 50 MHz or 100 MHz).

Requirement: label REQ_INT3_1732899273 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The period of the PWM signal is calculated by dividing the timer frequency by the desired PWM signal frequency. Period = Timer Frequency / Desired Frequency.

Requirement: label REQ_INT3_1732899266 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The prescaler reduces the timer frequency to ensure the PWM signal period falls within the valid range of 0 to 65535 for a 16-bit timer.

Requirement: label REQ_INT3_1732899259 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

ARR is the Auto-Reload Register value that determines the timer period.

Requirement: label REQ_INT3_1732899328 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The formula for calculating the prescaler: Prescaler = Timer Frequency / (Desired Frequency * Max ARR). Where Max ARR is 65535.

Requirement: label REQ_INT3_1732902472 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The prescaler can be set between 0 and 65535.

Requirement: label REQ_INT3_1732899344 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The ARR value is calculated using the formula: ARR = [Timer Frequency / (Desired Frequency * Prescaler) ] − 1.

Requirement: label REQ_INT3_1732902534 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The ARR value can be set between 0 and 65535 (for a 16-bit timer).

Requirement: label REQ_INT3_1732899371 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Prescaler Register (TIMx_PSC) stores the calculated prescaler value. (‘x’ represents the timer number)

Requirement: label REQ_INT3_1732899364 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

Auto-Reload Register (TIMx_ARR) stores the calculated ARR value. (‘x’ represents the timer number)

Requirement: label REQ_INT3_1732899356 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The CCR (Capture/Compare Register) determines the duty cycle of the PWM signal.

Requirement: label REQ_INT3_1732899353 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The CCR (Capture/Compare Register) value is calculated as: CCR = [Duty Cycle * (ARR+1)] / 100.

Requirement: label REQ_INT3_1732899348 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The calculated CCR value is written into the corresponding TIMx_CCRy register. ( ‘x’ represents the timer number, ‘y’ is the channel number)

Requirement: label REQ_INT3_1732899403 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The TIMx_CR1 register is the main control register for configuring and controlling the timer’s behavior. (‘x’ represents the timer number)

Requirement: label REQ_INT3_1732899412 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIMx_CR1_CEN (Counter Enable) bit controls whether the timer is running or stopped. (‘x’ represents the timer number)

Requirement: label REQ_INT3_1732899426 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

CCER (Capture/Compare Enable Register) register enables the activation of channels for output functionality.

Requirement: label REQ_INT3_1732899438 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

The CCER register determines the operating mode of the channel, such as PWM, input capture, or output signal for time measurement.

Requirement: label REQ_INT3_1732899398 ../../../../../_images/arrow-right-circle.svg
status: Draft
style: red_bar
category: Informational
priority: Low

TIM_CCER_CCyE bit is used to enable the timer channels for output. (‘y’ represents the channel number)