- Last edited 75 days ago
TIM internal peripheral
1 Article purpose
The purpose of this article is to
- briefly introduce the TIM peripheral and its main features
- indicate the level of security supported by this hardware block
- explain how each instance can be allocated to the three runtime contexts and linked to the corresponding software components
- explain how to configure the TIM peripheral
2 Peripheral overview
The TIM peripheral is a multi-channel timer unit, available in various configurations, depending on the instance used. There are basically following categories: advanced-control timers, general-purpose timers and basic timers.
The TIM can provide: PWM with complementary output and dead-time insertion, break detection, input capture, quadrature encoder interface (typically used for rotary encoders), trigger source for other internal peripherals like: ADC, DAC, DFSDM.
The TIM peripheral is available in different configurations, depending on the selected instance :
- TIM1 and TIM8 are advanced-control timers, with 6 independent channels.
- TIM2, TIM3, TIM4 and TIM5 are general-purpose timers, with 4 independent channels.
- TIM12, TIM13 and TIM14 are general-purpose timers, with 2 (TIM12) or 1 (TIM13 and TIM14) independent channels.
- TIM15, TIM16 and TIM17 are also general-purpose timers, with 2 (TIM15) or 1 (TIM16 and TIM17) independent channels. Compare to TIM12, TIM13 and TIM14, this configuration brings some features that are very useful for motor control (like break function, DMA burst mode control, complementary output with dead-time insertion, ...)
- TIM6 and TIM7 are basic timers
Refer to STM32MP15 reference manuals for the complete list of features, and to the software components, introduced below, to know which features are really implemented.
2.2 Security support
The TIM is a non-secure peripheral.
3 Peripheral usage and associated software
3.1 Boot time
The TIM is not used at boot time.
TIM12 and/or TIM15 can be allocated to:
- the Arm® Cortex®-A7 secure core to be controlled in the secure monitor (TF-A or OP-TEE), to perform HSI and CSI calibrations in RCC.
All TIM instances can be allocated to:
- the Arm® Cortex®-M4 to be controlled in STM32Cube MPU Package by TIM HAL driver
Note that RCC owns one prescaler per TIM group corresponding to APB1 and APB2 buses: TIMG1PRE and TIMG2PRE, respectively. The allocation to Cortex-A7 or the Cortex-M4 should ideally be done on a per group basis to get independent clocking setup on each side, this is why the TIM instances groups are shown in the summary table below (#Peripheral assignment).
3.2.2 Software frameworks
|Core/Timers||TIM||TF-A TIM driver
OP-TEE TIM driver
|Linux PWM framework
Linux IIO framework
|STM32Cube TIM driver|
3.2.3 Peripheral configuration
The configuration is applied by the firmware running in the context to which the peripheral is assigned. The configuration by itself can be performed via the STM32CubeMX tool for all internal peripherals. It can then be manually completed (especially for external peripherals) according to the information given in the corresponding software framework article.
3.2.4 Peripheral assignment
Check boxes illustrate the possible peripheral allocations supported by STM32 MPU Embedded Software:
- ☐ means that the peripheral can be assigned (☑) to the given runtime context.
- ✓ is used for system peripherals that cannot be unchecked because they are statically connected in the device.
Refer to How to assign an internal peripheral to a runtime context for more information on how to assign peripherals manually or via STM32CubeMX.
The present chapter describes STMicroelectronics recommendations or choice of implementation. Additional possiblities might be described in STM32MP15 reference manuals.
|Core/Timers||TIM||TIM1 (APB2 group)||☐||☐||Assignment (single choice)|
|TIM2 (APB1 group)||☐||☐||Assignment (single choice)|
|TIM3 (APB1 group)||☐||☐||Assignment (single choice)|
|TIM4 (APB1 group)||☐||☐||Assignment (single choice)|
|TIM5 (APB1 group)||☐||☐||Assignment (single choice)|
|TIM6 (APB1 group)||☐||☐||Assignment (single choice)|
|TIM7 (APB1 group)||☐||☐||Assignment (single choice)|
|TIM8 (APB2 group)||☐||☐||Assignment (single choice)|
|TIM12 (APB1 group)||☐||☐||☐||Assignment (single choice)|
|TIM13 (APB1 group)||☐||☐||Assignment (single choice)|
|TIM14 (APB1 group)||☐||☐||Assignment (single choice)|
|TIM15 (APB2 group)||☐||☐||☐||Assignment (single choice)|
|TIM16 (APB2 group)||☐||☐||Assignment (single choice)|
|TIM17 (APB2 group)||☐||☐||Assignment (single choice)|
4 How to go further
STM32 cross-series timer overview application note.