July 2016 DocID022500 Rev 6 1/39
1
AN4013
Application note
STM32 cross-series timer overview
Introduction
The purpose of this document is detailed hereafter:
Present an overview of the timer peripherals in the STM32 product series detailed in
Table 1.
Describe the various modes and specific features of the timers, such as clock sources.
Explain how to use the available modes and features.
Explain how to compute the time base in each configuration.
Describe the timer synchronization sequences and the advanced features for motor
control applications, in addition to the general-purpose timer modes.
For each mode, typical configurations are presented and examples of how to use the modes
are provided.
In the rest of this document (unless otherwise specified), the term STM32xx is used to refer
to the products listed in Table 1.
Table 1. Applicable products
Type Product series
Microcontrollers
STM32F0 Series, STM32F1 Series, STM32F2 Series, STM32F3 Series,
STM32F4 Series, STM32F7 Series, STM32L0 Series, STM32L1 Series,
STM32L4 Series
www.st.com
Contents AN4013
2/39 DocID022500 Rev 6
Contents
1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 General-purpose timer modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1 Clock input sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.1 Internal clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.2 External clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Time base generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3 Timer input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Timer output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.5 Timer PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.6 Timer one pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.7 Timer Asymmetric PWM mode available for
STM32L4/F7 Series and STM32F30x/F3x8 lines . . . . . . . . . . . . . . . . . . 15
2.8 Timer combined PWM mode available for
STM32L4/F7 Series and STM32F30x/F3x8 lines . . . . . . . . . . . . . . . . . . 17
2.9 Retriggerable one pulse mode available for
STM32L4/F7 Series and STM32F30x/F3x8 lines . . . . . . . . . . . . . . . . . . 18
3 Timer synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.1 Timer system link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 Master configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3 Slave configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4 Advanced features for motor control . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1 Signal generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2 Combined three-phase PWM mode available for
STM32L4/F7 Series and STM32F30x/F3x8 lines . . . . . . . . . . . . . . . . . . 25
4.3 Specific features for motor control applications . . . . . . . . . . . . . . . . . . . . 26
4.3.1 Complementary signal and dead time feature . . . . . . . . . . . . . . . . . . . . 26
4.3.2 Break input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3.3 Locking mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.3.4 Specific features for feedback measurement . . . . . . . . . . . . . . . . . . . . . 29
5 High-resolution timer applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33