Functional Description

Upcounting Mode

This timer is a 32-bit counter with its related auto-reload register. The counter, as well as the auto-reload register can be written or read by software. This is true even when the counter is running.

The time-base unit includes:

  • Counter register (TIMx_CNT)

  • Auto-reload register (TIMx_ARR)

Timer is in count-up mode where the counter counts from 0 to the auto-reload value (the content of the TIMx_ARR register). A counter overflow event is generated after the counter reaches the auto-reload value.

Preloaded Auto-Reload Register

The auto-reload register supports a preload mechanism. Read and write operations to this register actually access the corresponding preload register. The timing of transferring the value from the preload register to the shadow register is controlled by the auto-reload preload enable bit ARPE in the timer control register TIMx_CR: if ARPE is set, the preload value is transferred to the shadow register only when each update event (UEV) occurs; if ARPE is cleared, the preload value is written to the shadow register immediately.

The trigger conditions for an update event (UEV) are divided into two categories: hardware triggers and software triggers. The prerequisite for the operation to take effect is that the update disable bit UDIS in the TIMx_CR register is 0, meaning all update functions are enabled.

  1. Hardware trigger: When the counter operates in count-up mode and the count value reaches the overflow state, the hardware automatically generates an update event;

  2. Software trigger: This is achieved by setting the update generation bit UG in the timer event generation register TIMx_EGR via software. The prerequisite for this operation to take effect is that the update request source bit URS in the TIMx_CR register is 0, meaning the software update function is not masked.

By setting the UDIS bit in the TIMx_CR register, the generation of update events can be globally disabled. This prevents the shadow register from being synchronously updated while writing a new reload value to the preload register, ensuring the stability of the configuration write. No trigger condition will generate an update event until the UDIS bit is cleared.

When an update event effectively occurs, the timer-related registers are updated. Meanwhile, the auto-reload shadow register loads the current value from the preload register TIMx_ARR, completing the synchronous update of the reload value.

Interrupt Event

Interrupt events can be enabled through the TIMx_DIER register. When the UIE bit is 1, an interrupt event occurrence will trigger a system interrupt. Hardware overflow and software-triggered updates both generate interrupts. The corresponding interrupt status can be checked via the UIF bit in TIMx_SR, and the interrupt can be cleared by writing to UIF.

Security Attribution

Basic Timer peripherals do not independently occupy a peripheral port on a per-timer basis. Their port resources are typically shared by multiple timers within the same peripheral port, corresponding to a single PPC (Peripheral Permission Controller). Since the security attribution of a shared port is configured uniformly by the PPC, independent configuration of individual timer security attribution is not achievable. To support flexible configuration of each basic timer’s security attribution, every basic timer integrates a dedicated security control register. This security control register contains a security enable bit for independently configuring the security attribution of the corresponding timer. It is accessible only from the secure world; the non-secure world cannot perform read or write operations on it. When the timer security enable bit is set, the timer is configured as a secure timer. All of its registers are accessible only through secure addresses, and non-secure address access is prohibited. When the security enable bit is cleared, the timer is configured as a non-secure timer. With the exception of the security control register, all other registers can be accessed through both secure and non-secure addresses.