Feb 1, 2021 — Reference manual. STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and. STM32F107xx advanced Arm. ®. -based 32-bit MCUs.

80 KB – 1136 Pages

PAGE – 1 ============
February 2021RM0008 Rev 211/1136 1RM0008Reference manualSTM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx andSTM32F107xx advanced Arm ®-based 32-bit MCUsIntroduction This reference manual is addressed to application developers. It provides complete information on how to use the STM32F101xx, STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx microcontroller memory and peripherals. These devices, featuring different memory size s, packages and peripherals, are referred to as STM32F10xxx throughout the do cument, unless otherwise specified. For ordering information, mechanical and electr ical device characterist ics refer to the low-, medium-, high- and XL-density STM32F101xx and STM32F103xx datasheets, to the low- and medium-density STM32F102xx datasheet s and to the STM32F105xx/STM32F107xx connectivity line datasheet. For information on programming, erasing and pr otection of the internal Flash memory refer to:PM0075 for low-, medium- high-density a nd connectivity line STM32F10xxx devices PM0068 for XL-density STM32F10xxx devices. For information on the Arm ® Cortex ®-M3 core, refer to PM0056, STM32F10xxx Cortex®-M3 programming manual .Related documentsAvailable from www.st.com :STM32F101xx, STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx datasheets STM32F10xxx Cortex ®-M3 programming manual (PM0056) STM32F10xxx Flash memory programming manual (PM0075) STM32F10xxx XL-density Flash memory programming manual (PM0068) www.st.com

PAGE – 2 ============
Contents RM0008 2/1136RM0008 Rev 21 Contents 1Overview of the manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.1General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.2List of abbreviations for registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.3Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 2.4Peripheral availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 3Memory and bus architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.1System architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.2Memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 3.3Memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3.3.1Embedded SRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.3.2Bit banding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.3.3Embedded Flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.4Boot configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 4CRC calculation unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.1CRC introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.2CRC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.3CRC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 4.4CRC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 4.4.1Data register (CRC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 4.4.2Independent data register (CRC_IDR) . . . . . . . . . . . . . . . . . . . . . . . . . 65 4.4.3Control register (CRC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 4.4.4CRC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5Power control (PWR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 5.1Power supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 5.1.1Independent A/D and D/A converter s upply and reference voltage . . . . 68 5.1.2Battery backup domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.1.3Voltage regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 5.2Power supply supervisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

PAGE – 3 ============
RM0008 Rev 213/1136 RM0008 Contents265.2.1Power on reset (POR)/power down reset (PDR) . . . . . . . . . . . . . . . . . . 70 5.2.2Programmable voltage detector (PVD) . . . . . . . . . . . . . . . . . . . . . . . . . 70 5.3Low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 5.3.1Slowing down system clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 5.3.2Peripheral clock gating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.3.3Sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.3.4Stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 5.3.5Standby mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 5.3.6Auto-wakeup (AWU) from low-power mode . . . . . . . . . . . . . . . . . . . . . . 77 5.4Power control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 5.4.1Power control register (PWR_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 5.4.2Power control/status register (PWR_CSR) . . . . . . . . . . . . . . . . . . . . . . 79 5.4.3PWR register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 6Backup registers (BKP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 6.1BKP introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 6.2BKP main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 6.3BKP functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 6.3.1Tamper detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 6.3.2RTC calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 6.4BKP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 6.4.1Backup data register x ( BKP_DRx) (x = 1 ..42) . . . . . . . . . . . . . . . . . . . 83 6.4.2RTC clock calibration regi ster (BKP_RTCCR) . . . . . . . . . . . . . . . . . . . . 83 6.4.3Backup control register (BKP_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 6.4.4Backup control/stat us register (BKP_CSR) . . . . . . . . . . . . . . . . . . . . . . 84 6.4.5BKP register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 7Low-, medium-, high- and XL-density reset and clock control (RCC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 7.1Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 7.1.1System reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 7.1.2Power reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 7.1.3Backup domain reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 7.2Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 7.2.1HSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 7.2.2HSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

PAGE – 4 ============
Contents RM0008 4/1136RM0008 Rev 21 7.2.3PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 7.2.4LSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 7.2.5LSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 7.2.6System clock (SYSCLK ) selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 7.2.7Clock security system (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 7.2.8RTC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 7.2.9Watchdog clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 7.2.10Clock-out capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 7.3RCC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.3.1Clock control register (RCC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.3.2Clock configuration register (RCC_CFGR) . . . . . . . . . . . . . . . . . . . . . 101 7.3.3Clock interrupt register (RCC_CIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 7.3.4APB2 peripheral reset r egister (RCC_APB2RSTR) . . . . . . . . . . . . . . 106 7.3.5APB1 peripheral reset r egister (RCC_APB1RSTR) . . . . . . . . . . . . . . 109 7.3.6AHB peripheral clock enable register (RCC_AHBENR) . . . . . . . . . . . 111 7.3.7APB2 peripheral clock en able register (RCC_APB2ENR) . . . . . . . . . . 112 7.3.8APB1 peripheral clock en able register (RCC_APB1ENR) . . . . . . . . . . 115 7.3.9Backup domain control register (RCC_BD CR) . . . . . . . . . . . . . . . . . . 118 7.3.10Control/status register (RCC_CSR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 7.3.11RCC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 8Connectivity line devices: reset and cl ock control (RCC) . . . . . . . . . 123 8.1Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 8.1.1System reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 8.1.2Power reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 8.1.3Backup domain reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 8.2Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 8.2.1HSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 8.2.2HSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 8.2.3PLLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 8.2.4LSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 8.2.5LSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 8.2.6System clock (SYSCLK ) selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 8.2.7Clock security system (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 8.2.8RTC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 8.2.9Watchdog clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 8.2.10Clock-out capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

PAGE – 5 ============
RM0008 Rev 215/1136 RM0008 Contents268.3RCC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 8.3.1Clock control register (RCC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 8.3.2Clock configuration register (RCC_CFGR) . . . . . . . . . . . . . . . . . . . . . 134 8.3.3Clock interrupt register (RCC_CIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 8.3.4APB2 peripheral reset r egister (RCC_APB2RSTR) . . . . . . . . . . . . . . 141 8.3.5APB1 peripheral reset r egister (RCC_APB1RSTR) . . . . . . . . . . . . . . 142 8.3.6AHB Peripheral Clock enable register (RCC_AHBENR) . . . . . . . . . . . 145 8.3.7APB2 peripheral clock enable register (RCC_APB2ENR) . . . . . . . . . . 146 8.3.8APB1 peripheral clock enable register (RCC_APB1ENR) . . . . . . . . . . 148 8.3.9Backup domain control register (RCC_BD CR) . . . . . . . . . . . . . . . . . . 150 8.3.10Control/status register (RCC_CSR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 8.3.11AHB peripheral clock reset register (RCC_AHBRSTR) . . . . . . . . . . . . 153 8.3.12Clock configuration regist er2 (RCC_CFGR2) . . . . . . . . . . . . . . . . . . . 154 8.3.13RCC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 9General-purpose and al ternate-function I/Os (GPIOs and AFIOs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 9.1GPIO functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 9.1.1General-purpose I/O (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 9.1.2Atomic bit set or reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 9.1.3External interrupt/wa keup lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 9.1.4Alternate functions (AF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 9.1.5Software remapping of I/O alternate functions . . . . . . . . . . . . . . . . . . 162 9.1.6GPIO locking mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 9.1.7Input configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 9.1.8Output configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 9.1.9Alternate function configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 9.1.10Analog configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 9.1.11GPIO configurations for device peripherals . . . . . . . . . . . . . . . . . . . . . 166 9.2GPIO registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 9.2.1Port configuration register low (GPIOx_CRL) (x=A..G) . . . . . . . . . . . . 171 9.2.2Port configuration register high (GPI Ox_CRH) (x=A..G) . . . . . . . . . . . 172 9.2.3Port input data register (GPIOx_IDR) (x=A..G) . . . . . . . . . . . . . . . . . . 172 9.2.4Port output data register (GPIOx_ODR) (x=A..G) . . . . . . . . . . . . . . . . 173 9.2.5Port bit set/reset register (GPIOx_BSRR) (x=A..G) . . . . . . . . . . . . . . . 173 9.2.6Port bit reset register (GPIOx_BRR) (x=A..G) . . . . . . . . . . . . . . . . . . . 174 9.2.7Port configuration lock register (GPI Ox_LCKR) (x=A..G) . . . . . . . . . . 174

PAGE – 6 ============
Contents RM0008 6/1136RM0008 Rev 21 9.3Alternate function I/O and debug configuration (AFIO) . . . . . . . . . . . . . 175 9.3.1Using OSC32_IN/OSC32_OUT pins as GPIO ports PC14/PC15 . . . . 175 9.3.2Using OSC_IN/OSC_OUT pins as GPIO ports PD0/PD1 . . . . . . . . . . 175 9.3.3CAN1 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 9.3.4CAN2 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 9.3.5JTAG/SWD alternate function remapping . . . . . . . . . . . . . . . . . . . . . . 176 9.3.6ADC alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 9.3.7Timer alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 9.3.8USART alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . 180 9.3.9I2C1 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 9.3.10SPI1 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 9.3.11SPI3/I2S3 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . 181 9.3.12Ethernet alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . 181 9.4AFIO registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 9.4.1Event control register (AFIO_EVCR) . . . . . . . . . . . . . . . . . . . . . . . . . . 183 9.4.2AF remap and debug I/O configuration register (AFIO_MAPR) . . . . . 184 9.4.3External interrupt configuration regi ster 1 (AFIO_EXTICR1) . . . . . . . . 191 9.4.4External interrupt configuration regi ster 2 (AFIO_EXTICR2) . . . . . . . . 191 9.4.5External interrupt configuration regi ster 3 (AFIO_EXTICR3) . . . . . . . . 192 9.4.6External interrupt configuration regi ster 4 (AFIO_EXTICR4) . . . . . . . . 192 9.4.7AF remap and debug I/O configuration register2 (AFIO_MAPR2) . . . 193 9.5GPIO and AFIO register maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 10Interrupts and events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 10.1Nested vectored interrupt controller (NVIC) . . . . . . . . . . . . . . . . . . . . . . 197 10.1.1SysTick calibration value register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 10.1.2Interrupt and exception vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 10.2External interrupt/event controller (EXTI) . . . . . . . . . . . . . . . . . . . . . . . . 207 10.2.1Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 10.2.2Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 10.2.3Wakeup event management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 10.2.4Functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 10.2.5External interrupt/event line mapping . . . . . . . . . . . . . . . . . . . . . . . . . 209 10.3EXTI registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211 10.3.1Interrupt mask register (EXTI_IMR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 10.3.2Event mask register (EXTI_EM R) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

PAGE – 8 ============
Contents RM0008 8/1136RM0008 Rev 21 11.11ADC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 11.12ADC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 11.12.1ADC status register (ADC_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 11.12.2ADC control register 1 (ADC_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 11.12.3ADC control register 2 (ADC_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . 240 11.12.4ADC sample time register 1 (ADC_SMPR1) . . . . . . . . . . . . . . . . . . . . 244 11.12.5ADC sample time register 2 (ADC_SMPR2) . . . . . . . . . . . . . . . . . . . . 245 11.12.6ADC injected channel data offset register x (ADC_JOFRx) (x=1..4) . . 245 11.12.7ADC watchdog high threshold register (ADC_HTR) . . . . . . . . . . . . . . 246 11.12.8ADC watchdog low threshold register (ADC_LTR) . . . . . . . . . . . . . . . 246 11.12.9ADC regular sequence register 1 (ADC_ SQR1) . . . . . . . . . . . . . . . . . 247 11.12.10ADC regular sequence register 2 (ADC_ SQR2) . . . . . . . . . . . . . . . . . 248 11.12.11ADC regular sequence register 3 (ADC_ SQR3) . . . . . . . . . . . . . . . . . 249 11.12.12ADC injected sequence register (ADC_JSQR) . . . . . . . . . . . . . . . . . . 250 11.12.13ADC injected data register x (ADC_JDRx) (x= 1..4) . . . . . . . . . . . . . . 251 11.12.14ADC regular data register (ADC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . 251 11.12.15ADC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 12Digital-to-analog converter (DAC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 12.1DAC introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 12.2DAC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 12.3DAC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 12.3.1DAC channel enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 12.3.2DAC output buffer enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 12.3.3DAC data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 12.3.4DAC conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 12.3.5DAC output voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 12.3.6DAC trigger selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 12.3.7DMA request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 12.3.8Noise generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 12.3.9Triangle-wave generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 12.4Dual DAC channel conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 12.4.1Independent trigger without wave generatio n . . . . . . . . . . . . . . . . . . . 261 12.4.2Independent trigger with same LFSR generation . . . . . . . . . . . . . . . . 262 12.4.3Independent trigger with different LFSR generation . . . . . . . . . . . . . . 262 12.4.4Independent trigger with same triangle ge neration . . . . . . . . . . . . . . . 262

PAGE – 9 ============
RM0008 Rev 219/1136 RM0008 Contents2612.4.5Independent trigger with different triangle generation . . . . . . . . . . . . . 263 12.4.6Simultaneous software start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 12.4.7Simultaneous trigger without wave generat ion . . . . . . . . . . . . . . . . . . 263 12.4.8Simultaneous trigger with same LFSR ge neration . . . . . . . . . . . . . . . 264 12.4.9Simultaneous trigger with different LFSR generation . . . . . . . . . . . . . 264 12.4.10Simultaneous trigger with same triangl e generation . . . . . . . . . . . . . . 264 12.4.11Simultaneous trigger with different triangle generation . . . . . . . . . . . . 265 12.5DAC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 12.5.1DAC control register (DAC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 12.5.2DAC software trigger register (DAC_SWTRIGR) . . . . . . . . . . . . . . . . 268 12.5.3DAC channel1 12-bit right- aligned data holding register (DAC_DHR12R1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 12.5.4DAC channel1 12-bit left aligned data holding register (DAC_DHR12L1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 12.5.5DAC channel1 8-bit righ t aligned data holding register (DAC_DHR8R1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 12.5.6DAC channel2 12-bit right aligned data holding register (DAC_DHR12R2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 12.5.7DAC channel2 12-bit left aligned data holding register (DAC_DHR12L2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 12.5.8DAC channel2 8-bit right-aligned data holding register (DAC_DHR8R2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 12.5.9Dual DAC 12-bit right-aligned data holding register (DAC_DHR12RD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 12.5.10DUAL DAC 12-bit left aligned data holding register (DAC_DHR12LD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 12.5.11DUAL DAC 8-bit right aligned data holding register (DAC_DHR8RD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 12.5.12DAC channel1 data output register (DAC_DOR1) . . . . . . . . . . . . . . . . 272 12.5.13DAC channel2 data output register (DAC_DOR2) . . . . . . . . . . . . . . . . 272 12.5.14DAC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 13Direct memory access controll er (DMA) . . . . . . . . . . . . . . . . . . . . . . . 274 13.1DMA introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 13.2DMA main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 13.3DMA functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 13.3.1DMA transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 13.3.2Arbiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 13.3.3DMA channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

PAGE – 10 ============
Contents RM0008 10/1136RM0008 Rev 21 13.3.4Programmable data width, data alignm ent and endians . . . . . . . . . . . 279 13.3.5Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 13.3.6Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 13.3.7DMA request mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 13.4DMA registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 13.4.1DMA interrupt status register (DMA_ISR) . . . . . . . . . . . . . . . . . . . . . . 284 13.4.2DMA interrupt flag clear register (DMA_I FCR) . . . . . . . . . . . . . . . . . . 285 13.4.3DMA channel x configuration register (DMA_CCRx) (x = 1..7, where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 13.4.4DMA channel x number of data register (DMA_CNDTRx) (x = 1..7, where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 13.4.5DMA channel x peripheral address register (DMA_CPARx) (x = 1..7, where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 13.4.6DMA channel x memory address register (DMA_CMARx) (x = 1..7, where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 13.4.7DMA register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 14Advanced-control timers (TIM1 and TIM8) . . . . . . . . . . . . . . . . . . . . . 292 14.1TIM1 and TIM8 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 14.2TIM1 and TIM8 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 14.3TIM1 and TIM8 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . 295 14.3.1Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 14.3.2Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 14.3.3Repetition counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 14.3.4Clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 14.3.5Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 14.3.6Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 14.3.7PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 14.3.8Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 14.3.9Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 14.3.10PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 14.3.11Complementary outputs an d dead-time insertion . . . . . . . . . . . . . . . . 321 14.3.12Using the break function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 14.3.13Clearing the OCxREF signal on an external event . . . . . . . . . . . . . . . 326 14.3.146-step PWM generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 14.3.15One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 14.3.16Encoder interface mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 14.3.17Timer input XOR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

PAGE – 11 ============
RM0008 Rev 2111/1136 RM0008 Contents2614.3.18Interfacing with Hall sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 14.3.19TIMx and external trigger synchronization . . . . . . . . . . . . . . . . . . . . . . 334 14.3.20Timer synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 14.3.21Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 14.4TIM1 and TIM8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 14.4.1TIM1 and TIM8 control register 1 (TIMx_ CR1) . . . . . . . . . . . . . . . . . . 338 14.4.2TIM1 and TIM8 control register 2 (TIMx_ CR2) . . . . . . . . . . . . . . . . . . 339 14.4.3TIM1 and TIM8 slave mode control register (TIMx_SMCR) . . . . . . . . 342 14.4.4TIM1 and TIM8 DMA/interrupt enable register (TIMx_DIER) . . . . . . . . 344 14.4.5TIM1 and TIM8 status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . 346 14.4.6TIM1 and TIM8 event generation regist er (TIMx_EGR) . . . . . . . . . . . . 347 14.4.7TIM1 and TIM8 capture/compare mode register 1 (TIMx_CCMR1) . . 349 14.4.8TIM1 and TIM8 capture/compare mode register 2 (TIMx_CCMR2) . . 351 14.4.9TIM1 and TIM8 capture/compare enable register (TIMx_CCER) . . . . 353 14.4.10TIM1 and TIM8 counter (T IMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . 356 14.4.11TIM1 and TIM8 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . 356 14.4.12TIM1 and TIM8 auto-reload register (T IMx_ARR) . . . . . . . . . . . . . . . . 356 14.4.13TIM1 and TIM8 repetiti on counter register (TIMx_RCR) . . . . . . . . . . . 357 14.4.14TIM1 and TIM8 capture/compare register 1 (TIMx_CCR1) . . . . . . . . . 357 14.4.15TIM1 and TIM8 capture/compare register 2 (TIMx_CCR2) . . . . . . . . . 358 14.4.16TIM1 and TIM8 capture/compare register 3 (TIMx_CCR3) . . . . . . . . . 358 14.4.17TIM1 and TIM8 capture/compare register 4 (TIMx_CCR4) . . . . . . . . . 359 14.4.18TIM1 and TIM8 break and dead-time register (TIMx_BDTR) . . . . . . . 359 14.4.19TIM1 and TIM8 DMA control register (TIMx_DCR) . . . . . . . . . . . . . . . 361 14.4.20TIM1 and TIM8 DMA address for full transfer (TIMx_DMAR) . . . . . . . 362 14.4.21TIM1 and TIM8 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 15General-purpose timers (TIM2 to TIM5) . . . . . . . . . . . . . . . . . . . . . . . . 365 15.1TIM2 to TIM5 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 15.2TIMx main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 15.3TIMx functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 15.3.1Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 15.3.2Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 15.3.3Clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 15.3.4Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382 15.3.5Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 15.3.6PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385

80 KB – 1136 Pages