Timer Systems in Modern MCUs

Modern microcontrollers (MCUs) include versatile timer/counter modules that provide precise timing, waveform generation, and event capture functionality. Timers are used for:

Prescaler

A prescaler divides the MCU clock frequency before it reaches the timer, allowing the timer to count at a slower, configurable rate. For example, a 72 MHz MCU clock with a prescaler of 72 will make the timer increment at 1 MHz. Prescalers are critical for:

Basic Timer / One-Shot Mode

Basic timers increment or decrement a counter based on the prescaled clock. - One-Shot Mode: Timer counts to a specified value and stops, generating a single event or interrupt. - Auto-Reload Mode: Timer resets automatically for periodic events.

Pulse Width Modulation (PWM)

PWM allows generation of a digital waveform with configurable duty cycle:

Differential PWM / Dead-Time Control

For motor drives and H-bridge circuits, timers can output complementary PWM signals:

Input Capture

Input Capture allows a timer to record the counter value when an external event occurs:

Quadrature / Encoder Timer

Timers can interface with quadrature encoders to measure rotation:

Advanced Timer Features

Modern MCU timers also support: