55. Basic timers (TIM6/TIM7)
55.1 TIM6/TIM7 introduction
The basic timers TIM6/TIM7 consist in 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.
55.2 TIM6/TIM7 main features
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.
55.3 TIM6/TIM7 functional description
55.3.1 TIM6/TIM7 block diagram
Figure 620. Basic timer block diagram

Notes:
- Reg Preload registers transferred to active registers on U event according to control bit
- ⚡ Event
- ⤳ Interrupt & DMA
MSv62381V1
55.3.2 TIM6/TIM7 internal signals
The table in this section summarizes the TIM inputs and outputs.
Table 559. TIM internal input/output signals
| Internal signal name | Signal type | Description |
|---|---|---|
| tim_pclk | Input | Timer APB clock |
| tim_ker_ck | Input | Timer kernel clock. This clock must be synchronous with tim_pclk (derived from the same source). The clock ratio tim_ker_ck/tim_pclk must be an integer: 1, 2, 3,..., 16 (maximum value) |
| tim_trgo | Output | Internal trigger output. This trigger can trigger other on-chip peripherals (DAC). |
| tim_upd_it | Output | Timer update event interrupt |
| tim_upd_dma | Output | Timer update dma request |
55.3.3 TIM6/TIM7 clocks
The timer bus interface is clocked by the tim_pclk APB clock.
The counter clock tim_ker_ck is connected to the tim_pclk input.
The CEN (in the TIMx_CR1 register) and UG bits (in the TIMx_EGR register) are actual control bits and can be changed only by software (except for UG that remains cleared automatically). As soon as the CEN bit is written to 1, the prescaler is clocked by the internal clock tim_ker_ck.
Figure 621 shows the behavior of the control circuit and the upcounter in normal mode, without prescaler.
Figure 621. Control circuit in normal mode, internal clock divided by 1

The diagram illustrates the timing relationship between various signals in normal mode without a prescaler. The tim_ker_ck signal is the primary clock. The CEN signal is a control signal that enables the counter. The UG signal is the update generation signal. The counter initialization (internal) signal shows the internal initialization of the counter. The tim_cnt_ck, tim_psc_ck signal is the counter clock, which is derived from tim_ker_ck when CEN is high. The Counter register shows the state of the counter, with bits 31 to 00. The counter increments on each rising edge of tim_cnt_ck, tim_psc_ck when CEN is high. The UG signal is high when the counter reaches its maximum value (0x0000) and rolls over to 0x0001.
55.3.4 Time-base unit
The main block of the programmable timer is a 16-bit upcounter with its related autoreload register. The counter clock can be divided by a prescaler.
The counter, the autoreload register and the prescaler 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) - • Prescaler register (
TIMx_PSC) - • Auto-Reload register (
TIMx_ARR).
The autoreload register is preloaded. The preload register is accessed each time an attempt is made to write or read the autoreload register. The contents of the preload register are transferred into the shadow register permanently or at each update event UEV, depending on the autoreload preload enable bit (ARPE) in the TIMx_CR1 register. The update event is sent when the counter reaches the overflow value and if the UDIS bit equals 0 in the TIMx_CR1 register. It can also be generated by software. The generation of the update event is described in detail for each configuration.
The counter is clocked by the prescaler output tim_cnt_ck, which is enabled only when the counter enable bit (CEN) in the TIMx_CR1 register is set.
Note that the actual counter enable signal tim_cnt_en is set one clock cycle after CEN bit set.
Prescaler description
The prescaler can divide the counter clock frequency by any factor between 1 and 65536. It is based on a 16-bit counter controlled through a 16-bit register (in the TIMx_PSC register). It can be changed on the fly as the TIMx_PSC control register is buffered. The new prescaler ratio is taken into account at the next update event.
Figure 622 and Figure 623 give some examples of the counter behavior when the prescaler ratio is changed on the fly.
Figure 622. Counter timing diagram with prescaler division change from 1 to 2

The diagram illustrates the timing of a counter when the prescaler division is changed from 1 to 2. The signals shown are:
- tim_psc_ck: The prescaler clock signal.
- CEN: The counter enable signal, which is set to 1.
- tim_cnt_ck: The counter clock signal, which is enabled when CEN is 1.
- Counter register: Shows the counter values. It increments from F7 to FC, then wraps around to 00, 01, 02, 03.
- Update event (UEV): A pulse that occurs when the counter reaches its maximum value (FC) and wraps around.
- Prescaler control register: Shows the value 0 before the update event and 1 after the update event. An arrow points to the transition with the text "Write a new value in TIMx_PSC".
- Prescaler buffer: Shows the value 0 before the update event and 1 after the update event.
- Prescaler counter: Shows the prescaler counter values. It increments from 0 to 1, then wraps around to 0, 1, 0, 1, 0, 1.
The diagram shows that the prescaler division is changed from 1 to 2 at the update event. The prescaler counter increments from 0 to 1, and then wraps around to 0, 1, 0, 1, 0, 1.
MSv50998V1
Figure 623. Counter timing diagram with prescaler division change from 1 to 4

The diagram illustrates the timing of a prescaler division change from 1 to 4. It shows the following signals and registers over time:
- tim_psc_ck: Prescaler clock signal.
- CEN: Counter enable signal, which starts high and then goes low.
- tim_cnt_ck: Counter clock signal, which is derived from tim_psc_ck.
- Counter register: Shows the counter values F7, F8, F9, FA, FB, FC, 00, and 01.
- Update event (UEV): A pulse occurs at the end of the counter register sequence.
- Prescaler control register: Shows the value 0 before the change and 3 after the change. An arrow points to the transition with the text "Write a new value in TIMx_PSC".
- Prescaler buffer: Shows the value 0 before the change and 3 after the change.
- Prescaler counter: Shows the value 0 before the change and then counts 0, 1, 2, 3, 0, 1, 2, 3 after the change.
MSv50999V1
55.3.5 Counting mode
The counter counts from 0 to the autoreload value (contents of the TIMx_ARR register), then restarts from 0 and generates a counter overflow event.
An update event can be generated at each counter overflow or by setting the UG bit in the TIMx_EGR register (by software or by using the slave mode controller).
The UEV event can be disabled by software by setting the UDIS bit in the TIMx_CR1 register. This avoids updating the shadow registers while writing new values into the preload registers. In this way, no update event occurs until the UDIS bit has been written to 0, however, the counter and the prescaler counter both restart from 0 (but the prescale rate does not change). In addition, if the URS (update request selection) bit in the TIMx_CR1 register is set, setting the UG bit generates an update event UEV, but the UIF flag is not set (so no interrupt or DMA request is sent).
When an update event occurs, all the registers are updated and the update flag (UIF bit in the TIMx_SR register) is set (depending on the URS bit):
- • The buffer of the prescaler is reloaded with the preload value (contents of the TIMx_PSC register).
- • The autoreload shadow register is updated with the preload value (TIMx_ARR).
The following figures show some examples of the counter behavior for different clock frequencies when TIMx_ARR = 0x36.
Figure 624. Counter timing diagram, internal clock divided by 1

This timing diagram illustrates the operation of a counter when the internal clock is divided by 1. The tim_psc_ck signal is a continuous square wave. The CEN signal is a low-to-high pulse that enables the counter. The tim_cnt_ck signal is a square wave with the same frequency as tim_psc_ck. The Counter register shows the count values: 31, 32, 33, 34, 35, 36, 00, 01, 02, 03, 04, 05, 06, 07. A counter overflow occurs when the count transitions from 36 to 00. The Counter overflow signal is a pulse at this transition. The Update event (UEV) signal is a pulse following the overflow. The Update interrupt flag (UIF) signal is a pulse following the UEV. Vertical dashed lines indicate the timing of the counter register updates.
MSv50997V1
Figure 625. Counter timing diagram, internal clock divided by 2

This timing diagram illustrates the operation of a counter when the internal clock is divided by 2. The tim_psc_ck signal is a continuous square wave. The CEN signal is a low-to-high pulse that enables the counter. The tim_cnt_ck signal is a square wave with half the frequency of tim_psc_ck. The Counter register shows the count values: 0034, 0035, 0036, 0000, 0001, 0002, 0003. A counter overflow occurs when the count transitions from 0036 to 0000. The Counter overflow signal is a pulse at this transition. The Update event (UEV) signal is a pulse following the overflow. The Update interrupt flag (UIF) signal is a pulse following the UEV. Vertical dashed lines indicate the timing of the counter register updates.
MSv62300V1
Figure 626. Counter timing diagram, internal clock divided by 4

This timing diagram illustrates the operation of a counter when the internal clock is divided by 4. The tim_psc_ck signal is a continuous high-frequency square wave. The CEN (Counter Enable) signal is active low; it starts high, then transitions to low to enable the counter. The tim_cnt_ck (Counter Clock) signal is a divided version of tim_psc_ck, with a period four times longer. The Counter register shows the count value: it increments from 0035 to 0036 on the first tim_cnt_ck rising edge after CEN is low. On the second tim_cnt_ck rising edge, the counter overflows, triggering a Counter overflow pulse, an Update event (UEV) pulse, and setting the Update interrupt flag (UIF) to high. The counter register then resets to 0000 and increments to 0001 on the next tim_cnt_ck rising edge. The diagram is labeled MSv62301V1 in the bottom right corner.
Figure 627. Counter timing diagram, internal clock divided by N

This timing diagram shows the counter operation with an internal clock divided by an arbitrary factor N. The tim_psc_ck signal is a continuous square wave. The tim_cnt_ck signal is a divided version of tim_psc_ck. The Counter register shows the count value: it increments from 1F to 20 on a tim_cnt_ck rising edge. On the next tim_cnt_ck rising edge, the counter overflows, triggering a Counter overflow pulse, an Update event (UEV) pulse, and setting the Update interrupt flag (UIF) to high. The counter register then resets to 00. The diagram is labeled MSv62302V1 in the bottom right corner.
Figure 628. Counter timing diagram, update event when ARPE = 0 (TIMx_ARR not preloaded)

The diagram illustrates the timing of an update event when ARPE = 0. The Counter register is shown as a sequence of 8-bit values (31, 32, 33, 34, 35, 36, 00, 01, 02, 03, 04, 05, 06, 07). The Counter overflow occurs when the counter reaches 36. The Update event (UEV) occurs on the rising edge of the counter overflow. The Update interrupt flag (UIF) is set on the rising edge of the UEV. The Auto-reload preload register is shown as FF, and a write to it is indicated by a vertical line. The CEN signal is active low, and the tim_psc_ck and tim_cnt_ck signals are shown as clock pulses.
| Signal | Value / State |
|---|---|
| Counter register | 31, 32, 33, 34, 35, 36, 00, 01, 02, 03, 04, 05, 06, 07 |
| Counter overflow | High until counter reaches 36, then low |
| Update event (UEV) | High pulse on rising edge of counter overflow |
| Update interrupt flag (UIF) | High after rising edge of UEV |
| Auto-reload preload register | FF |
Write a new value in TIMx_ARR
MSv62303V1
Figure 629. Counter timing diagram, update event when ARPE = 1 (TIMx_ARR preloaded)

The diagram illustrates the timing of a counter when ARPE = 1. The counter register counts from F0 to F5, then wraps to 00-07. An update event (UEV) occurs at the end of the F5 cycle, triggering the UIF and updating the shadow register. The preload register is updated with a new value '36' after the update event. The counter register is updated from the shadow register at the next update event.
Write a new value in TIMx_ARR
MSv62304V1
Dithering mode
The time base effective resolution can be increased by enabling the dithering mode, using the DITHER bit in the TIMx_CR1 register. This affects the way the TIMx_ARR is behaving, and is useful for adjusting the average counter period when the timer is used as a trigger (typically for a DAC).
The operating principle is to have the actual ARR value slightly changed (adding or not one timer clock period) over 16 consecutive counting periods, with predefined patterns. This allows a 16-fold resolution increase, considering the average counting period.
Figure 630 presents the dithering principle applied to four consecutive counting periods.

Figure 630. Dithering principle
MSv47466V1
When the dithering mode is enabled, the register coding is changed as follows (see Figure 631 for example):
- • The four LSBs are coding for the enhanced resolution part (fractional part).
- • The MSBs are left-shifted to the bits 19:4 and are coding for the base value.
Note: The following sequence must be followed when resetting the DITHEN bit:
1. CEN and ARPE bits must be reset
2. The DITHEN bit must be reset
3. The CEN bit can be set (eventually with ARPE = 1).
Figure 631. Data format and register coding in dithering mode

MSv45753V2
The minimum frequency is given by the following formula:
Note: The maximum TIMx_ARR value is limited to 0xFFFEF in dithering mode (corresponds to 65534 for the integer part and 15 for the dithered part).
As shown on Figure 632, the dithering mode is used to increase the PWM resolution whatever the PWM frequency.
Figure 632. FCnt resolution vs frequency

MSv50910V1
The period changes are spread over 16 consecutive periods, as described in Figure 633.
Figure 633. PWM dithering pattern

MSv47465V1
The autoreload and compare values increments are spread following the specific patterns described in Table 560. The dithering sequence is done to have increments distributed as evenly as possible and minimize the overall ripple.
Table 560. TIMx_ARR register change dithering pattern
| - | PWM period | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | |
| LSB value | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 0000 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0001 | +1 | - | - | - | - | - | - | - | - | - | - | - | - | - | - | - |
| 0010 | +1 | - | - | - | - | - | - | - | +1 | - | - | - | - | - | - | - |
| 0011 | +1 | - | - | - | +1 | - | - | - | +1 | - | - | - | - | - | - | - |
| 0100 | +1 | - | - | - | +1 | - | - | - | +1 | - | - | - | +1 | - | - | - |
| 0101 | +1 | - | +1 | - | +1 | - | - | - | +1 | - | - | - | +1 | - | - | - |
| 0110 | +1 | - | +1 | - | +1 | - | - | - | +1 | - | +1 | - | +1 | - | - | - |
| 0111 | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - | - | - |
| 1000 | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - |
| 1001 | +1 | +1 | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - | +1 | - |
| 1010 | +1 | +1 | +1 | - | +1 | - | +1 | - | +1 | +1 | +1 | - | +1 | - | +1 | - |
| 1011 | +1 | +1 | +1 | - | +1 | +1 | +1 | - | +1 | +1 | +1 | - | +1 | - | +1 | - |
| 1100 | +1 | +1 | +1 | - | +1 | +1 | +1 | - | +1 | +1 | +1 | - | +1 | +1 | +1 | - |
| 1101 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | - | +1 | +1 | +1 | - | +1 | +1 | +1 | - |
| 1110 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | - | +1 | +1 | +1 | +1 | +1 | +1 | +1 | - |
| 1111 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | +1 | - |
55.3.6 UIF bit remapping
The IUFREMAP bit in the TIMx_CR1 register forces a continuous copy of the update interrupt flag UIF into the timer counter register's bit 31 (TIMxCNT[31]). This is used to atomically read both the counter value and a potential roll-over condition signaled by the UIFCPY flag. In particular cases, it can ease the calculations by avoiding race conditions caused for instance by a processing shared between a background task (counter reading) and an interrupt (update interrupt).
There is no latency between the assertions of the UIF and UIFCPY flags.
55.3.7 ADC triggers
The timer can generate an ADC triggering event with various internal signals, such as reset, enable or compare events.
Note: The clock of the slave peripherals (such as timer, ADC) receiving the tim_trgo signal must be enabled prior to receiving events from the master timer, and the clock frequency (prescaler) must not be changed on-the-fly while triggers are received from the master timer.
55.3.8 TIM6/TIM7 DMA requests
The TIM6/TIM7 can generate a single DMA request, as shown in Table 561.
Table 561. DMA request
| DMA acronym | DMA request | Enable control bit |
|---|---|---|
| tim_upd_dma | Update | UDE |
55.3.9 Debug mode
When the microcontroller enters debug mode (Cortex-M33 core halted), the TIMx counter can either continue to work normally or be stopped.
The behavior in debug mode can be programmed with a dedicated configuration bit per timer in the Debug support (DBG) module.
For more details, refer to section Debug support (DBG).
55.3.10 TIM6/TIM7 low-power modes
Table 562. Effect of low-power modes on TIM6/TIM7
| Mode | Description |
|---|---|
| Sleep | No effect, peripheral is active. The interrupts can cause the device to exit from Sleep mode. |
| Stop | The timer operation is stopped and the register content is kept. No interrupt can be generated. |
| Standby | The timer is powered-down and must be reinitialized after exiting the Standby mode. |
55.3.11 TIM6/TIM7 interrupts
The TIM6/TIM7 can generate a single interrupt, as shown in Table 563.
Table 563. Interrupt request
| Interrupt acronym | Interrupt event | Event flag | Enable control bit | Interrupt clear method | Exit from Sleep mode | Exit from Stop and Standby mode |
|---|---|---|---|---|---|---|
| TIM6 TIM7 | Update | UIF | UIE | write 0 in UIF | Yes | No |
55.4 TIM6/TIM7 registers
Refer to Section 1.2 for a list of abbreviations used in register descriptions.
The peripheral registers can be accessed by half-words (16-bit) or words (32-bit).
55.4.1 TIMx control register 1 (TIMx_CR1)(x = 6 to 7)
Address offset: 0x00
Reset value: 0x0000
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | DITH EN | UIFRE MAP | Res. | Res. | Res. | ARPE | Res. | Res. | Res. | OPM | URS | UDIS | CEN |
| rw | rw | rw | rw | rw | rw | rw |
Bits 15:13 Reserved, must be kept at reset value.
Bit 12 DITHEN: Dithering enable
0: Dithering disabled
1: Dithering enabled
Note: The DITHEN bit can only be modified when CEN bit is reset.
Bit 11 UIFREMAP: UIF status bit remapping
0: No remapping. UIF status bit is not copied to TIMx_CNT register bit 31.
1: Remapping enabled. UIF status bit is copied to TIMx_CNT register bit 31.
Bits 10:8 Reserved, must be kept at reset value.
Bit 7 ARPE: Auto-reload preload enable
0: TIMx_ARR register is not buffered.
1: TIMx_ARR register is buffered.
Bits 6:4 Reserved, must be kept at reset value.
Bit 3 OPM: One-pulse mode
0: Counter is not stopped at update event
1: Counter stops counting at the next update event (clearing the CEN bit).
Bit 2 URS: Update request source
This bit is set and cleared by software to select the UEV event sources.
0: Any of the following events generates an update interrupt or DMA request if enabled.
These events can be:
- - Counter overflow/underflow
- - Setting the UG bit
- - Update generation through the slave mode controller
1: Only counter overflow/underflow generates an update interrupt or DMA request if enabled.
Bit 1 UDIS: Update disable
This bit is set and cleared by software to enable/disable UEV event generation.
0: UEV enabled. The Update (UEV) event is generated by one of the following events:
- - Counter overflow/underflow
- - Setting the UG bit
- - Update generation through the slave mode controller
Buffered registers are then loaded with their preload values.
1: UEV disabled. The Update event is not generated, shadow registers keep their value (ARR, PSC). However the counter and the prescaler are reinitialized if the UG bit is set or if a hardware reset is received from the slave mode controller.
Bit 0 CEN: Counter enable
0: Counter disabled
1: Counter enabled
CEN is cleared automatically in one-pulse mode, when an update event occurs.
55.4.2 TIMx control register 2 (TIMx_CR2)(x = 6 to 7)
Address offset: 0x04
Reset value: 0x0000
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | MMS[2:0] | Res. | Res. | Res. | Res. | ||
| rw | rw | rw | |||||||||||||
Bits 15:7 Reserved, must be kept at reset value.
Bits 6:4 MMS[2:0]: Master mode selection
These bits are used to select the information to be sent in master mode to slave timers for synchronization (TRGO). The combination is as follows:
000:Reset - the UG bit from the TIMx_EGR register is used as a trigger output (tim_trgo).
001:Enable - the Counter enable signal, tim_cnt_en, is used as a trigger output (tim_trgo). It is useful to start several timers at the same time or to control a window in which a slave timer is enabled. The Counter Enable signal is generated when the CEN control bit is written.
010:Update - The update event is selected as a trigger output (tim_trgo). For instance a master timer can then be used as a prescaler for a slave timer.
Note: The clock of the slave timer or the peripheral receiving the tim_trgo must be enabled prior to receive events from the master timer, and must not be changed on-the-fly while triggers are received from the master timer.
Bits 3:0 Reserved, must be kept at reset value.
55.4.3 TIMx DMA/Interrupt enable register (TIMx_DIER)(x = 6 to 7)
Address offset: 0x0C
Reset value: 0x0000
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | UDE | Res. | Res. | Res. | Res. | Res. | Res. | Res. | UIE |
| rw | rw |
Bits 15:9 Reserved, must be kept at reset value.
Bit 8 UDE: Update DMA request enable
0: Update DMA request disabled.
1: Update DMA request enabled.
Bits 7:1 Reserved, must be kept at reset value.
Bit 0 UIE: Update interrupt enable
0: Update interrupt disabled.
1: Update interrupt enabled.
55.4.4 TIMx status register (TIMx_SR)(x = 6 to 7)
Address offset: 0x10
Reset value: 0x0000
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | UIF |
| rc_w0 |
Bits 15:1 Reserved, must be kept at reset value.
Bit 0 UIF : Update interrupt flagThis bit is set by hardware on an update event. It is cleared by software.
0: No update occurred.
1: Update interrupt pending. This bit is set by hardware when the registers are updated:
–On counter overflow if UDIS = 0 in the TIMx_CR1 register.
–When CNT is reinitialized by software using the UG bit in the TIMx_EGR register, if URS = 0 and UDIS = 0 in the TIMx_CR1 register.
55.4.5 TIMx event generation register (TIMx_EGR)(x = 6 to 7)
Address offset: 0x14
Reset value: 0x0000
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | UG |
| w |
Bits 15:1 Reserved, must be kept at reset value.
Bit 0 UG : Update generationThis bit can be set by software, it is automatically cleared by hardware.
0: No action.
1: Re-initializes the timer counter and generates an update of the registers. Note that the prescaler counter is cleared too (but the prescaler ratio is not affected).
55.4.6 TIMx counter (TIMx_CNT)(x = 6 to 7)
Address offset: 0x24
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| UIF CPY | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| r | |||||||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| CNT[15:0] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bit 31 UIFCPY: UIF copy
This bit is a read-only copy of the UIF bit of the TIMx_ISR register. If the UIFREMAP bit in TIMx_CR1 is reset, bit 31 is reserved and read as 0.
Bits 30:16 Reserved, must be kept at reset value.
Bits 15:0 CNT[15:0]: Counter value
Non-dithering mode (DITHEN = 0)
The register holds the counter value.
Dithering mode (DITHEN = 1)
The register only holds the non-dithered part in CNT[15:0]. The fractional part is not available.
55.4.7 TIMx prescaler (TIMx_PSC)(x = 6 to 7)
Address offset: 0x28
Reset value: 0x0000
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PSC[15:0] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 15:0 PSC[15:0]: Prescaler value
The counter clock frequency \(f_{tim\_cnt\_ck}\) is equal to \(f_{tim\_psc\_ck} / (PSC[15:0] + 1)\).
PSC contains the value to be loaded into the active prescaler register at each update event. (including when the counter is cleared through UG bit of TIMx_EGR register).
55.4.8 TIMx autoreload register (TIMx_ARR)(x = 6 to 7)
Address offset: 0x2C
Reset value: 0x0000 FFFF
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | ARR[19:16] | |||
| rw | rw | rw | rw | ||||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| ARR[15:0] | |||||||||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
Bits 31:20 Reserved, must be kept at reset value.
Bits 19:0 ARR[19:0]: Auto-reload value
ARR is the value to be loaded into the actual auto-reload register.
Refer to Section 55.3.4: Time-base unit for more details about ARR update and behavior.
The counter is blocked while the auto-reload value is null.
Non-dithering mode (DITHEN = 0)
The register holds the auto-reload value in ARR[15:0]. The ARR[19:16] bits are reserved.
Dithering mode (DITHEN = 1)
The register holds the integer part in ARR[19:4]. The ARR[3:0] bitfield contains the dithered part.
55.4.9 TIMx hardware configuration 2 register
(TIMx_HWCFGR2)(x = 6 to 7)
Address offset: 0x3EC
Reset value: 0x0000 1011
This read register identifies the hardware configuration parameters of the instantiated IP.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | OPTIONREG_OUT[7:0] | |||||||
| r | r | r | r | r | r | r | r | ||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| CNT_WIDTH[7:0] | PSC_WIDTH16[3:0] | PSC_LINEAR[3:0] | |||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:24 Reserved, must be kept at reset value.
Bits 23:16 OPTIONREG_OUT[7:0]: Option register number (0 to 16).
Bits 15:8 CNT_WIDTH[7:0]: Counter width
0x08: 8-bits
0x10: 16-bits
0x20: 32-bits
Others: Reserved
Bits 7:4 PSC_WIDTH16[3:0]: Prescaler width
0x0: 7 (by power of 2) /8 (linear) -bit counter
0x1: 15 (by power of 2) /16 (linear) -bit counter
Others: Reserved
Bits 3:0 PSC_LINEAR[3:0]: Prescaler linear
0x0: prescaler by power of 2 (division by 1, 2, 4, 8...)
0x1: prescaler is linear (division by 1, 2, 3, 4, 5...)
Others: Reserved
55.4.10 TIMx hardware configuration 1 register
(TIMx_HWCFGR1)(x = 6 to 7)
Address offset: 0x3F0
Reset value: 0x1100 0100
This read register identifies the hardware configuration parameters of the instantiated IP.
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CNT_DIR[3:0] | DMA_IMPL[3:0] | BK_IMPL[3:0] | ETR_IMPL[3:0] | ||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| RCR_IMPL[3:0] | NB_OF_SM[3:0] | NB_OF_DT[3:0] | NB_OF_CC[3:0] | ||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
- Bits 31:28 CNT_DIR[3:0]: Counter direction
0x0: Down-counter only
0x1: Up-counter only
0x2: Up/Down counter allowing center-aligned mode
Others: Reserved - Bits 27:24 DMA_IMPL[3:0]: DMA features implementation
0x0: DMA requests are not possible
0x1: Single DMA requests possible
0x2: All DMA features implemented
Others: Reserved - Bits 23:20 BK_IMPL[3:0]: Break circuit implementation
0x0: no break implemented
0x1: break1 implemented without filter (tim_brk + tim_sys_brk connected)
0x2: break1 implemented with filter (tim_brk + tim_sys_brk connected)
0x3: break 1 and 2 implemented (tim_brk + tim_sys_brk + brk2)
Others: Reserved - Bits 19:16 ETR_IMPL[3:0]: External trigger implementation
0x0: External trigger circuit not implemented, tim_ocrefx cleared by tim_ocref_clr input
0x1: External trigger circuit implemented, tim_ocrefx cleared by tim_ocref_clr input
0x2: External trigger circuit implemented, tim_ocrefx cleared by tim_etr signal
0x3: External trigger circuit implemented, tim_ocrefx cleared by tim_ocref_clr or tim_etr (1 control bit “OCCS” added in GPT_SMCR)
Others: Reserved - Bits 15:12 RCR_IMPL[3:0]: Repetition counter implementation
0x0: repetition counter not implemented
0x1: 8-bit repetition counter implemented
0x2: 16-bit repetition counter implemented
Others: Reserved - Bits 11:8 NB_OF_SM[3:0]: Number of synchronization module
0x0: synchronization module not implemented
0x1: 1 synchronization module implemented
Others: Reserved - Bits 7:4 NB_OF_DT[3:0]: Number of complementary outputs and dead-time generators
0x0
0x1
0x2
0x3
0x4
Others: Reserved - Bits 3:0 NB_OF_CC[3:0]: Number of capture / compare channel
0x0: no capture/compare channel implemented
0x1: only CC1 channel is implemented
0x2: CC1 and CC2 channels are implemented
0x3: CC1, CC2 and CC3 channels are implemented
0x4: CC1, CC2, CC3 and CC4 channels are implemented
0x5: CC1, CC2, CC3, CC4 and CC5 channels are implemented
0x6: CC1, CC2, CC3, CC4, CC5 and CC6 channels are implemented
Others: Reserved
55.4.11 TIMx IP version register (TIMx_VERR)(x = 6 to 7)
Address offset: 0x3F4
Reset value: 0x0000 0043
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | MAJREV[3:0] | MINREV[3:0] | ||||||
| r | r | r | r | r | r | r | r | ||||||||
Bits 31:8 Reserved, must be kept at reset value.
Bits 7:4 MAJREV[3:0]: Major revision number.
0x4
Bits 3:0 MINREV[3:0]: Minor revision number.
0x3
55.4.12 TIMx IP identification register (TIMx_IPIDR)(x = 6 to 7)
Address offset: 0x3F8
Reset value: 0x0012 0002
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| ID[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| ID[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 ID[31:0]: IP identification code.
0x00120002
55.4.13 TIMx size ID register (TIMx_SIDR)(x = 6 to 7)
Address offset: 0x3FC
Reset value: 0xA3C5 DD01
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| SID[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| SID[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:8 SID[31:8]: Fixed code.
0xA3C5DD
Bits 7:0 SID[7:0]: Offset in KB of the ID register base address from the IP base address.
0x1: 1KB offset
55.4.14 TIMx register map
TIMx registers are mapped as 16-bit addressable registers as described in the table below:
Table 564. TIMx register map and reset values
| Offset | Register name | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x00 | TIMx_CR1 | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | DITHEN | UIFREMA | Res. | Res. | Res. | ARPE | Res. | Res. | Res. | OPM | URS | UDIS | CEN | ||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||||||||||||||||||||||
| 0x04 | TIMx_CR2 | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | MMS [2:0] | Res. | Res. | Res. | Res. | ||||
| Reset value | 0 | 0 | 0 | ||||||||||||||||||||||||||||||||
| 0x08 | Reserved | ||||||||||||||||||||||||||||||||||
| 0x0C | TIMx_DIER | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | UDE | Res. | Res. | Res. | Res. | Res. | Res. | Res. | UIE | ||
| Reset value | 0 | 0 | |||||||||||||||||||||||||||||||||
| 0x10 | TIMx_SR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | UIF | ||
| Reset value | 0 | ||||||||||||||||||||||||||||||||||
| 0x14 | TIMx_EGR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | UG | ||
| Reset value | 0 | ||||||||||||||||||||||||||||||||||
| 0x18-0x20 | Reserved | ||||||||||||||||||||||||||||||||||
| 0x24 | TIMx_CNT | UIFCPY or Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CNT[15:0] | ||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||||||||||||
| 0x28 | TIMx_PSC | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | PSC[15:0] | |||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||||||||||||||||||
| 0x2C | TIMx_ARR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | ARR[19:0] | |||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||||||||||||||||
| 0x3EC | TIMx_HWCFG R2 | Res. | Res. | Res. | Res. | Res. | Res. | Res. | OPTIONREG_OUT[7:0] | CNT_WIDTH[3:0] | PSC_WIDTH16 [3:0] | PSC_LINEAR[3:0] | |||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | ||||||||||
| 0x3F0 | TIMx_HWCFG R1 | CNT_DIR[3:0] | DMA_IMPL[3:0] | BK_IMPL[3:0] | ETR_IMPL[3:0] | RCR_IMPL[3:0] | NB_OF_SM[3:0] | NB_OF_DT[3:0] | NB_OF_CC[3:0] | ||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x3F4 | TIMx_VERR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | MAJREV [3:0] | MINREV [3:0] | |||||||||
| Reset value | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | ||||||||||||||||||||||||||

Table 564. TIMx register map and reset values (continued)
| Offset | Register name | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x3F8 | TIMx_IPIDR | ID[31:16] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | |
| 0x3FC | TIMx_SIDR | SID[31:16] | |||||||||||||||||||||||||||||||
| Reset value | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | |
Refer to Section 2.4: Memory organization for the register boundary addresses.