STM32 Timer Types: Basic, General-Purpose, and Advanced Timers

STM32 devices contain several kinds of timers, and each kind can do different things. In the previous article, the STM32 Timers Complete Guide, we saw how a timer works. A clock signal goes through a prescaler, a counter counts up to the auto-reload value, and an update event happens when the counter returns to zero. Every timer works this way, but not every timer has the same features. When you look at a datasheet, you will see names like TIM1, TIM2, and TIM6. Some of these timers can only count time, while others can also generate PWM, measure pulses, and drive motors.

If you pick a timer without knowing these differences, you may find that it does not have the channel, the pin, or the feature you need. Knowing the three timer types first makes this choice easy, and it also makes the timer section of a datasheet simpler to read.

In this article, we will first see why STM32 has different timer types. Then we will look at the basic, general-purpose, and advanced-control timers one by one, along with what each one can do and where it is used. After that, we will compare all three types in a single table. At the end, we will see how to find the timers of your own device using the datasheet, the reference manual, and STM32CubeMX.

The examples in this article use the STM32F4 series and the NUCLEO-F446RE board. Timers are not the same on every STM32 family or device, so any feature that is not available everywhere is marked as device-dependent. This article is part of the STM32 timer tutorial series.

Why STM32 Has Different Timer Types

Every feature inside a timer takes space on the chip. The counter, the prescaler, and the auto-reload register are small. Each capture/compare channel needs its own register, a comparator, an input filter, and an output stage. Complementary outputs, dead time, and break logic need even more circuits. If every timer had all of these features, the chip would be bigger and more expensive, and most of the extra hardware would never be used.

For this reason, ST puts a few full-featured timers and many simple timers in each device. Each timer is made for a certain kind of work. A periodic interrupt that runs a task every millisecond needs only a counter and an update event, and it does not need a pin. A PWM output or a pulse measurement needs channels that are connected to pins. A motor driver needs those channels and also needs protection features that work in hardware when something goes wrong. The three timer types match these three levels of need.

The diagram below shows how the types are built on top of each other. The counter core in the middle is present in every timer, and each larger type contains everything from the smaller type plus some extra circuits.

STM32 timer types diagram showing a basic timer core inside general-purpose and advanced-control timers

Because all three types use the same counter core, everything you learned about the prescaler, the auto-reload register, and the update event applies to every timer. Only the extra parts around the counter are different.


STM32 Basic Timers

Basic timers are the simplest timers in the STM32 family. On the STM32F446, these are TIM6 and TIM7. A basic timer has a 16-bit counter, a 16-bit prescaler, and an auto-reload register, and it has nothing more. It always counts up, and it uses only the internal timer clock.

Main Capabilities

The main job of a basic timer is to create a time base. The counter runs at a speed set by the prescaler, and each time it reaches the auto-reload value, the timer creates an update event. This event can raise an interrupt, send a request to the DMA controller, or go out as a trigger signal called TRGO. The time between two update events follows the same formula as in the previous article, which is:

The DMA request and the trigger output make a basic timer more useful than a plain interrupt source. On the STM32F4 series, the TRGO signal of TIM6 and TIM7 is mainly used to start DAC conversions at a fixed rate. This lets the DAC play a waveform or audio samples without any help from the CPU. On some other families, the same signal can also start an ADC conversion or another peripheral, so the list of possible targets depends on the device. The DMA request can move data to a peripheral at the same fixed rate. You should always check the exact connections in the reference manual of your device.

Basic STM32 timer block diagram with clock, prescaler, counter, auto-reload, update event, and interrupt, DMA, and TRGO outputs

A basic timer has no capture/compare channels and no pins. This means it cannot generate PWM, it cannot measure the width of an input pulse, and it cannot compare the counter with several values. Those functions belong to general-purpose timers, and this is the most important limit to remember about basic timers.

STM32CubeMX configuration of basic timer TIM6 with only the Activated option and no channels

Typical Applications

Basic timers are used when you need a steady time reference and no pin. The most common use is a periodic interrupt that runs a task at a fixed interval, such as reading a sensor, running a small scheduler, or counting a timeout. A basic timer is also a good trigger source for a DAC or another peripheral, because it leaves the more capable timers free for work that needs pins.

Another benefit is that a basic timer can be reserved for the RTOS tick or for the HAL time base. Since it has no channels, you will not block a PWM output or a capture input that you may need later. Keep in mind that basic timers do not have the channel-based capture and compare functions of general-purpose timers, so a project that needs PWM or pulse measurement must use a different timer.


STM32 General-Purpose Timers

General-purpose timers are the most commonly used timers in the STM32 family, and they cover most of what normal projects need. On the STM32F446, this group includes TIM2 to TIM5 and TIM9 to TIM14. They have the same counter core as a basic timer, and they add capture/compare channels that connect the counter to the pins of the device.

Main Capabilities

Counter Width and Counting Modes

The timers TIM2 to TIM5 are the full-featured members of this group. They can count up, count down, or count up and down in a center-aligned mode, which is useful for symmetrical PWM signals. On the STM32F4 series, TIM2 and TIM5 have a 32-bit counter, while TIM3 and TIM4 have a 16-bit counter. A 32-bit counter can measure long times at a high resolution without worrying about counter overflow, which helps with timestamps and slow signals. The counter width depends on the device, so you should always check it for the timer you plan to use.

The timers TIM9 to TIM14 are simpler versions for smaller tasks. They have only one or two channels, they count up only, and their synchronization options are limited. They are still general-purpose timers, and they are a good choice when you need a simple PWM output or a periodic interrupt and the full-featured timers are already in use. The exact set of simple timers differs between families.


Capture/Compare Channels

The main feature of a general-purpose timer is the capture/compare channel. Each channel has its own capture/compare register, and it can work as an output or as an input. As an output, the timer compares the counter with the register value and changes the pin state when the two values match. This is the basis of output compare and PWM, where the compare value sets the duty cycle. As an input, an edge on the pin copies the current counter value into the register. This is the basis of input capture, and it lets you measure periods and pulse widths.

General-purpose timer diagram with a counter, four capture/compare registers, and four channel pins

The number of channels depends on the timer and on the device. TIM2 to TIM5 have four channels, and the simple timers have one or two. The pin of each channel is selected with the alternate function mechanism from the alternate function article, so the pins you can use also depend on the device and the package.


Encoder and Synchronization Features

The full-featured general-purpose timers also have an encoder interface. In this mode, the timer reads the two signals of a quadrature encoder and counts up or down depending on the direction of rotation. The counter value then shows the position of the shaft. These timers also support slave modes, where another timer or a pin can start, stop, or reset the counter, and they can send a TRGO signal to other peripherals. The encoder interface and the synchronization options are common on the full-featured timers, but they are device-dependent on the simple timers.

STM32CubeMX TIM3 mode panel with internal clock source and Channel1 to Channel4 modes such as PWM Generation

Typical Applications

General-purpose timers handle most of the timing work in everyday projects. One PWM channel can dim an LED or the backlight of a display, and several channels of the same timer can drive RGB LEDs or small servos at the same frequency. As inputs, the channels can measure the echo pulse of an ultrasonic sensor, read the pulse width of an RC receiver, or find the frequency of a signal on a pin.

Another common use is motor speed measurement. A timer in encoder mode counts the pulses of a rotary encoder, and the change in the counter between two readings gives the speed. A capture channel can also measure the time between the pulses of a simple tachometer sensor. For general timing that does not need a pin, any general-purpose timer can act as a periodic interrupt source in the same way as a basic timer. When a project needs several of these functions together, the usual approach is to give each function its own timer, so that each one has its own counter and its own period.


STM32 Advanced-Control Timers

Advanced-control timers are the most capable timers in the family. On the STM32F446, these are TIM1 and TIM8, and both are connected to the APB2 bus. They include all the features of a full-featured general-purpose timer, along with the extra circuits for driving power stages safely.

Main Capabilities

Complementary Outputs and Dead Time

The first major addition is the complementary output. On a channel that supports it, the timer creates two signals instead of one. The main output follows the PWM signal, and the complementary output follows the opposite signal. This is exactly what a half bridge needs, because the high-side transistor and the low-side transistor must never be on at the same time, and one of them should be on whenever the other is off.

A problem appears at the moment of switching, because a real transistor does not turn off immediately. If the second transistor turns on while the first one is still conducting, a large current flows from the supply to ground through both of them. This is called shoot-through, and it can destroy the power stage. The dead-time generator solves this by delaying the rising edge of each output, so that a short gap appears where both outputs are off. The length of the gap is programmable, and you choose it to be longer than the turn-off time of your transistors. The diagram below shows the effect.

Waveforms of a PWM reference, main output, and complementary output with dead time between the switching edges
STM32CubeMX TIM1 settings for break and dead time management on an advanced-control timer

Break Function

The second major addition is the break function. A break input is a dedicated pin, or on some devices an internal signal, that puts the timer outputs into a safe state as soon as it becomes active. This action happens in hardware within a few clock cycles, so it does not depend on the CPU or on interrupt delays. A typical use is to connect the output of an overcurrent comparator to the break input. The power stage then switches off immediately when a fault occurs, even if the software is busy or has stopped working.

Advanced-control timers also have a main output enable bit, and it must be set before any output pin becomes active. The HAL functions that start PWM on these timers set this bit for you, but it often causes confusion when a TIM1 output stays silent after a manual register setup. The number of break inputs and the available break sources depend on the device.


Repetition Counter and Other Features

The third addition is the repetition counter. It delays the update event until a chosen number of counter cycles have passed, so the application can update the PWM settings at a lower rate than the PWM frequency itself. This is useful in motor control loops. Advanced-control timers also have a commutation event with preloaded registers, which lets several output settings change at the same moment, and this is used for six-step control of brushless motors. Many devices add extra internal channels, more break inputs, or a faster clock for these timers, but these extras are device-dependent.


Typical Applications

Advanced-control timers are used for half-bridge and full-bridge control, where the complementary outputs and the dead time protect the transistors. In a DC motor driver with an H-bridge, one timer can generate the signals for both half bridges. In a three-phase inverter for a brushless DC motor or a permanent-magnet synchronous motor, the three complementary channels drive the three phases, and the break input protects the inverter. The same features are used in switching power supplies, digital power converters, and lighting drivers.

A project that needs only a simple PWM signal for a small DC motor through a ready-made driver board does not need an advanced-control timer, because a general-purpose timer is enough. The advanced-control timer becomes necessary when you drive power transistors directly, since only this type provides dead time and a hardware break function.


STM32 Timer Feature Comparison

The table below compares the three timer types. The examples come from the STM32F446, and every capability that is not found on all devices of a type is marked as device-dependent.

Timer typeExamples on STM32F446Typical capabilitiesCommon uses
Basic TimersTIM6, TIM716-bit up counter, prescaler, update event, interrupt, DMA request, TRGO output (trigger targets are device-dependent). No capture/compare channels and no pins.Periodic interrupts, DAC or peripheral triggering, system tick
General-purpose TimersTIM2 to TIM5, TIM9 to TIM14Capture/compare channels, PWM, input capture, output compare, one-pulse mode. Counter width (16-bit or 32-bit), number of channels (1 to 4), counting directions, encoder interface, and slave modes are device-dependent.LED dimming, servo control, pulse measurement, encoder reading, general timing
Advanced-control TimersTIM1, TIM8Everything from general-purpose timers, plus complementary outputs, dead-time insertion, break input, and repetition counter. The number of complementary channels, break inputs, and extra internal channels are device-dependent.Half-bridge and full-bridge control, motor drives, inverters, power converters

The table shows the typical case, and the reference manual of your exact device is always the final source. A simple general-purpose timer such as TIM10 has one channel and no encoder interface, while TIM2 has four channels and an encoder interface, and both belong to the same type. This means the type name only tells you what a timer is likely to offer, and the feature table in the datasheet tells you what it really offers.

A good rule for choosing is to take the simplest timer that covers everything you need. A periodic interrupt needs only a basic timer or any free timer. PWM, capture, and encoder tasks need a general-purpose timer with enough channels and with channel pins that exist in your package. Direct control of power transistors needs an advanced-control timer. Following this rule keeps the more capable timers free for the tasks that really need them.


Identify Your STM32 Timers

The timers of a device are described in three places, and each one answers a different question. The datasheet tells you which timers exist and what they can do, the reference manual explains how they work, and STM32CubeMX shows how you can configure them in your project.

Datasheet

The datasheet of the device has a table called “Timer feature comparison” in its functional overview section. This table lists every timer of the device and shows its type, counter resolution, counter type, prescaler factor, DMA request generation, number of capture/compare channels, complementary outputs, and maximum timer clock. It is the fastest way to see what a device offers. The pins for each channel are listed in the alternate function table of the same document.

STM32F446 datasheet table of timers with TIM1, TIM2 and TIM6 marked as advanced-control, general-purpose and basic timers

Reference Manual

The reference manual has a separate chapter for each timer group, and the chapter titles name the type and the timer instances. Each chapter starts with an introduction and a list of main features, which is a quick way to confirm what a timer can do. The following sections describe the registers in detail. When several timers share one chapter, the text points out the differences between them, such as which timer has a 32-bit counter.

STM32F446 reference manual contents showing the advanced-control, general-purpose, and basic timer chapters

STM32CubeMX

In STM32CubeMX, the timers are listed in the Timers category of the Pinout & Configuration tab, and the list shows only the timers that your device has. The configuration panel also shows the type of each timer. A basic timer offers only an activation checkbox and the period settings. A general-purpose timer adds the clock source and the channel modes. An advanced-control timer also adds complementary outputs and the group for break and dead-time settings. This makes CubeMX a handy check, because a feature that a timer does not have is simply not shown.

STM32CubeMX Timers category listing the timer instances of the NUCLEO-F446RE

Conclusion

STM32 devices have three timer types because different tasks need different hardware, and a fully featured timer in every instance would waste space on the chip. Basic timers give you a time base with an update event, an interrupt, a DMA request, and a trigger output, but they have no channels and no pins. General-purpose timers add capture/compare channels, which allow PWM, input capture, output compare, and often an encoder interface. Advanced-control timers add complementary outputs, dead time, a break function, and a repetition counter for motor control and power conversion.

All three types share the same counter core, so the prescaler, the auto-reload register, and the update event work in the same way everywhere. The features that change from device to device are the counter width, the number of channels, the encoder and synchronization options, and the trigger targets, so you should check them for your exact device in the datasheet, the reference manual, and CubeMX. With the types clear, the next step is to put a timer to work. The next article uses the periodic update interrupt and shows how to run code at a fixed interval with the HAL library.

Article by Yashmiti

Yashmiti is a technical writer at STM32Guide, where she creates tutorials and guides that help embedded-systems learners and developers work confidently with STM32 microcontrollers. Her writing covers tools like STM32CubeIDE and STM32CubeMX, along with peripherals and communication protocols โ€” always with an emphasis on clear explanations and hands-on examples that take readers from concept to working project.

She's also part of the effort to build STM32Guide into an organized, easy-to-navigate resource for the STM32 community.

Leave a Comment