STMicroelectronics RM0365 User manual

January 2017 DocID025202 Rev 7 1/1080
1
RM0365
Reference manual
STM32F302xB/C/D/E and STM32F302x6/8
advanced ARM®-based 32-bit MCUs
Introduction
This reference manual targets application developers. It provides complete information on
how to use the STM32F302xB/C/D/E and STM32F302x6/8 microcontroller memory and
peripherals. The STM32F302xB/C/D/E and STM32F302x6/8 devices are referred to as
STM32F302xx throughout the document, unless otherwise specified.
The STM32F302xx is a family of microcontrollers with different memory sizes, packages
and peripherals.
For ordering information, mechanical and electrical device characteristics please refer to the
STM32F302xB/C, STM32F302xD/E and STM32F302x6/8 datasheets.
For information on the ARM®Cortex®-M4 core with FPU, refer to the
STM32F3xx/STM32F4xx programming manual (PM0214).
Related documents
•STM32F302xB/C, STM32F302xd/E and STM32F302x6/8 datasheets available from
www.st.com
•STM32F3xx/F4xx ARM®Cortex®-M4 programming manual (PM0214) available from
www.st.com.
www.st.com

DocID025202 Rev 7 2/1080
RM0365 Contents
27
Contents
1 Overview of the manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2 Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.1 List of abbreviations for registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.2 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.3 Peripheral availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3 System and memory overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.1 System architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.1.1 S0: I-bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.1.2 S1: D-bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.1.3 S2: S-bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.1.4 S3, S4: DMA-bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.1.5 BusMatrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.2 Memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.2.2 Memory map and register boundary addresses . . . . . . . . . . . . . . . . . . 47
3.3 Embedded SRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.3.1 Parity check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.4 Flash memory overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.5 Boot configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.5.1 Embedded boot loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4 Embedded Flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.1 Flash main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2 Flash memory functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.1 Flash memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.2 Read operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.2.3 Flash program and erase operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.3 Memory protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.3.1 Read protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.3.2 Write protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.3.3 Option byte block write protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Contents RM0365
3/1080 DocID025202 Rev 7
4.4 Flash interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.5 Flash register description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.5.1 Flash access control register (FLASH_ACR) . . . . . . . . . . . . . . . . . . . . 71
4.5.2 Flash key register (FLASH_KEYR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.5.3 Flash option key register (FLASH_OPTKEYR) . . . . . . . . . . . . . . . . . . . 72
4.5.4 Flash status register (FLASH_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.5.5 Flash control register (FLASH_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.5.6 Flash address register (FLASH_AR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.5.7 Option byte register (FLASH_OBR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.5.8 Write protection register (FLASH_WRPR) . . . . . . . . . . . . . . . . . . . . . . . 76
4.6 Flash register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5 Option byte description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6 Cyclic redundancy check calculation unit (CRC) . . . . . . . . . . . . . . . . . 81
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.2 CRC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.3 CRC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.3.1 CRC block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.3.2 CRC internal signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.3.3 CRC operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.4 CRC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.4.1 Data register (CRC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.4.2 Independent data register (CRC_IDR) . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.4.3 Control register (CRC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.4.4 Initial CRC value (CRC_INIT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.4.5 CRC polynomial (CRC_POL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
6.4.6 CRC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7 Peripheral interconnect matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.2 Connection summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.3 Interconnection details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.3.1 DMA interconnections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.3.2 From ADC to ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.3.3 From ADC to TIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

DocID025202 Rev 7 4/1080
RM0365 Contents
27
7.3.4 From TIM and EXTI to ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.3.5 From OPAMP to ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.3.6 From TS to ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.3.7 From VBAT to ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.3.8 From VREFINT to ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.3.9 From COMP to TIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.3.10 From TIM to COMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.3.11 From DAC to COMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.3.12 From VREFINT to COMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.3.13 From DAC to OPAMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.3.14 From TIM to OPAMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.3.15 From TIM to TIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.3.16 From break input sources to TIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.3.17 From HSE, HSI, LSE, LSI, MCO, RTC to TIM . . . . . . . . . . . . . . . . . . . . 95
7.3.18 From TIM and EXTI to DAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.3.19 From TIM to IRTIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
8 Power control (PWR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.1 Power supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.1.1 Independent A/D and D/A converter supply and reference voltage . . . . 98
8.1.2 Battery backup domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
8.1.3 Voltage regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.2 Power supply supervisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.2.1 Power on reset (POR)/power down reset (PDR) . . . . . . . . . . . . . . . . . 100
8.2.2 Programmable voltage detector (PVD) . . . . . . . . . . . . . . . . . . . . . . . . 101
8.3 Low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.3.1 Slowing down system clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.3.2 Peripheral clock gating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
8.3.3 Sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
8.3.4 Stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.3.5 Standby mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
8.3.6 Auto-wakeup from low-power mode . . . . . . . . . . . . . . . . . . . . . . . . . . 108
8.4 Power control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
8.4.1 Power control register (PWR_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
8.4.2 Power control/status register (PWR_CSR) . . . . . . . . . . . . . . . . . . . . . 110
8.4.3 PWR register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Contents RM0365
5/1080 DocID025202 Rev 7
9 Reset and clock control (RCC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
9.1 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
9.1.1 Power reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
9.1.2 System reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
9.1.3 RTC domain reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
9.2 Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
9.2.1 HSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
9.2.2 HSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
9.2.3 PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.2.4 LSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.2.5 LSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.2.6 System clock (SYSCLK) selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.2.7 Clock security system (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.2.8 ADC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
9.2.9 RTC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
9.2.10 Timers (TIMx) clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
9.2.11 Watchdog clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
9.2.12 I2S clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
9.2.13 Clock-out capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
9.2.14 Internal/external clock measurement with TIM16 . . . . . . . . . . . . . . . . 125
9.3 Low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.4 RCC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.4.1 Clock control register (RCC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.4.2 Clock configuration register (RCC_CFGR) . . . . . . . . . . . . . . . . . . . . . 128
9.4.3 Clock interrupt register (RCC_CIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
9.4.4 APB2 peripheral reset register (RCC_APB2RSTR) . . . . . . . . . . . . . . 134
9.4.5 APB1 peripheral reset register (RCC_APB1RSTR) . . . . . . . . . . . . . . 136
9.4.6 AHB peripheral clock enable register (RCC_AHBENR) . . . . . . . . . . . 138
9.4.7 APB2 peripheral clock enable register (RCC_APB2ENR) . . . . . . . . . . 140
9.4.8 APB1 peripheral clock enable register (RCC_APB1ENR) . . . . . . . . . . 141
9.4.9 RTC domain control register (RCC_BDCR) . . . . . . . . . . . . . . . . . . . . . 144
9.4.10 Control/status register (RCC_CSR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
9.4.11 AHB peripheral reset register (RCC_AHBRSTR) . . . . . . . . . . . . . . . . 147
9.4.12 Clock configuration register 2 (RCC_CFGR2) . . . . . . . . . . . . . . . . . . . 148
9.4.13 Clock configuration register 3 (RCC_CFGR3) . . . . . . . . . . . . . . . . . . . 150
9.4.14 RCC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

DocID025202 Rev 7 6/1080
RM0365 Contents
27
10 General-purpose I/Os (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
10.2 GPIO main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
10.3 GPIO functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
10.3.1 General-purpose I/O (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
10.3.2 I/O pin alternate function multiplexer and mapping . . . . . . . . . . . . . . . 158
10.3.3 I/O port control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
10.3.4 I/O port data registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
10.3.5 I/O data bitwise handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
10.3.6 GPIO locking mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
10.3.7 I/O alternate function input/output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
10.3.8 External interrupt/wakeup lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
10.3.9 Input configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
10.3.10 Output configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
10.3.11 Alternate function configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
10.3.12 Analog configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
10.3.13 Using the HSE or LSE oscillator pins as GPIOs . . . . . . . . . . . . . . . . . 163
10.3.14 Using the GPIO pins in the RTC supply domain . . . . . . . . . . . . . . . . . 163
10.4 GPIO registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
10.4.1 GPIO port mode register (GPIOx_MODER) (x =A..H) . . . . . . . . . . . . . 164
10.4.2 GPIO port output type register (GPIOx_OTYPER) (x = A..H) . . . . . . . 164
10.4.3 GPIO port output speed register (GPIOx_OSPEEDR)
(x = A..H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
10.4.4 GPIO port pull-up/pull-down register (GPIOx_PUPDR)
(x = A..H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
10.4.5 GPIO port input data register (GPIOx_IDR) (x = A..H) . . . . . . . . . . . . 166
10.4.6 GPIO port output data register (GPIOx_ODR) (x = A..H) . . . . . . . . . . 166
10.4.7 GPIO port bit set/reset register (GPIOx_BSRR) (x = A..H) . . . . . . . . . 166
10.4.8 GPIO port configuration lock register (GPIOx_LCKR)
(x = A..H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
10.4.9 GPIO alternate function low register (GPIOx_AFRL)
(x = A..H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
10.4.10 GPIO alternate function high register (GPIOx_AFRH)
(x = A..H) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
10.4.11 GPIO port bit reset register (GPIOx_BRR) (x =A..H) . . . . . . . . . . . . . . 169
10.4.12 GPIO register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
11 System configuration controller (SYSCFG) . . . . . . . . . . . . . . . . . . . . 172

Contents RM0365
7/1080 DocID025202 Rev 7
11.1 SYSCFG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
11.1.1 SYSCFG configuration register 1 (SYSCFG_CFGR1) . . . . . . . . . . . . 172
11.1.2 SYSCFG external interrupt configuration register 1
(SYSCFG_EXTICR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
11.1.3 SYSCFG external interrupt configuration register 2
(SYSCFG_EXTICR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
11.1.4 SYSCFG external interrupt configuration register 3
(SYSCFG_EXTICR3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
11.1.5 SYSCFG external interrupt configuration register 4
(SYSCFG_EXTICR4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
11.1.6 SYSCFG configuration register 2 (SYSCFG_CFGR2) . . . . . . . . . . . . 180
11.1.7 SYSCFG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
12 Direct memory access controller (DMA) . . . . . . . . . . . . . . . . . . . . . . . 183
12.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
12.2 DMA main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
12.3 DMA implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
12.4 DMA functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
12.4.1 DMA transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
12.4.2 Arbiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
12.4.3 DMA channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
12.4.4 Programmable data width, data alignment and endians . . . . . . . . . . . 187
12.4.5 Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
12.4.6 DMA interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
12.4.7 DMA request mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
12.5 DMA registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
12.5.1 DMA interrupt status register (DMA_ISR) . . . . . . . . . . . . . . . . . . . . . . 196
12.5.2 DMA interrupt flag clear register (DMA_IFCR) . . . . . . . . . . . . . . . . . . 197
12.5.3 DMA channel x configuration register (DMA_CCRx)
(x = 1..7 , where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . 198
12.5.4 DMA channel x number of data register (DMA_CNDTRx) (x = 1..7,
where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
12.5.5 DMA channel x peripheral address register (DMA_CPARx) (x = 1..7,
where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
12.5.6 DMA channel x memory address register (DMA_CMARx) (x = 1..7,
where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
12.5.7 DMA register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
13 Interrupts and events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

DocID025202 Rev 7 8/1080
RM0365 Contents
27
13.1 Nested vectored interrupt controller (NVIC) . . . . . . . . . . . . . . . . . . . . . . 205
13.1.1 NVIC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
13.1.2 SysTick calibration value register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
13.1.3 Interrupt and exception vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
13.2 Extended interrupts and events controller (EXTI) . . . . . . . . . . . . . . . . . 212
13.2.1 Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
13.2.2 Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
13.2.3 Wakeup event management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
13.2.4 Asynchronous Internal Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
13.2.5 Functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
13.2.6 External and internal interrupt/event line mapping . . . . . . . . . . . . . . . 215
13.3 EXTI registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
13.3.1 Interrupt mask register (EXTI_IMR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 217
13.3.2 Event mask register (EXTI_EMR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
13.3.3 Rising trigger selection register (EXTI_RTSR1) . . . . . . . . . . . . . . . . . 219
13.3.4 Falling trigger selection register (EXTI_FTSR1) . . . . . . . . . . . . . . . . . 219
13.3.5 Software interrupt event register (EXTI_SWIER1) . . . . . . . . . . . . . . . 220
13.3.6 Pending register (EXTI_PR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
13.3.7 Interrupt mask register (EXTI_IMR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 221
13.3.8 Event mask register (EXTI_EMR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
13.3.9 Rising trigger selection register (EXTI_RTSR2) . . . . . . . . . . . . . . . . . 222
13.3.10 Falling trigger selection register (EXTI_FTSR2) . . . . . . . . . . . . . . . . . 222
13.3.11 Software interrupt event register (EXTI_SWIER2) . . . . . . . . . . . . . . . 223
13.3.12 Pending register (EXTI_PR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
13.3.13 EXTI register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
14 Flexible static memory controller (FSMC) . . . . . . . . . . . . . . . . . . . . . 227
14.1 FMC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
14.2 Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
14.3 AHB interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
14.3.1 Supported memories and transactions . . . . . . . . . . . . . . . . . . . . . . . . 229
14.4 External device address mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
14.4.1 NOR/PSRAM address mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
14.4.2 NAND Flash memory/PC Card address mapping . . . . . . . . . . . . . . . . 232
14.5 NOR Flash/PSRAM controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
14.5.1 External memory interface signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

Contents RM0365
9/1080 DocID025202 Rev 7
14.5.2 Supported memories and transactions . . . . . . . . . . . . . . . . . . . . . . . . 236
14.5.3 General timing rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
14.5.4 NOR Flash/PSRAM controller asynchronous transactions . . . . . . . . . 238
14.5.5 Synchronous transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
14.5.6 NOR/PSRAM controller registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
14.6 NAND Flash/PC Card controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
14.6.1 External memory interface signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
14.6.2 NAND Flash / PC Card supported memories and transactions . . . . . . 272
14.6.3 Timing diagrams for NAND Flash memory and PC Card . . . . . . . . . . 272
14.6.4 NAND Flash operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
14.6.5 NAND Flash prewait functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
14.6.6 Computation of the error correction code (ECC)
in NAND Flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
14.6.7 PC Card/CompactFlash operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
14.6.8 NAND Flash/PC Card controller registers . . . . . . . . . . . . . . . . . . . . . . 278
14.7 FMC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
15 Analog-to-digital converters (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
15.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
15.2 ADC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
15.3 ADC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
15.3.1 ADC block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
15.3.2 Pins and internal signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
15.3.3 Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
15.3.4 ADC1/2 connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
15.3.5 Slave AHB interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
15.3.6 ADC voltage regulator (ADVREGEN) . . . . . . . . . . . . . . . . . . . . . . . . . 295
15.3.7 Single-ended and differential input channels . . . . . . . . . . . . . . . . . . . . 295
15.3.8 Calibration (ADCAL, ADCALDIF, ADCx_CALFACT) . . . . . . . . . . . . . . 296
15.3.9 ADC on-off control (ADEN, ADDIS, ADRDY) . . . . . . . . . . . . . . . . . . . 299
15.3.10 Constraints when writing the ADC control bits . . . . . . . . . . . . . . . . . . . 300
15.3.11 Channel selection (SQRx, JSQRx) . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
15.3.12 Channel-wise programmable sampling time (SMPR1, SMPR2) . . . . . 301
15.3.13 Single conversion mode (CONT=0) . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
15.3.14 Continuous conversion mode (CONT=1) . . . . . . . . . . . . . . . . . . . . . . . 302
15.3.15 Starting conversions (ADSTART, JADSTART) . . . . . . . . . . . . . . . . . . . 303
15.3.16 Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304

DocID025202 Rev 7 10/1080
RM0365 Contents
27
15.3.17 Stopping an ongoing conversion (ADSTP, JADSTP) . . . . . . . . . . . . . . 304
15.3.18 Conversion on external trigger and trigger polarity (EXTSEL, EXTEN,
JEXTSEL, JEXTEN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
15.3.19 Injected channel management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
15.3.20 Discontinuous mode (DISCEN, DISCNUM, JDISCEN) . . . . . . . . . . . . 310
15.3.21 Queue of context for injected conversions . . . . . . . . . . . . . . . . . . . . . . 311
15.3.22 Programmable resolution (RES) - fast conversion mode . . . . . . . . . . 319
15.3.23 End of conversion, end of sampling phase (EOC, JEOC, EOSMP) . . 320
15.3.24 End of conversion sequence (EOS, JEOS) . . . . . . . . . . . . . . . . . . . . . 320
15.3.25 Timing diagrams example (single/continuous modes,
hardware/software triggers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
15.3.26 Data management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
15.3.27 Dynamic low-power features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
15.3.28 Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL,
AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx) . . . . 333
15.3.29 Dual ADC modes (STM32F302xB/C/D/E only) . . . . . . . . . . . . . . . . . . 337
15.3.30 Temperature sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
15.3.31 VBAT supply monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
15.3.32 Monitoring the internal voltage reference . . . . . . . . . . . . . . . . . . . . . . 353
15.4 ADC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
15.5 ADC registers (for each ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
15.5.1 ADC interrupt and status register (ADCx_ISR, x=1..2) . . . . . . . . . . . . 356
15.5.2 ADC interrupt enable register (ADCx_IER, x=1..2) . . . . . . . . . . . . . . . 358
15.5.3 ADC control register (ADCx_CR, x=1..2) . . . . . . . . . . . . . . . . . . . . . . . 360
15.5.4 ADC configuration register (ADCx_CFGR, x=1..2) . . . . . . . . . . . . . . . 363
15.5.5 ADC sample time register 1 (ADCx_SMPR1, x=1..2) . . . . . . . . . . . . . 367
15.5.6 ADC sample time register 2 (ADCx_SMPR2, x=1..2) . . . . . . . . . . . . . 369
15.5.7 ADC watchdog threshold register 1 (ADCx_TR1, x=1..2) . . . . . . . . . . 369
15.5.8 ADC watchdog threshold register 2 (ADCx_TR2, x = 1..2) . . . . . . . . . 370
15.5.9 ADC watchdog threshold register 3 (ADCx_TR3, x=1..2) . . . . . . . . . . 371
15.5.10 ADC regular sequence register 1 (ADCx_SQR1, x=1..2) . . . . . . . . . . 372
15.5.11 ADC regular sequence register 2 (ADCx_SQR2, x=1..2) . . . . . . . . . . 373
15.5.12 ADC regular sequence register 3 (ADCx_SQR3, x=1..2) . . . . . . . . . . 375
15.5.13 ADC regular sequence register 4 (ADCx_SQR4, x=1..2) . . . . . . . . . . 376
15.5.14 ADC regular Data Register (ADCx_DR, x=1..2) . . . . . . . . . . . . . . . . . 377
15.5.15 ADC injected sequence register (ADCx_JSQR, x=1..2) . . . . . . . . . . . 378
15.5.16 ADC offset register (ADCx_OFRy, x=1..2) (y=1..4) . . . . . . . . . . . . . . . 380
15.5.17 ADC injected data register (ADCx_JDRy, x=1..2, y= 1..4) . . . . . . . . . . 381

Contents RM0365
11/1080 DocID025202 Rev 7
15.5.18 ADC Analog Watchdog 2 Configuration Register (ADCx_AWD2CR,
x=1..2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
15.5.19 ADC Analog Watchdog 3 Configuration Register (ADCx_AWD3CR,
x=1..2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
15.5.20 ADC Differential Mode Selection Register (ADCx_DIFSEL, x=1..2) . . 382
15.5.21 ADC Calibration Factors (ADCx_CALFACT, x=1..2) . . . . . . . . . . . . . . 383
15.6 ADC common registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
15.6.1 ADC Common status register (ADCx_CSR, x=12) . . . . . . . . . . . . . . . 384
15.6.2 ADC common control register (ADCx_CCR, x=12) . . . . . . . . . . . . . . . 386
15.6.3 ADC common regular data register for dual mode . . . . . . . . . . . . . . . . . .
(ADCx_CDR, x=12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
15.6.4 ADC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
16 Digital-to-analog converter (DAC1) . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
16.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
16.2 DAC1 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
16.3 DAC output buffer enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
16.4 DAC channel enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
16.5 Single mode functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
16.5.1 DAC data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
16.5.2 DAC channel conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
16.5.3 DAC output voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
16.5.4 DAC trigger selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
16.6 Noise generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
16.7 Triangle-wave generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
16.8 DMA request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
16.9 DAC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
16.9.1 DAC control register (DAC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
16.9.2 DAC software trigger register (DAC_SWTRIGR) . . . . . . . . . . . . . . . . . 403
16.9.3 DAC channel1 12-bit right-aligned data holding register
(DAC_DHR12R1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
16.9.4 DAC channel1 12-bit left-aligned data holding register
(DAC_DHR12L1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
16.9.5 DAC channel1 8-bit right-aligned data holding register
(DAC_DHR8R1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
16.9.6 DAC channel1 data output register (DAC_DOR1) . . . . . . . . . . . . . . . . 404
16.9.7 DAC status register (DAC_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
16.9.8 DAC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406

DocID025202 Rev 7 12/1080
RM0365 Contents
27
17 Comparator (COMP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
17.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
17.2 COMP main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
17.3 COMP functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
17.3.1 COMP block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
17.3.2 COMP pins and internal signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
17.3.3 COMP reset and clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
17.3.4 Comparator LOCK mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
17.3.5 Hysteresis (STM32F302xBxC only) . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
17.3.6 Comparator output blanking function . . . . . . . . . . . . . . . . . . . . . . . . . . 411
17.3.7 Power mode (STM32F302xB/C only) . . . . . . . . . . . . . . . . . . . . . . . . . 412
17.4 COMP interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
17.5 COMP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
17.5.1 COMP1 control and status register (COMP1_CSR) . . . . . . . . . . . . . . 413
17.5.2 COMP2 control and status register (COMP2_CSR) . . . . . . . . . . . . . . 415
17.5.3 COMP4 control and status register (COMP4_CSR) . . . . . . . . . . . . . . 418
17.5.4 COMP6 control and status register (COMP6_CSR) . . . . . . . . . . . . . . 420
17.5.5 COMP register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
18 Operational amplifier (OPAMP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
18.1 OPAMP introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
18.2 OPAMP main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
18.3 OPAMP functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
18.3.1 General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
18.3.2 Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
18.3.3 Operational amplifiers and comparators interconnections . . . . . . . . . . 424
18.3.4 Using the OPAMP outputs as ADC inputs . . . . . . . . . . . . . . . . . . . . . . 425
18.3.5 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
18.3.6 Timer controlled Multiplexer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
18.3.7 OPAMP modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
18.4 OPAMP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
18.4.1 OPAMP1 control register (OPAMP1_CSR) . . . . . . . . . . . . . . . . . . . . . 431
18.4.2 OPAMP2 control register (OPAMP2_CSR) . . . . . . . . . . . . . . . . . . . . . 433
18.4.3 OPAMP register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
19 Touch sensing controller (TSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

Contents RM0365
13/1080 DocID025202 Rev 7
19.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
19.2 TSC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
19.3 TSC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
19.3.1 TSC block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
19.3.2 Surface charge transfer acquisition overview . . . . . . . . . . . . . . . . . . . 438
19.3.3 Reset and clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
19.3.4 Charge transfer acquisition sequence . . . . . . . . . . . . . . . . . . . . . . . . . 441
19.3.5 Spread spectrum feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
19.3.6 Max count error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
19.3.7 Sampling capacitor I/O and channel I/O mode selection . . . . . . . . . . . 443
19.3.8 Acquisition mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
19.3.9 I/O hysteresis and analog switch control . . . . . . . . . . . . . . . . . . . . . . . 444
19.4 TSC low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
19.5 TSC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
19.6 TSC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
19.6.1 TSC control register (TSC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
19.6.2 TSC interrupt enable register (TSC_IER) . . . . . . . . . . . . . . . . . . . . . . 448
19.6.3 TSC interrupt clear register (TSC_ICR) . . . . . . . . . . . . . . . . . . . . . . . . 449
19.6.4 TSC interrupt status register (TSC_ISR) . . . . . . . . . . . . . . . . . . . . . . . 450
19.6.5 TSC I/O hysteresis control register (TSC_IOHCR) . . . . . . . . . . . . . . . 450
19.6.6 TSC I/O analog switch control register (TSC_IOASCR) . . . . . . . . . . . 451
19.6.7 TSC I/O sampling control register (TSC_IOSCR) . . . . . . . . . . . . . . . . 451
19.6.8 TSC I/O channel control register (TSC_IOCCR) . . . . . . . . . . . . . . . . . 452
19.6.9 TSC I/O group control status register (TSC_IOGCSR) . . . . . . . . . . . . 452
19.6.10 TSC I/O group x counter register (TSC_IOGxCR) (x = 1..8) . . . . . . . . 453
19.6.11 TSC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
20 Advanced-control timers (TIM1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
20.1 TIM1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
20.2 TIM1 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
20.3 TIM1 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
20.3.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
20.3.2 Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
20.3.3 Repetition counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
20.3.4 External trigger input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
20.3.5 Clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474

DocID025202 Rev 7 14/1080
RM0365 Contents
27
20.3.6 Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
20.3.7 Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
20.3.8 PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
20.3.9 Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
20.3.10 Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
20.3.11 PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
20.3.12 Asymmetric PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
20.3.13 Combined PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
20.3.14 Combined 3-phase PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
20.3.15 Complementary outputs and dead-time insertion . . . . . . . . . . . . . . . . 491
20.3.16 Using the break function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
20.3.17 Clearing the OCxREF signal on an external event . . . . . . . . . . . . . . . 498
20.3.18 6-step PWM generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
20.3.19 One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
20.3.20 Retriggerable one pulse mode (OPM) . . . . . . . . . . . . . . . . . . . . . . . . . 502
20.3.21 Encoder interface mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
20.3.22 UIF bit remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
20.3.23 Timer input XOR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
20.3.24 Interfacing with Hall sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
20.3.25 Timer synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
20.3.26 ADC synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
20.3.27 DMA burst mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
20.3.28 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
20.4 TIM1 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
20.4.1 TIM1 control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 515
20.4.2 TIM1 control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 516
20.4.3 TIM1 slave mode control register (TIMx_SMCR) . . . . . . . . . . . . . . . . 519
20.4.4 TIM1 DMA/interrupt enable register (TIMx_DIER) . . . . . . . . . . . . . . . . 521
20.4.5 TIM1 status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
20.4.6 TIM1 event generation register (TIMx_EGR) . . . . . . . . . . . . . . . . . . . . 525
20.4.7 TIM1 capture/compare mode register 1 (TIMx_CCMR1) . . . . . . . . . . . 526
20.4.8 TIM1 capture/compare mode register 2 (TIMx_CCMR2) . . . . . . . . . . . 530
20.4.9 TIM1 capture/compare enable register (TIMx_CCER) . . . . . . . . . . . . 532
20.4.10 TIM1 counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
20.4.11 TIM1 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
20.4.12 TIM1 auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . . . . . . . . 536
20.4.13 TIM1 repetition counter register (TIMx_RCR) . . . . . . . . . . . . . . . . . . . 537

Contents RM0365
15/1080 DocID025202 Rev 7
20.4.14 TIM1 capture/compare register 1 (TIMx_CCR1) . . . . . . . . . . . . . . . . . 537
20.4.15 TIM1 capture/compare register 2 (TIMx_CCR2) . . . . . . . . . . . . . . . . . 538
20.4.16 TIM1 capture/compare register 3 (TIMx_CCR3) . . . . . . . . . . . . . . . . . 538
20.4.17 TIM1 capture/compare register 4 (TIMx_CCR4) . . . . . . . . . . . . . . . . . 539
20.4.18 TIM1 break and dead-time register (TIMx_BDTR) . . . . . . . . . . . . . . . 539
20.4.19 TIM1 DMA control register (TIMx_DCR) . . . . . . . . . . . . . . . . . . . . . . . 542
20.4.20 TIM1 DMA address for full transfer (TIMx_DMAR) . . . . . . . . . . . . . . . 543
20.4.21 TIM1 option registers (TIMx_OR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
20.4.22 TIM1 capture/compare mode register 3 (TIMx_CCMR3) . . . . . . . . . . . 544
20.4.23 TIM1 capture/compare register 5 (TIMx_CCR5) . . . . . . . . . . . . . . . . . 545
20.4.24 TIM1 capture/compare register 6 (TIMx_CCR6) . . . . . . . . . . . . . . . . . 546
20.4.25 TIM1 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
21 General-purpose timers (TIM2/TIM3/TIM4) . . . . . . . . . . . . . . . . . . . . . 550
21.1 TIM2/TIM3/TIM4 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
21.2 TIM2/TIM3/TIM4 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
21.3 TIM2/TIM3/TIM4 functional description . . . . . . . . . . . . . . . . . . . . . . . . . 552
21.3.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
21.3.2 Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
21.3.3 Clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
21.3.4 Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
21.3.5 Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
21.3.6 PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
21.3.7 Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
21.3.8 Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
21.3.9 PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
21.3.10 Asymmetric PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
21.3.11 Combined PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
21.3.12 Clearing the OCxREF signal on an external event . . . . . . . . . . . . . . . 579
21.3.13 One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
21.3.14 Retriggerable one pulse mode (OPM) . . . . . . . . . . . . . . . . . . . . . . . . . 582
21.3.15 Encoder interface mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
21.3.16 UIF bit remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
21.3.17 Timer input XOR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
21.3.18 Timers and external trigger synchronization . . . . . . . . . . . . . . . . . . . . 586
21.3.19 Timer synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
21.3.20 DMA burst mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594

DocID025202 Rev 7 16/1080
RM0365 Contents
27
21.3.21 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
21.4 TIM2/TIM3/TIM4 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
21.4.1 TIMx control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 596
21.4.2 TIMx control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 597
21.4.3 TIMx slave mode control register (TIMx_SMCR) . . . . . . . . . . . . . . . . . 599
21.4.4 TIMx DMA/Interrupt enable register (TIMx_DIER) . . . . . . . . . . . . . . . . 602
21.4.5 TIMx status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
21.4.6 TIMx event generation register (TIMx_EGR) . . . . . . . . . . . . . . . . . . . . 604
21.4.7 TIMx capture/compare mode register 1 (TIMx_CCMR1) . . . . . . . . . . . 605
21.4.8 TIMx capture/compare mode register 2 (TIMx_CCMR2) . . . . . . . . . . . 609
21.4.9 TIMx capture/compare enable register (TIMx_CCER) . . . . . . . . . . . . . 611
21.4.10 TIMx counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612
21.4.11 TIMx prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
21.4.12 TIMx auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . . . . . . . . 613
21.4.13 TIMx capture/compare register 1 (TIMx_CCR1) . . . . . . . . . . . . . . . . . 614
21.4.14 TIMx capture/compare register 2 (TIMx_CCR2) . . . . . . . . . . . . . . . . . 614
21.4.15 TIMx capture/compare register 3 (TIMx_CCR3) . . . . . . . . . . . . . . . . . 615
21.4.16 TIMx capture/compare register 4 (TIMx_CCR4) . . . . . . . . . . . . . . . . . 615
21.4.17 TIMx DMA control register (TIMx_DCR) . . . . . . . . . . . . . . . . . . . . . . . 616
21.4.18 TIMx DMA address for full transfer (TIMx_DMAR) . . . . . . . . . . . . . . . 616
21.4.19 TIMx register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
22 General-purpose timers (TIM15/TIM16/TIM17) . . . . . . . . . . . . . . . . . . 619
22.1 TIM15/TIM16/TIM17 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
22.2 TIM15 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
22.3 TIM16/TIM17 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
22.4 TIM15/TIM16/TIM17 functional description . . . . . . . . . . . . . . . . . . . . . . 623
22.4.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
22.4.2 Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
22.4.3 Repetition counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629
22.4.4 Clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630
22.4.5 Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
22.4.6 Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635
22.4.7 PWM input mode (only for TIM15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
22.4.8 Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
22.4.9 Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
22.4.10 PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638

Contents RM0365
17/1080 DocID025202 Rev 7
22.4.11 Combined PWM mode (TIM15 only) . . . . . . . . . . . . . . . . . . . . . . . . . . 639
22.4.12 Complementary outputs and dead-time insertion . . . . . . . . . . . . . . . . 641
22.4.13 Using the break function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
22.4.14 One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
22.4.15 UIF bit remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
22.4.16 Timer input XOR function (TIM15 only) . . . . . . . . . . . . . . . . . . . . . . . . 648
22.4.17 External trigger synchronization (TIM15 only) . . . . . . . . . . . . . . . . . . . 649
22.4.18 Slave mode: Combined reset + trigger mode (TIM15 only) . . . . . . . . . 651
22.4.19 DMA burst mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 651
22.4.20 Timer synchronization (TIM15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
22.4.21 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
22.5 TIM15 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
22.5.1 TIM15 control register 1 (TIM15_CR1) . . . . . . . . . . . . . . . . . . . . . . . . 654
22.5.2 TIM15 control register 2 (TIM15_CR2) . . . . . . . . . . . . . . . . . . . . . . . . 655
22.5.3 TIM15 slave mode control register (TIM15_SMCR) . . . . . . . . . . . . . . 657
22.5.4 TIM15 DMA/interrupt enable register (TIM15_DIER) . . . . . . . . . . . . . 658
22.5.5 TIM15 status register (TIM15_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 659
22.5.6 TIM15 event generation register (TIM15_EGR) . . . . . . . . . . . . . . . . . 661
22.5.7 TIM15 capture/compare mode register 1 (TIM15_CCMR1) . . . . . . . . 662
22.5.8 TIM15 capture/compare enable register (TIM15_CCER) . . . . . . . . . . 665
22.5.9 TIM15 counter (TIM15_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
22.5.10 TIM15 prescaler (TIM15_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
22.5.11 TIM15 auto-reload register (TIM15_ARR) . . . . . . . . . . . . . . . . . . . . . . 668
22.5.12 TIM15 repetition counter register (TIM15_RCR) . . . . . . . . . . . . . . . . . 669
22.5.13 TIM15 capture/compare register 1 (TIM15_CCR1) . . . . . . . . . . . . . . . 669
22.5.14 TIM15 capture/compare register 2 (TIM15_CCR2) . . . . . . . . . . . . . . . 670
22.5.15 TIM15 break and dead-time register (TIM15_BDTR) . . . . . . . . . . . . . 670
22.5.16 TIM15 DMA control register (TIM15_DCR) . . . . . . . . . . . . . . . . . . . . . 672
22.5.17 TIM15 DMA address for full transfer (TIM15_DMAR) . . . . . . . . . . . . . 672
22.5.18 TIM15 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673
22.6 TIM16/TIM17 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
22.6.1 TIM16/TIM17 control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . 675
22.6.2 TIM16/TIM17 control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . 676
22.6.3 TIM16/TIM17 DMA/interrupt enable register (TIMx_DIER) . . . . . . . . . 677
22.6.4 TIM16/TIM17 status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . 678
22.6.5 TIM16/TIM17 event generation register (TIMx_EGR) . . . . . . . . . . . . . 679
22.6.6 TIM16/TIM17 capture/compare mode register 1 (TIMx_CCMR1) . . . . 680

DocID025202 Rev 7 18/1080
RM0365 Contents
27
22.6.7 TIM16/TIM17 capture/compare enable register (TIMx_CCER) . . . . . . 682
22.6.8 TIM16/TIM17 counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . 684
22.6.9 TIM16/TIM17 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . 685
22.6.10 TIM16/TIM17 auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . 685
22.6.11 TIM16/TIM17 repetition counter register (TIMx_RCR) . . . . . . . . . . . . 686
22.6.12 TIM16/TIM17 capture/compare register 1 (TIMx_CCR1) . . . . . . . . . . 686
22.6.13 TIM16/TIM17 break and dead-time register (TIMx_BDTR) . . . . . . . . . 687
22.6.14 TIM16/TIM17 DMA control register (TIMx_DCR) . . . . . . . . . . . . . . . . 689
22.6.15 TIM16/TIM17 DMA address for full transfer (TIMx_DMAR) . . . . . . . . . 689
22.6.16 TIM16 option register (TIM16_OR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
22.6.17 TIM16/TIM17 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691
23 Basic timers (TIM6) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
23.1 TIM6 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
23.2 TIM6 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
23.3 TIM6 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694
23.3.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694
23.3.2 Counting mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
23.3.3 UIF bit remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
23.3.4 Clock source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
23.3.5 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
23.4 TIM6 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
23.4.1 TIM6 control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 700
23.4.2 TIM6 control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 702
23.4.3 TIM6 DMA/Interrupt enable register (TIMx_DIER) . . . . . . . . . . . . . . . 702
23.4.4 TIM6 status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
23.4.5 TIM6 event generation register (TIMx_EGR) . . . . . . . . . . . . . . . . . . . . 703
23.4.6 TIM6 counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
23.4.7 TIM6 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
23.4.8 TIM6 auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . . . . . . . . 704
23.4.9 TIM6 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705
24 Infrared interface (IRTIM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706
25 System window watchdog (WWDG) . . . . . . . . . . . . . . . . . . . . . . . . . . 707
25.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
25.2 WWDG main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707

Contents RM0365
19/1080 DocID025202 Rev 7
25.3 WWDG functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
25.3.1 Enabling the watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708
25.3.2 Controlling the downcounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708
25.3.3 Advanced watchdog interrupt feature . . . . . . . . . . . . . . . . . . . . . . . . . 708
25.3.4 How to program the watchdog timeout . . . . . . . . . . . . . . . . . . . . . . . . 709
25.3.5 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
25.4 WWDG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
25.4.1 Control register (WWDG_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
25.4.2 Configuration register (WWDG_CFR) . . . . . . . . . . . . . . . . . . . . . . . . . 711
25.4.3 Status register (WWDG_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
25.4.4 WWDG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
26 Independent watchdog (IWDG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
26.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
26.2 IWDG main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
26.3 IWDG functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
26.3.1 IWDG block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
26.3.2 Window option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
26.3.3 Hardware watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
26.3.4 Behavior in Stop and Standby modes . . . . . . . . . . . . . . . . . . . . . . . . . 715
26.3.5 Register access protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
26.3.6 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
26.4 IWDG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716
26.4.1 Key register (IWDG_KR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716
26.4.2 Prescaler register (IWDG_PR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
26.4.3 Reload register (IWDG_RLR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718
26.4.4 Status register (IWDG_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719
26.4.5 Window register (IWDG_WINR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
26.4.6 IWDG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
27 Real-time clock (RTC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
27.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
27.2 RTC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723
27.3 RTC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
27.3.1 RTC block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
27.3.2 GPIOs controlled by the RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725

DocID025202 Rev 7 20/1080
RM0365 Contents
27
27.3.3 Clock and prescalers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
27.3.4 Real-time clock and calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
27.3.5 Programmable alarms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
27.3.6 Periodic auto-wakeup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
27.3.7 RTC initialization and configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 729
27.3.8 Reading the calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
27.3.9 Resetting the RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731
27.3.10 RTC synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
27.3.11 RTC reference clock detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
27.3.12 RTC smooth digital calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
27.3.13 Time-stamp function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
27.3.14 Tamper detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
27.3.15 Calibration clock output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737
27.3.16 Alarm output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738
27.4 RTC low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738
27.5 RTC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738
27.6 RTC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
27.6.1 RTC time register (RTC_TR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
27.6.2 RTC date register (RTC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740
27.6.3 RTC control register (RTC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
27.6.4 RTC initialization and status register (RTC_ISR) . . . . . . . . . . . . . . . . . 745
27.6.5 RTC prescaler register (RTC_PRER) . . . . . . . . . . . . . . . . . . . . . . . . . 748
27.6.6 RTC wakeup timer register (RTC_WUTR) . . . . . . . . . . . . . . . . . . . . . . 749
27.6.7 RTC alarm A register (RTC_ALRMAR) . . . . . . . . . . . . . . . . . . . . . . . . 750
27.6.8 RTC alarm B register (RTC_ALRMBR) . . . . . . . . . . . . . . . . . . . . . . . . 751
27.6.9 RTC write protection register (RTC_WPR) . . . . . . . . . . . . . . . . . . . . . 752
27.6.10 RTC sub second register (RTC_SSR) . . . . . . . . . . . . . . . . . . . . . . . . . 752
27.6.11 RTC shift control register (RTC_SHIFTR) . . . . . . . . . . . . . . . . . . . . . . 753
27.6.12 RTC timestamp time register (RTC_TSTR) . . . . . . . . . . . . . . . . . . . . . 754
27.6.13 RTC timestamp date register (RTC_TSDR) . . . . . . . . . . . . . . . . . . . . 755
27.6.14 RTC time-stamp sub second register (RTC_TSSSR) . . . . . . . . . . . . . 756
27.6.15 RTC calibration register (RTC_CALR) . . . . . . . . . . . . . . . . . . . . . . . . . 757
27.6.16 RTC tamper and alternate function configuration register
(RTC_TAFCR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758
27.6.17 RTC alarm A sub second register (RTC_ALRMASSR) . . . . . . . . . . . . 761
27.6.18 RTC alarm B sub second register (RTC_ALRMBSSR) . . . . . . . . . . . . 762
27.6.19 RTC backup registers (RTC_BKPxR) . . . . . . . . . . . . . . . . . . . . . . . . . 763
This manual suits for next models
6
Table of contents
Other STMicroelectronics Computer Hardware manuals

STMicroelectronics
STMicroelectronics X-NUCLEO-53L1A2 User manual

STMicroelectronics
STMicroelectronics X-NUCLEO-53L0A1 User manual

STMicroelectronics
STMicroelectronics X-NUCLEO-PGEEZ1 User manual

STMicroelectronics
STMicroelectronics B-G474E-DPOW1 User manual

STMicroelectronics
STMicroelectronics X-NUCLEO-IHM08M1 User manual

STMicroelectronics
STMicroelectronics STEVAL-C34KAT1 User manual

STMicroelectronics
STMicroelectronics ST8034C User manual

STMicroelectronics
STMicroelectronics STM32Cube User manual

STMicroelectronics
STMicroelectronics ST62GP-EMU2 HDS2 Series User manual