DS14928 · DatasheetArm® Cortex®-M33 32-bit MCU with FPU, 144 MHz, 593 CoreMark®, up to 512‑Kbyte dual‑bank flash memory, 128-Kbyte RAM
Download .pdfOpen in the full document

Timers and watchdogs

Timers and watchdogs

The devices include two advanced control timers, up to eleven general‑purpose timers, two basic timers, two low‑power timers, two watchdog timers, and one SysTick timer.

The table below compares the features of the advanced control, general‑purpose and basic timers.
Table 6. Timer feature comparison
Timer typeTimerCounter resolutionCounter typePrescaler factorDMA request generationCapture / compare channelsComplementary outputs
Advanced controlTIM1, TIM816 bitsUp, down, Up/downAny integer between 1 and 65536Yes44
General-purposeTIM2, TIM532 bitsUp, down, Up/downAny integer between 1 and 65536Yes4No
TIM12 16 bitsUpNo2No
TIM1516 bitsUp, down, Up/downYes21
TIM16, TIM1716 bitsUp, down, Up/down1No
BasicTIM6, TIM716 bitsUpAny integer between 1 and 65536Yes0No

Advanced-control timers (TIM1/TIM8)

The advanced-control timers (TIM1/TIM8) consist of a 16-bit autoreload counter driven by a programmable prescaler.

They may be used for various purposes, including measuring the pulse lengths of input signals (input capture) or generating output waveforms (output compare, PWM, complementary PWM with dead-time insertion).

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.

TIM1/TIM8 timer features include:

  • 16-bit up, down, up/down autoreload counter
  • 16-bit programmable prescaler allowing dividing (also “on the fly”) the counter clock frequency by any factor from 1 to 65536
  • Seven independent channels for:
    • Input capture (except channels 5, 6, and 7)
    • Output compare
    • PWM generation (edge- and center-aligned mode)
    • One-pulse mode output
  • Complementary outputs with programmable dead-time
  • Synchronization circuit to control the timer with external signals and to interconnect several timers together
  • Repetition counter to update the timer registers only after a given number of cycles of the counter
  • Two break inputs to put the timer’s output signals in a safe user‑selectable configuration
  • 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
  • Incremental encoders, quadrature encoders, and hall‑sensors support
  • Trigger input for external clock or cycle-by-cycle current management
  • ADC synchronization for jitter-free sampling points

General-purpose timers (TIM2/TIM5/TIM12/TIM15/TIM16/TIM17)

The general-purpose timers (TIMx) consist of a 16-bit or 32-bit autoreload counter driven by a programmable prescaler.

They can be used for various 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.

General-purpose TIMx timer features include:

  • 16-bit or 32-bit up, down, up/down autoreload counter
  • 16-bit programmable prescaler used to divide (also “on the fly”) the counter clock frequency by any factor between 1 and 65535
  • Up to four independent channels for:
    • Input capture
    • Output compare
    • PWM generation (edge- and center-aligned modes)
    • One-pulse mode output
  • Synchronization circuit to control the timer with external signals and to interconnect several timers
  • 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
  • Supports incremental (quadrature) encoder and hall-sensor circuitry for positioning purposes
  • Trigger input for external clock or cycle-by-cycle current management
  • ADC synchronization for jitter-free sampling points

Basic timers (TIM6/TIM7)

The basic timers (TIM6/TIM7) consist of a 16-bit autoreload counter driven by a programmable prescaler.

They can be used as generic timers for time-base generation.

The basic timer can also be used for triggering the digital-to-analog converter. This is done with the trigger output of the timer.

The timers are completely independent and do not share any resources.

Basic timer (TIM6/TIM7) features include:

  • 16-bit autoreload upcounter
  • 16-bit programmable prescaler used to divide (also “on the fly”) the counter clock frequency by any factor between 1 and 65535
  • Synchronization circuit to trigger the DAC
  • Interrupt/DMA generation on the update event: counter overflow
  • ADC synchronization for jitter-free sampling points

Low-power timers (LPTIM1)

The LPTIM is a 16-bit timer that benefits from the ultimate developments in power consumption reduction. Thanks to its diversity of clock sources, the LPTIM can keep running in all power modes except for Standby mode. Given its capability to run even with no internal clock source, the LPTIM can be used as a pulse counter, which can be useful in some applications. The LPTIM capability to wake up the system from low‑power modes makes it suitable to realize timeout functions with extremely low-power consumption.

The low-power timer supports the following features:
  • 16-bit up counter with 16-bit auto reload register
  • 3-bit prescaler with eight possible dividing factors (1, 2, 4, 8, 16, 32, 64, 128)
  • Selectable clock
    • Internal clock sources: LSE, LSI, HSI, or APB clock
    • External clock source over LPTIM input (working with no LP oscillator running, used by pulse counter application)
  • 16-bit ARR auto reload register
  • 16-bit capture/compare register
  • Continuous/one-shot mode
  • Selectable software/hardware input trigger
  • Programmable digital glitch filter
  • Configurable output: pulse, PWM
  • Configurable I/O polarity
  • Encoder mode
  • Repetition counter
  • Up to two independent channels for:
    • Input capture
    • PWM generation (edge-aligned mode)
    • One-pulse mode output
  • Interrupt generation on ten events
  • DMA request generation on the following events:
    • Update event
    • Input capture

Independent watchdog (IWDG)

The independent watchdog (IWDG) peripheral offers a high safety level due to its capability to detect malfunctions caused by software or hardware failures.

The IWDG is clocked by an independent clock and remains active even if the main clock fails.

Additionally, the watchdog function is performed in the VDD voltage domain, allowing the IWDG to remain functional even in low‑power modes.

The IWDG main features are:

  • 12-bit down-counter
  • Dual voltage domain, thus enabling operation in low-power modes
  • Independent clock
  • Early wake-up interrupt generation
  • Reset generation:
    • In case of timeout
    • In case of refresh outside the expected window

Window watchdog (WWDG)

The system window watchdog (WWDG) is used to detect the occurrence of a software fault, usually generated by external interference or unforeseen logical conditions, which causes the application program to abandon its normal sequence.

The watchdog circuit generates a reset on the expiry of a programmed time period unless the program refreshes the contents of the down-counter before the T6 bit is cleared. A reset is also generated if the 7‑bit down‑counter value (in the control register) is refreshed before the down-counter reaches the window register value. This implies that the counter must be refreshed in a limited window.

The WWDG clock is prescaled from the APB clock and has a configurable time window that can be programmed to detect abnormally late or early application behavior.

The WWDG is best suited for applications requiring the watchdog to react within an accurate timing window.

The WWDG main features are:

  • Programmable free-running down-counter
  • Conditional reset:
    • Reset (if watchdog activated) when the down-counter value becomes lower than 0x40
    • Reset (if watchdog activated) if the down-counter is reloaded outside the window
  • Early wake-up interrupt (EWI): triggered (if enabled and the watchdog activated) when the down‑counter is equal to 0x40

SysTick timer

The Cortex®-M33 embeds one SysTick timer.

This timer is dedicated to real‑time operating systems, but can also be used as a standard down counter. It features:

  • A 24-bit down counter
  • Auto reload capability
  • Maskable system interrupt generation when the counter reaches 0
  • Programmable clock source