UM0306 General purpose timer (TIMx)
221/519
13 General purpose timer (TIMx)
13.1 Introduction
The 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 and 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 timers are completely independent, and do not share any resources. They can be
synchronized together as described in Section 13.4.15.
13.2 Main features
General purpose TIMx timer features include:
● 16-bit up, down, up/down auto-reload counter.
● 16-bit programmable prescaler allowing dividing (also “on the fly”) the counter clock
frequency either by any factor between 1 and 65535.
● Up to 4 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 between them.
● Interrupt/DMA generation on the following events:
– Update: counter overflow/underflow, counter initialization (by software or
internal/external trigger)
– Trigger event (counter start, stop, initialization or count by internal/external trigger
– Input capture
– Output compare