RM0367 Rev 7 547/1043
RM0367 General-purpose timers (TIM21/22)
601
22 General-purpose timers (TIM21/22)
22.1 Introduction
The TIM21/22 general-purpose timers consist of a 16-bit auto-reload counter driven by a
programmable prescaler.
They may be used for a variety of purposes, including measuring the pulse lengths of input
signals (input capture) or generating output waveforms (output compare, PWM).
Pulse lengths and waveform periods can be modulated from a few microseconds to several
milliseconds using the timer prescaler and the RCC clock controller prescalers.
The TIM21/22 timers are completely independent, and do not share any resources. They
can be synchronized together as described in Section 22.3.14.
22.2 TIM21/22 main features
22.2.1 TIM21/22 main features
The features of the TIM21/22 general-purpose timers include:
• 16-bit up, down, up/down, auto-reload counter
• 16-bit programmable prescaler used to divide the counter clock frequency by any factor
between 1 and 65535 (can be changed “on the fly”)
• Up to 2 independent channels for:
– Input capture
– Output compare
– PWM generation (edge- and center-aligned mode)
– One-pulse mode output
• Synchronization circuit to control the timer with external signals and to interconnect
several timers together
• Interrupt generation on the following events:
– Update: counter overflow/underflow, counter initialization (by software or internal
trigger)
– Trigger event (counter start, stop, initialization or count by internal trigger)
– Input capture
– Output compare