RM0376-STM32L0x2
Introduction
This reference manual targets application developers. It provides complete information on how to use the STM32L0x2 microcontroller memory and peripherals.
The STM32L0x2 is a line of microcontrollers with different memory sizes, packages and peripherals.
For ordering information, mechanical and electrical device characteristics please refer to the corresponding datasheets.
For information on the Arm ® Cortex ® -M0+ core, refer to the Cortex ® -M0+ Technical Reference Manual .
The STM32L0x2 microcontrollers include state-of-the-art patented technology.
Related documents
- • Cortex ® -M0+ Technical Reference Manual, available from www.arm.com .
- • STM32L0 Series Cortex ® -M0+ programming manual (PM0223).
- • STM32L0x2 datasheets.
- • STM32L0x2 erratasheet.
Contents
- 1 Documentation conventions . . . . . 51
- 1.1 General information . . . . . 51
- 1.2 List of abbreviations for registers . . . . . 51
- 1.3 Glossary . . . . . 52
- 1.4 Availability of peripherals . . . . . 52
- 1.5 Product category definition . . . . . 52
- 2 System and memory overview . . . . . 55
- 2.1 System architecture . . . . . 55
- 2.1.1 S0: Cortex®-bus . . . . . 56
- 2.1.2 S1: DMA-bus . . . . . 56
- 2.1.3 BusMatrix . . . . . 56
- AHB/APB bridges . . . . . 56
- 2.2 Memory organization . . . . . 57
- 2.2.1 Introduction . . . . . 57
- 2.2.2 Memory map and register boundary addresses . . . . . 58
- 2.3 Embedded SRAM . . . . . 63
- 2.4 Boot configuration . . . . . 63
- Bank swapping (category 5 devices only) . . . . . 64
- Physical remap . . . . . 64
- Embedded bootloader . . . . . 64
- 2.1 System architecture . . . . . 55
- 3 Flash program memory and data EEPROM (FLASH) . . . . . 65
- 3.1 Introduction . . . . . 65
- 3.2 NVM main features . . . . . 65
- 3.3 NVM functional description . . . . . 66
- 3.3.1 NVM organization . . . . . 66
- 3.3.2 Dual-bank boot capability . . . . . 70
- 3.3.3 Reading the NVM . . . . . 71
- Protocol to read . . . . . 71
- Relation between CPU frequency/Operation mode/NVM read time. . . . . 72
- Data buffering . . . . . 74
- 3.3.4 Writing/erasing the NVM . . . . . 80
- Write/erase protocol . . . . . 80
| Unlocking/locking operations . . . . . | 81 |
| Detailed description of NVM write/erase operations. . . . . | 84 |
| Parallel write half-page Flash program memory. . . . . | 90 |
| Status register . . . . . | 94 |
| 3.4 Memory protection . . . . . | 95 |
| 3.4.1 RDP (Read Out Protection) . . . . . | 96 |
| 3.4.2 PcROP (Proprietary Code Read-Out Protection) . . . . . | 97 |
| 3.4.3 Protections against unwanted write/erase operations . . . . . | 99 |
| 3.4.4 Write/erase protection management . . . . . | 100 |
| 3.4.5 Protection errors . . . . . | 101 |
| Write protection error flag (WRPERR) . . . . . | 101 |
| Read error (RDERR) . . . . . | 101 |
| 3.5 NVM interrupts . . . . . | 101 |
| 3.5.1 Hard fault . . . . . | 102 |
| 3.6 Memory interface management . . . . . | 102 |
| 3.6.1 Operation priority and evolution . . . . . | 102 |
| Read . . . . . | 102 |
| Write/erase . . . . . | 102 |
| Option byte loading. . . . . | 103 |
| 3.6.2 Sequence of operations . . . . . | 103 |
| Read as data while write . . . . . | 103 |
| Fetch while write. . . . . | 103 |
| Write while another write operation is ongoing. . . . . | 104 |
| 3.6.3 Change the number of wait states while reading . . . . . | 104 |
| 3.6.4 Power-down . . . . . | 104 |
| 3.7 Flash register description . . . . . | 105 |
| Read registers . . . . . | 105 |
| Write to registers . . . . . | 105 |
| 3.7.1 Access control register (FLASH_ACR) . . . . . | 106 |
| 3.7.2 Program and erase control register (FLASH_PECR) . . . . . | 107 |
| 3.7.3 Power-down key register (FLASH_PDKEYR) . . . . . | 111 |
| 3.7.4 PECR unlock key register (FLASH_PEKEYR) . . . . . | 111 |
| 3.7.5 Program and erase key register (FLASH_PRGKEYR) . . . . . | 111 |
| 3.7.6 Option bytes unlock key register (FLASH_OPTKEYR) . . . . . | 112 |
| 3.7.7 Status register (FLASH_SR) . . . . . | 113 |
| 3.7.8 Option bytes register (FLASH_OPTR) . . . . . | 115 |
| 3.7.9 Write protection register 1 (FLASH_WRPROT1) . . . . . | 117 |
| 3.7.10 Write protection register 2 (FLASH_WRPROT2) . . . . . | 118 |
| 3.7.11 | Flash register map . . . . . | 119 |
| 3.8 | Option bytes . . . . . | 120 |
| 3.8.1 | Option bytes description . . . . . | 120 |
| 3.8.2 | Mismatch when loading protection flags . . . . . | 121 |
| 3.8.3 | Reloading Option bytes by software . . . . . | 121 |
| 4 | Cyclic redundancy check calculation unit (CRC) . . . . . | 122 |
| 4.1 | Introduction . . . . . | 122 |
| 4.2 | CRC main features . . . . . | 122 |
| 4.3 | CRC functional description . . . . . | 123 |
| 4.3.1 | CRC block diagram . . . . . | 123 |
| 4.3.2 | CRC internal signals . . . . . | 123 |
| 4.3.3 | CRC operation . . . . . | 123 |
| Polynomial programmability . . . . . | 124 | |
| 4.4 | CRC registers . . . . . | 125 |
| 4.4.1 | CRC data register (CRC_DR) . . . . . | 125 |
| 4.4.2 | CRC independent data register (CRC_IDR) . . . . . | 125 |
| 4.4.3 | CRC control register (CRC_CR) . . . . . | 126 |
| 4.4.4 | CRC initial value (CRC_INIT) . . . . . | 127 |
| 4.4.5 | CRC polynomial (CRC_POL) . . . . . | 127 |
| 4.4.6 | CRC register map . . . . . | 128 |
| 5 | Firewall (FW) . . . . . | 129 |
| 5.1 | Introduction . . . . . | 129 |
| 5.2 | Firewall main features . . . . . | 129 |
| 5.3 | Firewall functional description . . . . . | 130 |
| 5.3.1 | Firewall AMBA bus snoop . . . . . | 130 |
| 5.3.2 | Functional requirements . . . . . | 130 |
| Debug consideration . . . . . | 130 | |
| Write protection . . . . . | 131 | |
| Interrupts management . . . . . | 131 | |
| 5.3.3 | Firewall segments . . . . . | 131 |
| Code segment . . . . . | 131 | |
| Non-volatile data segment . . . . . | 131 | |
| Volatile data segment . . . . . | 132 | |
| 5.3.4 | Segment accesses and properties . . . . . | 132 |
| Segment access depending on the Firewall state . . . . . | 132 |
| Segments properties | 133 |
| 5.3.5 Firewall initialization | 133 |
| 5.3.6 Firewall states | 134 |
| Opening the Firewall | 135 |
| Closing the Firewall | 135 |
| 5.4 Firewall registers | 136 |
| 5.4.1 Code segment start address (FW_CSSA) | 136 |
| 5.4.2 Code segment length (FW_CSL) | 136 |
| 5.4.3 Non-volatile data segment start address (FW_NVDSSA) | 137 |
| 5.4.4 Non-volatile data segment length (FW_NVDLSL) | 137 |
| 5.4.5 Volatile data segment start address (FW_VDSSA) | 138 |
| 5.4.6 Volatile data segment length (FW_VDSL) | 138 |
| 5.4.7 Configuration register (FW_CR) | 139 |
| 5.4.8 Firewall register map | 140 |
| 6 Power control (PWR) | 141 |
| 6.1 Power supplies | 141 |
| 6.1.1 Independent A/D and DAC converter supply and reference voltage | 142 |
| On packages with V REF+ pin | 142 |
| On packages without V REF+ pin | 142 |
| 6.1.2 RTC and RTC backup registers | 143 |
| RTC registers access | 143 |
| 6.1.3 Voltage regulator | 143 |
| 6.1.4 Dynamic voltage scaling management | 143 |
| Range 1 | 144 |
| Range 2 and 3 | 144 |
| 6.1.5 Dynamic voltage scaling configuration | 145 |
| 6.1.6 Voltage regulator and clock management when VDD drops below 1.71 V | 145 |
| 6.1.7 Voltage regulator and clock management when modifying the VCORE range | 146 |
| 6.1.8 Voltage range and limitations when VDD ranges from 1.71 V to 2.0 V | 146 |
| 6.2 Power supply supervisor | 147 |
| 6.2.1 Power-on reset (POR)/power-down reset (PDR) | 149 |
| 6.2.2 Brown out reset (BOR) | 149 |
| 6.2.3 Programmable voltage detector (PVD) | 150 |
| 6.2.4 Internal voltage reference (VREFINT) | 151 |
| 6.3 Low-power modes | 152 |
| 6.3.1 | Behavior of clocks in low-power modes . . . . . | 153 |
| Sleep and Low-power sleep modes . . . . . | 153 | |
| Stop and Standby modes . . . . . | 153 | |
| 6.3.2 | Slowing down system clocks . . . . . | 154 |
| 6.3.3 | Peripheral clock gating . . . . . | 154 |
| 6.3.4 | Low-power run mode (LP run) . . . . . | 154 |
| Entering Low-power run mode . . . . . | 154 | |
| Exiting Low-power run mode . . . . . | 155 | |
| 6.3.5 | Entering low-power mode . . . . . | 155 |
| 6.3.6 | Exiting low-power mode . . . . . | 155 |
| 6.3.7 | Sleep mode . . . . . | 156 |
| I/O states in Sleep mode . . . . . | 156 | |
| Entering Sleep mode . . . . . | 156 | |
| Exiting Sleep mode. . . . . | 156 | |
| 6.3.8 | Low-power sleep mode (LP sleep) . . . . . | 157 |
| I/O states in Low-power sleep mode . . . . . | 157 | |
| Entering Low-power sleep mode . . . . . | 157 | |
| Exiting Low-power sleep mode. . . . . | 158 | |
| 6.3.9 | Stop mode . . . . . | 159 |
| I/O states in Low-power sleep mode . . . . . | 159 | |
| Entering Stop mode . . . . . | 159 | |
| Exiting Stop mode . . . . . | 160 | |
| 6.3.10 | Standby mode . . . . . | 162 |
| I/O states in Standby mode . . . . . | 162 | |
| Entering Standby mode . . . . . | 162 | |
| Exiting Standby mode. . . . . | 162 | |
| Debug mode . . . . . | 163 | |
| 6.3.11 | Waking up the device from Stop and Standby modes using the RTC and comparators . . . . . | 163 |
| RTC auto-wakeup (AWU) from the Stop mode . . . . . | 164 | |
| RTC auto-wakeup (AWU) from the Standby mode. . . . . | 164 | |
| Comparator auto-wakeup (AWU) from the Stop mode. . . . . | 165 | |
| 6.4 | Power control registers . . . . . | 166 |
| 6.4.1 | PWR power control register (PWR_CR) . . . . . | 166 |
| 6.4.2 | PWR power control/status register (PWR_CSR) . . . . . | 169 |
| 6.4.3 | PWR register map . . . . . | 171 |
| 7 | Reset and clock control (RCC) . . . . . | 172 |
| 7.1 | Reset . . . . . | 172 |
| 7.1.1 | System reset . . . . . | 172 |
| Software reset . . . . . | 172 |
| Low-power management reset . . . . . | 172 |
| Option byte loader reset . . . . . | 172 |
| 7.1.2 Power reset . . . . . | 173 |
| 7.1.3 RTC and backup registers reset . . . . . | 173 |
| 7.2 Clocks . . . . . | 174 |
| 7.2.1 HSE clock . . . . . | 177 |
| External source (HSE bypass) . . . . . | 178 |
| External crystal/ceramic resonator (HSE crystal) . . . . . | 178 |
| 7.2.2 HSI16 clock . . . . . | 178 |
| Calibration . . . . . | 178 |
| 7.2.3 MSI clock . . . . . | 179 |
| Calibration . . . . . | 179 |
| 7.2.4 HSI48 clock . . . . . | 179 |
| 7.2.5 PLL . . . . . | 180 |
| 7.2.6 LSE clock . . . . . | 181 |
| External source (LSE bypass) . . . . . | 181 |
| 7.2.7 LSI clock . . . . . | 181 |
| LSI measurement . . . . . | 181 |
| 7.2.8 System clock (SYSCLK) selection . . . . . | 182 |
| 7.2.9 System clock source frequency versus voltage range . . . . . | 182 |
| 7.2.10 HSE clock security system (CSS) . . . . . | 182 |
| 7.2.11 LSE Clock Security System . . . . . | 183 |
| 7.2.12 RTC clock . . . . . | 183 |
| 7.2.13 Watchdog clock . . . . . | 184 |
| 7.2.14 Clock-out capability . . . . . | 184 |
| 7.2.15 Internal/external clock measurement using TIM21 . . . . . | 184 |
| 7.2.16 Clock-independent system clock sources for TIM2/TIM21/TIM22 . . . . . | 185 |
| 7.3 RCC registers . . . . . | 186 |
| 7.3.1 Clock control register (RCC_CR) . . . . . | 186 |
| 7.3.2 Internal clock sources calibration register (RCC_ICSCR) . . . . . | 189 |
| 7.3.3 Clock recovery RC register (RCC_CRRRCR) . . . . . | 190 |
| 7.3.4 Clock configuration register (RCC_CFGR) . . . . . | 191 |
| 7.3.5 Clock interrupt enable register (RCC_CIER) . . . . . | 193 |
| 7.3.6 Clock interrupt flag register (RCC_CIFR) . . . . . | 195 |
| 7.3.7 Clock interrupt clear register (RCC_CICR) . . . . . | 196 |
| 7.3.8 GPIO reset register (RCC_IOPRSTR) . . . . . | 197 |
| 7.3.9 AHB peripheral reset register (RCC_AHBRSTR) . . . . . | 198 |
| 7.3.10 | APB2 peripheral reset register (RCC_APB2RSTR) . . . . . | 199 |
| 7.3.11 | APB1 peripheral reset register (RCC_APB1RSTR) . . . . . | 200 |
| 7.3.12 | GPIO clock enable register (RCC_IOPENR) . . . . . | 203 |
| 7.3.13 | AHB peripheral clock enable register (RCC_AHBENR) . . . . . | 204 |
| 7.3.14 | APB2 peripheral clock enable register (RCC_APB2ENR) . . . . . | 206 |
| 7.3.15 | APB1 peripheral clock enable register (RCC_APB1ENR) . . . . . | 208 |
| 7.3.16 | GPIO clock enable in Sleep mode register (RCC_IOPSMENR) . . . . . | 211 |
| 7.3.17 | AHB peripheral clock enable in Sleep mode register (RCC_AHBSMENR) . . . . . | 212 |
| 7.3.18 | APB2 peripheral clock enable in Sleep mode register (RCC_APB2SMENR) . . . . . | 213 |
| 7.3.19 | APB1 peripheral clock enable in Sleep mode register (RCC_APB1SMENR) . . . . . | 214 |
| 7.3.20 | Clock configuration register (RCC_CCIPR) . . . . . | 216 |
| 7.3.21 | Control/status register (RCC_CSR) . . . . . | 217 |
| 7.3.22 | RCC register map . . . . . | 221 |
| 8 | Clock recovery system (CRS) . . . . . | 224 |
| 8.1 | Introduction . . . . . | 224 |
| 8.2 | CRS main features . . . . . | 224 |
| 8.3 | CRS implementation . . . . . | 224 |
| 8.4 | CRS functional description . . . . . | 225 |
| 8.4.1 | CRS block diagram . . . . . | 225 |
| 8.4.2 | Synchronization input . . . . . | 225 |
| 8.4.3 | Frequency error measurement . . . . . | 226 |
| 8.4.4 | Frequency error evaluation and automatic trimming . . . . . | 226 |
| 8.4.5 | CRS initialization and configuration . . . . . | 227 |
| RELOAD value . . . . . | 227 | |
| FELIM value . . . . . | 227 | |
| 8.5 | CRS low-power modes . . . . . | 228 |
| 8.6 | CRS interrupts . . . . . | 228 |
| 8.7 | CRS registers . . . . . | 229 |
| 8.7.1 | CRS control register (CRS_CR) . . . . . | 229 |
| 8.7.2 | CRS configuration register (CRS_CFGR) . . . . . | 230 |
| 8.7.3 | CRS interrupt and status register (CRS_ISR) . . . . . | 231 |
| 8.7.4 | CRS interrupt flag clear register (CRS_ICR) . . . . . | 233 |
| 8.7.5 | CRS register map . . . . . | 233 |
| 9 | General-purpose I/Os (GPIO) . . . . . | 235 |
| 9.1 | Introduction . . . . . | 235 |
| 9.2 | GPIO main features . . . . . | 235 |
| 9.3 | GPIO functional description . . . . . | 235 |
| 9.3.1 | General-purpose I/O (GPIO) . . . . . | 237 |
| 9.3.2 | I/O pin alternate function multiplexer and mapping . . . . . | 238 |
| 9.3.3 | I/O port control registers . . . . . | 239 |
| 9.3.4 | I/O port data registers . . . . . | 239 |
| 9.3.5 | I/O data bitwise handling . . . . . | 239 |
| 9.3.6 | GPIO locking mechanism . . . . . | 239 |
| 9.3.7 | I/O alternate function input/output . . . . . | 240 |
| 9.3.8 | External interrupt/wakeup lines . . . . . | 240 |
| 9.3.9 | Input configuration . . . . . | 240 |
| 9.3.10 | Output configuration . . . . . | 241 |
| 9.3.11 | Alternate function configuration . . . . . | 242 |
| 9.3.12 | Analog configuration . . . . . | 243 |
| 9.3.13 | Using the HSE or LSE oscillator pins as GPIOs . . . . . | 243 |
| 9.3.14 | Using the GPIO pins in the RTC supply domain . . . . . | 243 |
| 9.4 | GPIO registers . . . . . | 244 |
| 9.4.1 | GPIO port mode register (GPIOx_MODER) (x = A to E and H) . . . . . | 244 |
| 9.4.2 | GPIO port output type register (GPIOx_OTYPER) (x = A to E and H) . . . . . | 244 |
| 9.4.3 | GPIO port output speed register (GPIOx_OSPEEDR) (x = A to E and H) . . . . . | 245 |
| 9.4.4 | GPIO port pull-up/pull-down register (GPIOx_PUPDR) (x = A to E and H) . . . . . | 245 |
| 9.4.5 | GPIO port input data register (GPIOx_IDR) (x = A to E and H) . . . . . | 246 |
| 9.4.6 | GPIO port output data register (GPIOx_ODR) (x = A to E and H) . . . . . | 246 |
| 9.4.7 | GPIO port bit set/reset register (GPIOx_BSRR) (x = A to E and H) . . . . . | 247 |
| 9.4.8 | GPIO port configuration lock register (GPIOx_LCKR) (x = A to E and H) . . . . . | 247 |
| 9.4.9 | GPIO alternate function low register (GPIOx_AFRL) (x = A to E and H) . . . . . | 248 |
| 9.4.10 | GPIO alternate function high register (GPIOx_AFRH) (x = A to E and H) . . . . . | 249 |
- 9.4.11 GPIO port bit reset register (GPIOx_BRR) (x = A to E and H) . . . . . 249
- 9.4.12 GPIO register map . . . . . 250
- 10 System configuration controller (SYSCFG) . . . . . 252
- 10.1 Introduction . . . . . 252
- 10.2 SYSCFG registers . . . . . 253
- 10.2.1 SYSCFG memory remap register (SYSCFG_CFGR1) . . . . . 253
- 10.2.2 SYSCFG peripheral mode configuration register (SYSCFG_CFGR2) 255
- 10.2.3 Reference control and status register (SYSCFG_CFGR3) . . . . . 256
- 10.2.4 SYSCFG external interrupt configuration register 1
(SYSCFG_EXTICR1) . . . . . 257 - 10.2.5 SYSCFG external interrupt configuration register 2
(SYSCFG_EXTICR2) . . . . . 258 - 10.2.6 SYSCFG external interrupt configuration register 3
(SYSCFG_EXTICR3) . . . . . 258 - 10.2.7 SYSCFG external interrupt configuration register 4
(SYSCFG_EXTICR4) . . . . . 259 - 10.2.8 SYSCFG register map . . . . . 259
- 11 Direct memory access controller (DMA) . . . . . 261
- 11.1 Introduction . . . . . 261
- 11.2 DMA main features . . . . . 261
- 11.3 DMA implementation . . . . . 262
- 11.3.1 DMA . . . . . 262
- 11.3.2 DMA request mapping . . . . . 262
- DMA controller . . . . . 262
- 11.4 DMA functional description . . . . . 264
- 11.4.1 DMA block diagram . . . . . 264
- 11.4.2 DMA transfers . . . . . 265
- 11.4.3 DMA arbitration . . . . . 266
- 11.4.4 DMA channels . . . . . 267
- Programmable data sizes . . . . . 267
- Pointer incrementation . . . . . 267
- Channel configuration procedure . . . . . 268
- Channel state and disabling a channel . . . . . 268
- Circular mode (in memory-to-peripheral/peripheral-to-memory transfers) . . . . . 269
- Memory-to-memory mode . . . . . 269
- Peripheral-to-peripheral mode . . . . . 270
- Programming transfer direction, assigning source/destination . . . . . 270
| 11.4.5 | DMA data width, alignment and endianness . . . . . | 270 |
| Addressing AHB peripherals not supporting byte/half-word write transfers . . . | 271 | |
| 11.4.6 | DMA error management . . . . . | 272 |
| 11.5 | DMA interrupts . . . . . | 272 |
| 11.6 | DMA registers . . . . . | 272 |
| 11.6.1 | DMA interrupt status register (DMA_ISR) . . . . . | 273 |
| 11.6.2 | DMA interrupt flag clear register (DMA_IFCR) . . . . . | 275 |
| 11.6.3 | DMA channel x configuration register (DMA_CCRx) . . . . . | 276 |
| 11.6.4 | DMA channel x number of data to transfer register (DMA_CNDTRx) . . . . . | 279 |
| 11.6.5 | DMA channel x peripheral address register (DMA_CPARx) . . . . . | 280 |
| 11.6.6 | DMA channel x memory address register (DMA_CMARx) . . . . . | 280 |
| 11.6.7 | DMA channel selection register (DMA_CSELR) . . . . . | 282 |
| 11.6.8 | DMA register map . . . . . | 282 |
| 12 | Nested vectored interrupt controller (NVIC) . . . . . | 285 |
| 12.1 | Main features . . . . . | 285 |
| 12.2 | SysTick calibration value register . . . . . | 285 |
| 12.3 | Interrupt and exception vectors . . . . . | 285 |
| 13 | Extended interrupt and event controller (EXTI) . . . . . | 288 |
| 13.1 | Introduction . . . . . | 288 |
| 13.2 | EXTI main features . . . . . | 288 |
| 13.3 | EXTI functional description . . . . . | 288 |
| 13.3.1 | EXTI block diagram . . . . . | 289 |
| 13.3.2 | Wakeup event management . . . . . | 289 |
| 13.3.3 | Peripherals asynchronous interrupts . . . . . | 290 |
| 13.3.4 | Hardware interrupt selection . . . . . | 290 |
| 13.3.5 | Hardware event selection . . . . . | 290 |
| 13.3.6 | Software interrupt/event selection . . . . . | 290 |
| 13.4 | EXTI interrupt/event line mapping . . . . . | 291 |
| 13.5 | EXTI registers . . . . . | 293 |
| 13.5.1 | EXTI interrupt mask register (EXTI_IMR) . . . . . | 293 |
| 13.5.2 | EXTI event mask register (EXTI_EMR) . . . . . | 293 |
| 13.5.3 | EXTI rising edge trigger selection register (EXTI_RTSR) . . . . . | 294 |
| 13.5.4 | Falling edge trigger selection register (EXTI_FTSR) . . . . . | 295 |
| 13.5.5 | EXTI software interrupt event register (EXTI_SWIER) . . . . . | 295 |
| 13.5.6 | EXTI pending register (EXTI_PR) . . . . . | 296 |
| 13.5.7 | EXTI register map . . . . . | 297 |
| 14 | Analog-to-digital converter (ADC) . . . . . | 298 |
| 14.1 | Introduction . . . . . | 298 |
| 14.2 | ADC main features . . . . . | 299 |
| 14.3 | ADC functional description . . . . . | 300 |
| 14.3.1 | ADC pins and internal signals . . . . . | 300 |
| 14.3.2 | ADC voltage regulator (ADVREGEN) . . . . . | 301 |
| Analog reference for the ADC internal voltage regulator . . . . . | 301 | |
| ADVREG enable sequence . . . . . | 302 | |
| ADVREG disable sequence . . . . . | 302 | |
| 14.3.3 | Calibration (ADCAL) . . . . . | 302 |
| Calibration factor forcing software procedure . . . . . | 304 | |
| 14.3.4 | ADC on-off control (ADEN, ADDIS, ADRDY) . . . . . | 304 |
| 14.3.5 | ADC clock (CKMODE, PRESC[3:0], LFMEN) . . . . . | 305 |
| Low frequency . . . . . | 306 | |
| 14.3.6 | ADC connectivity . . . . . | 307 |
| 14.3.7 | Configuring the ADC . . . . . | 308 |
| 14.3.8 | Channel selection (CHSEL, SCANDIR) . . . . . | 308 |
| Temperature sensor, V REFINT internal channels . . . . . | 308 | |
| 14.3.9 | Programmable sampling time (SMP) . . . . . | 309 |
| 14.3.10 | Single conversion mode (CONT = 0) . . . . . | 309 |
| 14.3.11 | Continuous conversion mode (CONT = 1) . . . . . | 310 |
| 14.3.12 | Starting conversions (ADSTART) . . . . . | 310 |
| 14.3.13 | Timings . . . . . | 311 |
| 14.3.14 | Stopping an ongoing conversion (ADSTP) . . . . . | 312 |
| 14.4 | Conversion on external trigger and trigger polarity (EXTSEL, EXTEN) . . . . . | 312 |
| 14.4.1 | Discontinuous mode (DISCEN) . . . . . | 313 |
| 14.4.2 | Programmable resolution (RES) - Fast conversion mode . . . . . | 313 |
| 14.4.3 | End of conversion, end of sampling phase (EOC, EOSMP flags) . . . . . | 314 |
| 14.4.4 | End of conversion sequence (EOS flag) . . . . . | 314 |
| 14.4.5 | Example timing diagrams (single/continuous modes hardware/software triggers) . . . . . | 315 |
| 14.5 | Data management . . . . . | 317 |
| 14.5.1 | Data register and data alignment (ADC_DR, ALIGN) . . . . . | 317 |
| 14.5.2 | ADC overrun (OVR, OVRMOD) . . . . . | 317 |
| 14.5.3 | Managing a sequence of data converted without using the DMA . . . . . | 318 |
| 14.5.4 | Managing converted data without using the DMA without overrun . . . | 318 |
| 14.5.5 | Managing converted data using the DMA . . . . . | 318 |
| DMA one shot mode (DMACFG = 0) . . . . . | 319 | |
| DMA circular mode (DMACFG = 1) . . . . . | 319 | |
| 14.6 | Low-power features . . . . . | 320 |
| 14.6.1 | Wait mode conversion . . . . . | 320 |
| 14.6.2 | Auto-off mode (AUTOFF) . . . . . | 321 |
| 14.7 | Analog window watchdog (AWDEN, AWDSGL, AWDCH, ADC_TR) . . . . . | 322 |
| 14.7.1 | Description of the analog watchdog . . . . . | 322 |
| 14.7.2 | ADC_AWD1_OUT output signal generation . . . . . | 323 |
| 14.7.3 | Analog watchdog threshold control . . . . . | 325 |
| 14.8 | Oversampler . . . . . | 326 |
| 14.8.1 | ADC operating modes supported when oversampling . . . . . | 328 |
| 14.8.2 | Analog watchdog . . . . . | 328 |
| 14.8.3 | Triggered mode . . . . . | 328 |
| 14.9 | Temperature sensor and internal reference voltage . . . . . | 329 |
| Main features . . . . . | 330 | |
| Reading the temperature . . . . . | 330 | |
| Calculating the actual V DDA voltage using the internal reference voltage . . . . . | 331 | |
| Converting a supply-relative ADC measurement to an absolute voltage value . . . . . | 331 | |
| 14.10 | ADC interrupts . . . . . | 332 |
| 14.11 | ADC registers . . . . . | 333 |
| 14.11.1 | ADC interrupt and status register (ADC_ISR) . . . . . | 333 |
| 14.11.2 | ADC interrupt enable register (ADC_IER) . . . . . | 334 |
| 14.11.3 | ADC control register (ADC_CR) . . . . . | 336 |
| 14.11.4 | ADC configuration register 1 (ADC_CFGR1) . . . . . | 338 |
| 14.11.5 | ADC configuration register 2 (ADC_CFGR2) . . . . . | 342 |
| 14.11.6 | ADC sampling time register (ADC_SMPR) . . . . . | 343 |
| 14.11.7 | ADC watchdog threshold register (ADC_TR) . . . . . | 344 |
| 14.11.8 | ADC channel selection register (ADC_CHSELR) . . . . . | 344 |
| 14.11.9 | ADC data register (ADC_DR) . . . . . | 345 |
| 14.11.10 | ADC Calibration factor (ADC_CALFACT) . . . . . | 345 |
| 14.11.11 | ADC common configuration register (ADC_CCR) . . . . . | 346 |
| 14.12 | ADC register map . . . . . | 347 |
| 15 | Digital-to-analog converter (DAC) . . . . . | 349 |
| 15.1 | Introduction . . . . . | 349 |
| 15.2 | DAC1 main features . . . . . | 349 |
| 15.3 | DAC output buffer enable . . . . . | 351 |
| 15.4 | DAC channel enable . . . . . | 351 |
| 15.5 | Single mode functional description . . . . . | 351 |
| 15.5.1 | DAC data format . . . . . | 351 |
| 15.5.2 | DAC channel conversion . . . . . | 351 |
| Independent trigger with single LFSR generation . . . . . | 352 | |
| Independent trigger with single triangle generation . . . . . | 352 | |
| 15.5.3 | DAC output voltage . . . . . | 353 |
| 15.5.4 | DAC trigger selection . . . . . | 353 |
| 15.6 | Dual-mode functional description . . . . . | 354 |
| 15.6.1 | DAC data format . . . . . | 354 |
| 15.6.2 | DAC channel conversion in dual mode . . . . . | 354 |
| 15.6.3 | Description of dual conversion modes . . . . . | 354 |
| Independent trigger without wave generation. . . . . | 355 | |
| Independent trigger with single LFSR generation . . . . . | 355 | |
| Independent trigger with different LFSR generation. . . . . | 355 | |
| Independent trigger with single triangle generation . . . . . | 356 | |
| Independent trigger with different triangle generation . . . . . | 356 | |
| Simultaneous software start . . . . . | 356 | |
| Simultaneous trigger without wave generation. . . . . | 356 | |
| Simultaneous trigger with single LFSR generation. . . . . | 357 | |
| Simultaneous trigger with different LFSR generation . . . . . | 357 | |
| Simultaneous trigger with single triangle generation . . . . . | 357 | |
| Simultaneous trigger with different triangle generation . . . . . | 358 | |
| 15.6.4 | DAC output voltage . . . . . | 358 |
| 15.6.5 | DAC trigger selection . . . . . | 358 |
| 15.7 | Noise generation . . . . . | 358 |
| 15.8 | Triangle-wave generation . . . . . | 359 |
| 15.9 | DMA request . . . . . | 360 |
| DMA underrun . . . . . | 360 | |
| 15.10 | DAC registers . . . . . | 361 |
| 15.10.1 | DAC control register (DAC_CR) . . . . . | 361 |
| 15.10.2 | DAC software trigger register (DAC_SWTRIGR) . . . . . | 365 |
| 15.10.3 | DAC channel1 12-bit right-aligned data holding register (DAC_DHR12R1) . . . . . | 365 |
| 15.10.4 | DAC channel1 12-bit left-aligned data holding register (DAC_DHR12L1) ..... | 366 |
| 15.10.5 | DAC channel1 8-bit right-aligned data holding register (DAC_DHR8R1) ..... | 366 |
| 15.10.6 | DAC channel2 12-bit right-aligned data holding register (DAC_DHR12R2) ..... | 366 |
| 15.10.7 | DAC channel2 12-bit left-aligned data holding register (DAC_DHR12L2) ..... | 367 |
| 15.10.8 | DAC channel2 8-bit right-aligned data holding register (DAC_DHR8R2) ..... | 367 |
| 15.10.9 | Dual DAC 12-bit right-aligned data holding register (DAC_DHR12RD) ..... | 368 |
| 15.10.10 | Dual DAC 12-bit left-aligned data holding register (DAC_DHR12LD) ..... | 368 |
| 15.10.11 | Dual DAC 8-bit right-aligned data holding register (DAC_DHR8RD) ..... | 368 |
| 15.10.12 | DAC channel1 data output register (DAC_DOR1) ..... | 369 |
| 15.10.13 | DAC channel2 data output register (DAC_DOR2) ..... | 369 |
| 15.10.14 | DAC status register (DAC_SR) ..... | 369 |
| 15.10.15 | DAC register map ..... | 371 |
| 16 | Comparator (COMP) ..... | 373 |
| 16.1 | Introduction ..... | 373 |
| 16.2 | COMP main features ..... | 373 |
| 16.3 | COMP functional description ..... | 374 |
| 16.3.1 | COMP block diagram ..... | 374 |
| 16.3.2 | COMP pins and internal signals ..... | 374 |
| 16.3.3 | COMP reset and clocks ..... | 375 |
| 16.3.4 | Comparator LOCK mechanism ..... | 375 |
| 16.3.5 | Power mode ..... | 375 |
| 16.4 | COMP interrupts ..... | 375 |
| 16.5 | COMP registers ..... | 375 |
| 16.5.1 | Comparator 1 control and status register (COMP1_CSR) ..... | 375 |
| 16.5.2 | Comparator 2 control and status register (COMP2_CSR) ..... | 377 |
| 16.5.3 | COMP register map ..... | 379 |
| 17 | Touch sensing controller (TSC) ..... | 380 |
| 17.1 | Introduction ..... | 380 |
| 17.2 | TSC main features ..... | 380 |
| 17.3 | TSC functional description . . . . . | 381 |
| 17.3.1 | TSC block diagram . . . . . | 381 |
| 17.3.2 | Surface charge transfer acquisition overview . . . . . | 381 |
| 17.3.3 | Reset and clocks . . . . . | 383 |
| 17.3.4 | Charge transfer acquisition sequence . . . . . | 384 |
| 17.3.5 | Spread spectrum feature . . . . . | 385 |
| 17.3.6 | Max count error . . . . . | 385 |
| 17.3.7 | Sampling capacitor I/O and channel I/O mode selection . . . . . | 386 |
| 17.3.8 | Acquisition mode . . . . . | 387 |
| 17.3.9 | I/O hysteresis and analog switch control . . . . . | 387 |
| 17.4 | TSC low-power modes . . . . . | 388 |
| 17.5 | TSC interrupts . . . . . | 388 |
| 17.6 | TSC registers . . . . . | 389 |
| 17.6.1 | TSC control register (TSC_CR) . . . . . | 389 |
| 17.6.2 | TSC interrupt enable register (TSC_IER) . . . . . | 391 |
| 17.6.3 | TSC interrupt clear register (TSC_ICR) . . . . . | 392 |
| 17.6.4 | TSC interrupt status register (TSC_ISR) . . . . . | 393 |
| 17.6.5 | TSC I/O hysteresis control register (TSC_IOHCR) . . . . . | 393 |
| 17.6.6 | TSC I/O analog switch control register (TSC_IOASCR) . . . . . | 394 |
| 17.6.7 | TSC I/O sampling control register (TSC_IOSCR) . . . . . | 394 |
| 17.6.8 | TSC I/O channel control register (TSC_IOCCR) . . . . . | 395 |
| 17.6.9 | TSC I/O group control status register (TSC_IOGCSR) . . . . . | 395 |
| 17.6.10 | TSC I/O group x counter register (TSC_IOGxCR) . . . . . | 396 |
| 17.6.11 | TSC register map . . . . . | 397 |
| 18 | AES hardware accelerator (AES) . . . . . | 399 |
| 18.1 | Introduction . . . . . | 399 |
| 18.2 | AES main features . . . . . | 399 |
| 18.3 | AES implementation . . . . . | 400 |
| 18.4 | AES functional description . . . . . | 400 |
| 18.4.1 | AES block diagram . . . . . | 400 |
| 18.4.2 | AES internal signals . . . . . | 400 |
| 18.4.3 | AES cryptographic core . . . . . | 401 |
| Overview. . . . . | 401 | |
| Typical data processing . . . . . | 401 | |
| Chaining modes . . . . . | 401 |
| Electronic codebook (ECB) mode . . . . . | 402 |
| Cipher block chaining (CBC) mode . . . . . | 403 |
| Counter (CTR) mode . . . . . | 404 |
| 18.4.4 AES procedure to perform a cipher operation . . . . . | 404 |
| Introduction. . . . . | 404 |
| Initialization of AES. . . . . | 405 |
| Data append . . . . . | 405 |
| 18.4.5 AES decryption key preparation . . . . . | 407 |
| 18.4.6 AES ciphertext stealing and data padding . . . . . | 408 |
| 18.4.7 AES task suspend and resume . . . . . | 408 |
| 18.4.8 AES basic chaining modes (ECB, CBC) . . . . . | 409 |
| Overview. . . . . | 409 |
| ECB/CBC encryption sequence . . . . . | 412 |
| ECB/CBC decryption sequence . . . . . | 412 |
| Suspend/resume operations in ECB/CBC modes . . . . . | 413 |
| Alternative single ECB/CBC decryption using Mode 4 . . . . . | 414 |
| 18.4.9 AES counter (CTR) mode . . . . . | 414 |
| Overview. . . . . | 414 |
| CTR encryption and decryption . . . . . | 415 |
| Suspend/resume operations in CTR mode . . . . . | 417 |
| 18.4.10 AES data registers and data swapping . . . . . | 417 |
| Data input and output . . . . . | 417 |
| Data swapping . . . . . | 417 |
| Data padding . . . . . | 419 |
| 18.4.11 AES key registers . . . . . | 419 |
| 18.4.12 AES initialization vector registers . . . . . | 419 |
| 18.4.13 AES DMA interface . . . . . | 419 |
| Data input using DMA. . . . . | 420 |
| Data output using DMA . . . . . | 420 |
| DMA operation in different operating modes . . . . . | 421 |
| 18.4.14 AES error management . . . . . | 422 |
| Read error flag (RDERR) . . . . . | 422 |
| Write error flag (WDERR). . . . . | 422 |
| 18.5 AES interrupts . . . . . | 422 |
| 18.6 AES processing latency . . . . . | 423 |
| 18.7 AES registers . . . . . | 424 |
| 18.7.1 AES control register (AES_CR) . . . . . | 424 |
| 18.7.2 AES status register (AES_SR) . . . . . | 426 |
| 18.7.3 AES data input register (AES_DINR) . . . . . | 427 |
- 18.7.4 AES data output register (AES_DOUTR) . . . . . 427
- 18.7.5 AES key register 0 (AES_KEYR0) . . . . . 428
- 18.7.6 AES key register 1 (AES_KEYR1) . . . . . 429
- 18.7.7 AES key register 2 (AES_KEYR2) . . . . . 429
- 18.7.8 AES key register 3 (AES_KEYR3) . . . . . 429
- 18.7.9 AES initialization vector register 0 (AES_IVR0) . . . . . 430
- 18.7.10 AES initialization vector register 1 (AES_IVR1) . . . . . 430
- 18.7.11 AES initialization vector register 2 (AES_IVR2) . . . . . 431
- 18.7.12 AES initialization vector register 3 (AES_IVR3) . . . . . 431
- 18.7.13 AES register map . . . . . 431
19 True random number generator (RNG) . . . . . 433
- 19.1 Introduction . . . . . 433
- 19.2 RNG main features . . . . . 433
- 19.3 RNG functional description . . . . . 434
- 19.3.1 RNG block diagram . . . . . 434
- 19.3.2 RNG internal signals . . . . . 434
- 19.3.3 Random number generation . . . . . 435
- Noise source . . . . . 436
- Post processing . . . . . 436
- Output buffer . . . . . 436
- Health checks . . . . . 437
- 19.3.4 RNG initialization . . . . . 437
- 19.3.5 RNG operation . . . . . 437
- Normal operations . . . . . 437
- Low-power operations . . . . . 438
- Software post-processing . . . . . 438
- 19.3.6 RNG clocking . . . . . 438
- 19.3.7 Error management . . . . . 438
- Clock error detection . . . . . 438
- Noise source error detection . . . . . 439
- 19.3.8 RNG low-power usage . . . . . 439
- 19.4 RNG interrupts . . . . . 439
- 19.5 RNG processing time . . . . . 439
- 19.6 RNG entropy source validation . . . . . 440
- 19.6.1 Introduction . . . . . 440
- 19.6.2 Validation conditions . . . . . 440
| 19.6.3 | Data collection ..... | 440 |
| 19.7 | RNG registers ..... | 440 |
| 19.7.1 | RNG control register (RNG_CR) ..... | 440 |
| 19.7.2 | RNG status register (RNG_SR) ..... | 442 |
| 19.7.3 | RNG data register (RNG_DR) ..... | 443 |
| 19.7.4 | RNG register map ..... | 443 |
| 20 | General-purpose timers (TIM2/TIM3) ..... | 444 |
| 20.1 | TIM2/TIM3 introduction ..... | 444 |
| 20.2 | TIM2/TIM3 main features ..... | 444 |
| 20.3 | TIM2/TIM3 functional description ..... | 446 |
| 20.3.1 | Time-base unit ..... | 446 |
| Prescaler description ..... | 446 | |
| 20.3.2 | Counter modes ..... | 448 |
| Upcounting mode ..... | 448 | |
| Downcounting mode ..... | 451 | |
| Center-aligned mode (up/down counting) ..... | 454 | |
| 20.3.3 | Clock selection ..... | 458 |
| Internal clock source (CK_INT) ..... | 458 | |
| External clock source mode 1 ..... | 459 | |
| External clock source mode 2 ..... | 461 | |
| 20.3.4 | Capture/compare channels ..... | 462 |
| 20.3.5 | Input capture mode ..... | 464 |
| 20.3.6 | PWM input mode ..... | 466 |
| 20.3.7 | Forced output mode ..... | 467 |
| 20.3.8 | Output compare mode ..... | 467 |
| 20.3.9 | PWM mode ..... | 468 |
| PWM edge-aligned mode ..... | 469 | |
| Downcounting configuration ..... | 470 | |
| PWM center-aligned mode ..... | 470 | |
| 20.3.10 | One-pulse mode ..... | 472 |
| Particular case: OCx fast enable: ..... | 473 | |
| 20.3.11 | Clearing the OCxREF signal on an external event ..... | 473 |
| 20.3.12 | Encoder interface mode ..... | 474 |
| 20.3.13 | Timer input XOR function ..... | 476 |
| 20.3.14 | Timers and external trigger synchronization ..... | 477 |
| Slave mode: Reset mode ..... | 477 | |
| Slave mode: Gated mode ..... | 478 |
- Slave mode: Trigger mode . . . . . 479
- Slave mode: External Clock mode 2 + trigger mode . . . . . 480
- 20.3.15 Timer synchronization . . . . . 481
- Using one timer as prescaler for another timer . . . . . 481
- Using one timer to enable another timer . . . . . 482
- Using one timer to start another timer . . . . . 484
- Starting 2 timers synchronously in response to an external trigger . . . . . 486
- 20.3.16 Debug mode . . . . . 487
- 20.4 TIM2/TIM3 registers . . . . . 488
- 20.4.1 TIMx control register 1 (TIMx_CR1) . . . . . 488
- 20.4.2 TIMx control register 2 (TIMx_CR2) . . . . . 490
- 20.4.3 TIMx slave mode control register (TIMx_SMCR) . . . . . 491
- 20.4.4 TIMx DMA/Interrupt enable register (TIMx_DIER) . . . . . 493
- 20.4.5 TIMx status register (TIMx_SR) . . . . . 494
- 20.4.6 TIMx event generation register (TIMx_EGR) . . . . . 496
- 20.4.7 TIMx capture/compare mode register 1 (TIMx_CCMR1) . . . . . 497
- Output compare mode . . . . . 497
- Input capture mode. . . . . 498
- 20.4.8 TIMx capture/compare mode register 2 (TIMx_CCMR2) . . . . . 500
- Output compare mode . . . . . 500
- Input capture mode. . . . . 501
- 20.4.9 TIMx capture/compare enable register (TIMx_CCER) . . . . . 501
- 20.4.10 TIMx counter (TIMx_CNT) . . . . . 503
- 20.4.11 TIMx prescaler (TIMx_PSC) . . . . . 503
- 20.4.12 TIMx auto-reload register (TIMx_ARR) . . . . . 503
- 20.4.13 TIMx capture/compare register 1 (TIMx_CCR1) . . . . . 504
- 20.4.14 TIMx capture/compare register 2 (TIMx_CCR2) . . . . . 504
- 20.4.15 TIMx capture/compare register 3 (TIMx_CCR3) . . . . . 505
- 20.4.16 TIMx capture/compare register 4 (TIMx_CCR4) . . . . . 505
- 20.4.17 TIMx DMA control register (TIMx_DCR) . . . . . 506
- 20.4.18 TIMx DMA address for full transfer (TIMx_DMAR) . . . . . 506
- Example of how to use the DMA burst feature . . . . . 507
- 20.4.19 TIM2 option register (TIM2_OR) . . . . . 508
- 20.4.20 TIM3 option register (TIM3_OR) . . . . . 509
- 20.5 TIMx register map . . . . . 510
21 General-purpose timers (TIM21/22) . . . . . 512
- 21.1 Introduction . . . . . 512
| 21.2 | TIM21/22 main features . . . . . | 512 |
| 21.2.1 | TIM21/22 main features . . . . . | 512 |
| 21.3 | TIM21/22 functional description . . . . . | 514 |
| 21.3.1 | Timebase unit . . . . . | 514 |
| Prescaler description . . . . . | 514 | |
| 21.3.2 | Counter modes . . . . . | 516 |
| Upcounting mode . . . . . | 516 | |
| Downcounting mode . . . . . | 520 | |
| Center-aligned mode (up/down counting) . . . . . | 523 | |
| 21.3.3 | Clock selection . . . . . | 527 |
| Internal clock source (CK_INT) . . . . . | 527 | |
| External clock source mode 2 . . . . . | 529 | |
| 21.3.4 | Capture/compare channels . . . . . | 530 |
| 21.3.5 | Input capture mode . . . . . | 532 |
| 21.3.6 | PWM input mode . . . . . | 534 |
| 21.3.7 | Forced output mode . . . . . | 535 |
| 21.3.8 | Output compare mode . . . . . | 535 |
| 21.3.9 | PWM mode . . . . . | 536 |
| PWM center-aligned mode . . . . . | 538 | |
| Hints on using center-aligned mode . . . . . | 539 | |
| 21.3.10 | Clearing the OCxREF signal on an external event . . . . . | 539 |
| 21.3.11 | One-pulse mode . . . . . | 540 |
| Particular case: OCx fast enable . . . . . | 542 | |
| 21.3.12 | Encoder interface mode . . . . . | 542 |
| 21.3.13 | TIM21/22 external trigger synchronization . . . . . | 544 |
| Slave mode: Reset mode . . . . . | 544 | |
| Slave mode: Gated mode . . . . . | 545 | |
| Slave mode: Trigger mode . . . . . | 546 | |
| 21.3.14 | Timer synchronization (TIM21/22) . . . . . | 547 |
| 21.3.15 | Debug mode . . . . . | 547 |
| 21.4 | TIM21/22 registers . . . . . | 548 |
| 21.4.1 | TIM21/22 control register 1 (TIMx_CR1) . . . . . | 548 |
| 21.4.2 | TIM21/22 control register 2 (TIMx_CR2) . . . . . | 550 |
| 21.4.3 | TIM21/22 slave mode control register (TIMx_SMCR) . . . . . | 551 |
| 21.4.4 | TIM21/22 Interrupt enable register (TIMx_DIER) . . . . . | 554 |
| 21.4.5 | TIM21/22 status register (TIMx_SR) . . . . . | 554 |
| 21.4.6 | TIM21/22 event generation register (TIMx_EGR) . . . . . | 556 |
| 21.4.7 | TIM21/22 capture/compare mode register 1 (TIMx_CCMR1) . . . . . | 557 |
| Output compare mode . . . . . | 557 |
| Input capture mode. . . . . | 559 |
| 21.4.8 TIM21/22 capture/compare enable register (TIMx_CCER) . . . . . | 560 |
| 21.4.9 TIM21/22 counter (TIMx_CNT) . . . . . | 561 |
| 21.4.10 TIM21/22 prescaler (TIMx_PSC) . . . . . | 561 |
| 21.4.11 TIM21/22 auto-reload register (TIMx_ARR) . . . . . | 561 |
| 21.4.12 TIM21/22 capture/compare register 1 (TIMx_CCR1) . . . . . | 562 |
| 21.4.13 TIM21/22 capture/compare register 2 (TIMx_CCR2) . . . . . | 562 |
| 21.4.14 TIM21 option register (TIM21_OR) . . . . . | 563 |
| 21.4.15 TIM22 option register (TIM22_OR) . . . . . | 564 |
| 21.4.16 TIM21/22 register map . . . . . | 565 |
| 22 Basic timers (TIM6/7) . . . . . | 567 |
| 22.1 Introduction . . . . . | 567 |
| 22.2 TIM6/7 main features . . . . . | 567 |
| 22.3 TIM6/7 functional description . . . . . | 568 |
| 22.3.1 Time-base unit . . . . . | 568 |
| Prescaler description . . . . . | 568 |
| 22.3.2 Counting mode . . . . . | 570 |
| 22.3.3 Clock source . . . . . | 573 |
| 22.3.4 Debug mode . . . . . | 574 |
| 22.4 TIM6/7 registers . . . . . | 575 |
| 22.4.1 TIM6/7 control register 1 (TIMx_CR1) . . . . . | 575 |
| 22.4.2 TIM6/7 control register 2 (TIMx_CR2) . . . . . | 576 |
| 22.4.3 TIM6/7 DMA/Interrupt enable register (TIMx_DIER) . . . . . | 576 |
| 22.4.4 TIM6/7 status register (TIMx_SR) . . . . . | 577 |
| 22.4.5 TIM6/7 event generation register (TIMx_EGR) . . . . . | 577 |
| 22.4.6 TIM6/7 counter (TIMx_CNT) . . . . . | 577 |
| 22.4.7 TIM6/7 prescaler (TIMx_PSC) . . . . . | 578 |
| 22.4.8 TIM6/7 auto-reload register (TIMx_ARR) . . . . . | 578 |
| 22.4.9 TIM6/7 register map . . . . . | 579 |
| 23 Low-power timer (LPTIM) . . . . . | 580 |
| 23.1 Introduction . . . . . | 580 |
| 23.2 LPTIM main features . . . . . | 580 |
| 23.3 LPTIM implementation . . . . . | 581 |
| 23.4 LPTIM functional description . . . . . | 581 |
| 23.4.1 | LPTIM block diagram . . . . . | 581 |
| 23.4.2 | LPTIM trigger mapping . . . . . | 582 |
| 23.4.3 | LPTIM reset and clocks . . . . . | 582 |
| 23.4.4 | Glitch filter . . . . . | 582 |
| 23.4.5 | Prescaler . . . . . | 583 |
| 23.4.6 | Trigger multiplexer . . . . . | 584 |
| 23.4.7 | Operating mode . . . . . | 584 |
| One-shot mode . . . . . | 584 | |
| Continous mode . . . . . | 585 | |
| 23.4.8 | Timeout function . . . . . | 586 |
| 23.4.9 | Waveform generation . . . . . | 586 |
| 23.4.10 | Register update . . . . . | 587 |
| 23.4.11 | Counter mode . . . . . | 588 |
| 23.4.12 | Timer enable . . . . . | 589 |
| 23.4.13 | Encoder mode . . . . . | 589 |
| 23.4.14 | Debug mode . . . . . | 590 |
| 23.5 | LPTIM low-power modes . . . . . | 590 |
| 23.6 | LPTIM interrupts . . . . . | 591 |
| 23.7 | LPTIM registers . . . . . | 591 |
| 23.7.1 | LPTIM interrupt and status register (LPTIM_ISR) . . . . . | 592 |
| 23.7.2 | LPTIM interrupt clear register (LPTIM_ICR) . . . . . | 593 |
| 23.7.3 | LPTIM interrupt enable register (LPTIM_IER) . . . . . | 593 |
| 23.7.4 | LPTIM configuration register (LPTIM_CFGGR) . . . . . | 594 |
| 23.7.5 | LPTIM control register (LPTIM_CR) . . . . . | 597 |
| 23.7.6 | LPTIM compare register (LPTIM_CMP) . . . . . | 598 |
| 23.7.7 | LPTIM autoreload register (LPTIM_ARR) . . . . . | 599 |
| 23.7.8 | LPTIM counter register (LPTIM_CNT) . . . . . | 599 |
| 23.7.9 | LPTIM register map . . . . . | 600 |
| 24 | Independent watchdog (IWDG) . . . . . | 601 |
| 24.1 | Introduction . . . . . | 601 |
| 24.2 | IWDG main features . . . . . | 601 |
| 24.3 | IWDG functional description . . . . . | 601 |
| 24.3.1 | IWDG block diagram . . . . . | 601 |
| 24.3.2 | Window option . . . . . | 602 |
| Configuring the IWDG when the window option is enabled . . . . . | 602 | |
| Configuring the IWDG when the window option is disabled . . . . . | 602 |
| 24.3.3 | Hardware watchdog . . . . . | 603 |
| 24.3.4 | Register access protection . . . . . | 603 |
| 24.3.5 | Debug mode . . . . . | 603 |
| 24.4 | IWDG registers . . . . . | 604 |
| 24.4.1 | IWDG key register (IWDG_KR) . . . . . | 604 |
| 24.4.2 | IWDG prescaler register (IWDG_PR) . . . . . | 605 |
| 24.4.3 | IWDG reload register (IWDG_RLR) . . . . . | 606 |
| 24.4.4 | IWDG status register (IWDG_SR) . . . . . | 607 |
| 24.4.5 | IWDG window register (IWDG_WINR) . . . . . | 608 |
| 24.4.6 | IWDG register map . . . . . | 609 |
| 25 | System window watchdog (WWDG) . . . . . | 610 |
| 25.1 | Introduction . . . . . | 610 |
| 25.2 | WWDG main features . . . . . | 610 |
| 25.3 | WWDG functional description . . . . . | 610 |
| 25.3.1 | WWDG block diagram . . . . . | 611 |
| 25.3.2 | Enabling the watchdog . . . . . | 611 |
| 25.3.3 | Controlling the down-counter . . . . . | 611 |
| 25.3.4 | How to program the watchdog timeout . . . . . | 611 |
| 25.3.5 | Debug mode . . . . . | 613 |
| 25.4 | WWDG interrupts . . . . . | 613 |
| 25.5 | WWDG registers . . . . . | 613 |
| 25.5.1 | WWDG control register (WWDG_CR) . . . . . | 613 |
| 25.5.2 | WWDG configuration register (WWDG_CFR) . . . . . | 614 |
| 25.5.3 | WWDG status register (WWDG_SR) . . . . . | 614 |
| 25.5.4 | WWDG register map . . . . . | 615 |
| 26 | Real-time clock (RTC) . . . . . | 616 |
| 26.1 | Introduction . . . . . | 616 |
| 26.2 | RTC main features . . . . . | 617 |
| 26.3 | RTC implementation . . . . . | 617 |
| 26.4 | RTC functional description . . . . . | 618 |
| 26.4.1 | RTC block diagram . . . . . | 618 |
| 26.4.2 | GPIOs controlled by the RTC . . . . . | 619 |
| 26.4.3 | Clock and prescalers . . . . . | 620 |
| 26.4.4 | Real-time clock and calendar . . . . . | 621 |
| 26.4.5 | Programmable alarms . . . . . | 622 |
| 26.4.6 | Periodic auto-wakeup . . . . . | 622 |
| 26.4.7 | RTC initialization and configuration . . . . . | 623 |
| RTC register access . . . . . | 623 | |
| RTC register write protection . . . . . | 623 | |
| Calendar initialization and configuration . . . . . | 623 | |
| Daylight saving time . . . . . | 624 | |
| Programming the alarm . . . . . | 624 | |
| Programming the wakeup timer . . . . . | 624 | |
| 26.4.8 | Reading the calendar . . . . . | 624 |
| When BYPSHAD control bit is cleared in the RTC_CR register. . . . . | 624 | |
| When the BYPSHAD control bit is set in the RTC_CR register (bypass shadow registers) . . . . . | 625 | |
| 26.4.9 | Resetting the RTC . . . . . | 625 |
| 26.4.10 | RTC synchronization . . . . . | 626 |
| 26.4.11 | RTC reference clock detection . . . . . | 626 |
| 26.4.12 | RTC smooth digital calibration . . . . . | 627 |
| Calibration when PREDIV_A<3 . . . . . | 628 | |
| Verifying the RTC calibration . . . . . | 628 | |
| Re-calibration on-the-fly . . . . . | 629 | |
| 26.4.13 | Time-stamp function . . . . . | 629 |
| 26.4.14 | Tamper detection . . . . . | 630 |
| RTC backup registers . . . . . | 630 | |
| Tamper detection initialization . . . . . | 630 | |
| Trigger output generation on tamper event . . . . . | 631 | |
| Timestamp on tamper event . . . . . | 631 | |
| Edge detection on tamper inputs . . . . . | 631 | |
| Level detection with filtering on RTC_TAMPx inputs . . . . . | 631 | |
| 26.4.15 | Calibration clock output . . . . . | 632 |
| 26.4.16 | Alarm output . . . . . | 632 |
| Alarm output . . . . . | 632 | |
| 26.5 | RTC low-power modes . . . . . | 633 |
| 26.6 | RTC interrupts . . . . . | 633 |
| 26.7 | RTC registers . . . . . | 634 |
| 26.7.1 | RTC time register (RTC_TR) . . . . . | 634 |
| 26.7.2 | RTC date register (RTC_DR) . . . . . | 635 |
| 26.7.3 | RTC control register (RTC_CR) . . . . . | 636 |
| 26.7.4 | RTC initialization and status register (RTC_ISR) . . . . . | 639 |
| 26.7.5 | RTC prescaler register (RTC_PRER) . . . . . | 642 |
- 26.7.6 RTC wakeup timer register (RTC_WUTR) . . . . . 643
- 26.7.7 RTC alarm A register (RTC_ALRMAR) . . . . . 644
- 26.7.8 RTC alarm B register (RTC_ALRMBR) . . . . . 645
- 26.7.9 RTC write protection register (RTC_WPR) . . . . . 646
- 26.7.10 RTC sub second register (RTC_SSR) . . . . . 646
- 26.7.11 RTC shift control register (RTC_SHIFTR) . . . . . 647
- 26.7.12 RTC timestamp time register (RTC_TSTR) . . . . . 648
- 26.7.13 RTC timestamp date register (RTC_TSDR) . . . . . 649
- 26.7.14 RTC time-stamp sub second register (RTC_TSSSR) . . . . . 650
- 26.7.15 RTC calibration register (RTC_CALR) . . . . . 651
- 26.7.16 RTC tamper configuration register (RTC_TAMPCR) . . . . . 652
- 26.7.17 RTC alarm A sub second register (RTC_ALRMASSR) . . . . . 655
- 26.7.18 RTC alarm B sub second register (RTC_ALRMBSSR) . . . . . 656
- 26.7.19 RTC option register (RTC_OR) . . . . . 657
- 26.7.20 RTC backup registers (RTC_BKPxR) . . . . . 657
- 26.7.21 RTC register map . . . . . 658
27 Inter-integrated circuit (I2C) interface . . . . . 660
- 27.1 Introduction . . . . . 660
- 27.2 I2C main features . . . . . 660
- 27.3 I2C implementation . . . . . 661
- 27.4 I2C functional description . . . . . 661
- 27.4.1 I2C1/3 block diagram . . . . . 662
- 27.4.2 I2C2 block diagram . . . . . 663
- 27.4.3 I2C pins and internal signals . . . . . 664
- 27.4.4 I2C clock requirements . . . . . 664
- 27.4.5 Mode selection . . . . . 664
- Communication flow . . . . . 665
- 27.4.6 I2C initialization . . . . . 665
- Enabling and disabling the peripheral . . . . . 665
- Noise filters . . . . . 665
- I2C timings . . . . . 667
- 27.4.7 Software reset . . . . . 670
- 27.4.8 Data transfer . . . . . 671
- Reception . . . . . 671
- Transmission . . . . . 672
- Hardware transfer management. . . . . 672
| 27.4.9 | I2C slave mode . . . . . | 673 |
| I2C slave initialization . . . . . | 673 | |
| Slave clock stretching (NOSTRETCH = 0). . . . . | 674 | |
| Slave without clock stretching (NOSTRETCH = 1). . . . . | 674 | |
| Slave byte control mode . . . . . | 675 | |
| Slave transmitter . . . . . | 676 | |
| Slave receiver . . . . . | 680 | |
| 27.4.10 | I2C master mode . . . . . | 682 |
| I2C master initialization . . . . . | 682 | |
| Master communication initialization (address phase). . . . . | 684 | |
| Initialization of a master receiver addressing a 10-bit address slave . . . . . | 685 | |
| Master transmitter . . . . . | 686 | |
| Master receiver . . . . . | 690 | |
| 27.4.11 | I2C_TIMINGR register configuration examples . . . . . | 694 |
| 27.4.12 | SMBus specific features . . . . . | 695 |
| Introduction. . . . . | 695 | |
| Bus protocols . . . . . | 695 | |
| Address resolution protocol (ARP). . . . . | 695 | |
| Received command and data acknowledge control . . . . . | 696 | |
| Host notify protocol . . . . . | 696 | |
| SMBus alert . . . . . | 696 | |
| Packet error checking . . . . . | 696 | |
| Timeouts . . . . . | 696 | |
| Bus idle detection . . . . . | 698 | |
| 27.4.13 | SMBus initialization . . . . . | 698 |
| Received command and data acknowledge control (Slave mode). . . . . | 698 | |
| Specific address (Slave mode). . . . . | 698 | |
| Packet error checking . . . . . | 698 | |
| Timeout detection . . . . . | 699 | |
| Bus idle detection . . . . . | 699 | |
| 27.4.14 | SMBus: I2C_TIMEOUTR register configuration examples . . . . . | 700 |
| 27.4.15 | SMBus slave mode . . . . . | 700 |
| SMBus slave transmitter . . . . . | 700 | |
| SMBus Slave receiver . . . . . | 702 | |
| SMBus master transmitter . . . . . | 704 | |
| SMBus master receiver . . . . . | 706 | |
| 27.4.16 | Wakeup from Stop mode on address match . . . . . | 708 |
| 27.4.17 | Error conditions . . . . . | 708 |
| Bus error (BERR) . . . . . | 708 | |
| Arbitration lost (ARLO) . . . . . | 709 | |
| Overrun/underrun error (OVR) . . . . . | 709 |
- Packet error checking error (PECERR) . . . . . 709
- Timeout Error (TIMEOUT) . . . . . 709
- Alert (ALERT) . . . . . 710
- 27.4.18 DMA requests . . . . . 710
- Transmission using DMA . . . . . 710
- Reception using DMA . . . . . 711
- 27.4.19 Debug mode . . . . . 711
- 27.5 I2C low-power modes . . . . . 711
- 27.6 I2C interrupts . . . . . 712
- 27.7 I2C registers . . . . . 713
- 27.7.1 I2C control register 1 (I2C_CR1) . . . . . 713
- 27.7.2 I2C control register 2 (I2C_CR2) . . . . . 716
- 27.7.3 I2C own address 1 register (I2C_OAR1) . . . . . 718
- 27.7.4 I2C own address 2 register (I2C_OAR2) . . . . . 719
- 27.7.5 I2C timing register (I2C_TIMINGR) . . . . . 720
- 27.7.6 I2C timeout register (I2C_TIMEOUTR) . . . . . 721
- 27.7.7 I2C interrupt and status register (I2C_ISR) . . . . . 722
- 27.7.8 I2C interrupt clear register (I2C_ICR) . . . . . 724
- 27.7.9 I2C PEC register (I2C_PECR) . . . . . 725
- 27.7.10 I2C receive data register (I2C_RXDR) . . . . . 726
- 27.7.11 I2C transmit data register (I2C_TXDR) . . . . . 726
- 27.7.12 I2C register map . . . . . 727
28 Universal synchronous/asynchronous receiver transmitter (USART/UART) . . . . . 729
- 28.1 Introduction . . . . . 729
- 28.2 USART main features . . . . . 729
- 28.3 USART extended features . . . . . 730
- 28.4 USART implementation . . . . . 731
- 28.5 USART functional description . . . . . 731
- 28.5.1 USART character description . . . . . 734
- 28.5.2 USART transmitter . . . . . 736
- Character transmission . . . . . 736
- Single byte communication . . . . . 737
- Break characters . . . . . 738
- Idle characters . . . . . 738
- 28.5.3 USART receiver . . . . . 739
| Start bit detection . . . . . | 739 |
| Character reception . . . . . | 740 |
| Break character . . . . . | 740 |
| Idle character . . . . . | 740 |
| Overrun error . . . . . | 741 |
| Selecting the proper oversampling method . . . . . | 741 |
| Framing error . . . . . | 743 |
| Configurable stop bits during reception . . . . . | 744 |
| 28.5.4 USART baud rate generation . . . . . | 744 |
| How to derive USARTDIV from USART_BRR register values . . . . . | 745 |
| 28.5.5 Tolerance of the USART receiver to clock deviation . . . . . | 746 |
| 28.5.6 USART auto baud rate detection . . . . . | 748 |
| 28.5.7 Multiprocessor communication using USART . . . . . | 749 |
| Idle line detection (WAKE=0) . . . . . | 750 |
| 4-bit/7-bit address mark detection (WAKE=1) . . . . . | 750 |
| 28.5.8 Modbus communication using USART . . . . . | 751 |
| Modbus/RTU . . . . . | 751 |
| Modbus/ASCII . . . . . | 751 |
| 28.5.9 USART parity control . . . . . | 752 |
| Even parity . . . . . | 752 |
| Odd parity . . . . . | 752 |
| Parity checking in reception . . . . . | 752 |
| Parity generation in transmission . . . . . | 752 |
| 28.5.10 USART LIN (local interconnection network) mode . . . . . | 753 |
| LIN transmission . . . . . | 753 |
| LIN reception . . . . . | 753 |
| 28.5.11 USART synchronous mode . . . . . | 755 |
| 28.5.12 USART Single-wire Half-duplex communication . . . . . | 758 |
| 28.5.13 USART Smartcard mode . . . . . | 758 |
| Block mode (T=1) . . . . . | 761 |
| Direct and inverse convention . . . . . | 762 |
| 28.5.14 USART IrDA SIR ENDEC block . . . . . | 763 |
| IrDA low-power mode . . . . . | 764 |
| 28.5.15 USART continuous communication in DMA mode . . . . . | 765 |
| Transmission using DMA . . . . . | 765 |
| Reception using DMA . . . . . | 766 |
| Error flagging and interrupt generation in multibuffer communication . . . . . | 767 |
| 28.5.16 RS232 hardware flow control and RS485 driver enable using USART . . . . . | 767 |
| RS232 RTS flow control . . . . . | 768 |
| RS232 CTS flow control . . . . . | 768 |
| RS485 Driver Enable . . . . . | 769 |
| 28.5.17 Wakeup from Stop mode using USART . . . . . | 769 |
| Using Mute mode with Stop mode . . . . . | 770 |
| Determining the maximum USART baud rate allowing to wakeup correctly from Stop mode when the USART clock source is the HSI clock. . . . . | 770 |
| 28.6 USART in low-power modes . . . . . | 771 |
| 28.7 USART interrupts . . . . . | 771 |
| 28.8 USART registers . . . . . | 773 |
| 28.8.1 USART control register 1 (USART_CR1) . . . . . | 773 |
| 28.8.2 USART control register 2 (USART_CR2) . . . . . | 776 |
| 28.8.3 USART control register 3 (USART_CR3) . . . . . | 780 |
| 28.8.4 USART baud rate register (USART_BRR) . . . . . | 784 |
| 28.8.5 USART guard time and prescaler register (USART_GTPR) . . . . . | 784 |
| 28.8.6 USART receiver timeout register (USART_RTOR) . . . . . | 785 |
| 28.8.7 USART request register (USART_RQR) . . . . . | 786 |
| 28.8.8 USART interrupt and status register (USART_ISR) . . . . . | 787 |
| 28.8.9 USART interrupt flag clear register (USART_ICR) . . . . . | 792 |
| 28.8.10 USART receive data register (USART_RDR) . . . . . | 793 |
| 28.8.11 USART transmit data register (USART_TDR) . . . . . | 793 |
| 28.8.12 USART register map . . . . . | 794 |
| 29 Low-power universal asynchronous receiver transmitter (LPUART) . . . . . | 796 |
| 29.1 Introduction . . . . . | 796 |
| 29.2 LPUART main features . . . . . | 797 |
| 29.3 LPUART implementation . . . . . | 797 |
| 29.4 LPUART functional description . . . . . | 798 |
| 29.4.1 LPUART character description . . . . . | 800 |
| 29.4.2 LPUART transmitter . . . . . | 802 |
| Character transmission. . . . . | 802 |
| Single byte communication. . . . . | 803 |
| Break characters . . . . . | 804 |
| Idle characters . . . . . | 804 |
| 29.4.3 LPUART receiver . . . . . | 804 |
| Start bit detection . . . . . | 804 |
| Character reception . . . . . | 805 |
| Break character . . . . . | 805 |
| Idle character . . . . . | 805 |
| Overrun error . . . . . | 806 |
| Selecting the clock source . . . . . | 806 |
| Framing error . . . . . | 807 |
| Configurable stop bits during reception . . . . . | 807 |
| 29.4.4 LPUART baud rate generation . . . . . | 807 |
| 29.4.5 Tolerance of the LPUART receiver to clock deviation . . . . . | 809 |
| 29.4.6 Multiprocessor communication using LPUART . . . . . | 810 |
| Idle line detection (WAKE=0) . . . . . | 810 |
| 4-bit/7-bit address mark detection (WAKE=1) . . . . . | 811 |
| 29.4.7 LPUART parity control . . . . . | 812 |
| Even parity . . . . . | 812 |
| Odd parity . . . . . | 812 |
| Parity checking in reception . . . . . | 813 |
| Parity generation in transmission . . . . . | 813 |
| 29.4.8 Single-wire Half-duplex communication using LPUART . . . . . | 813 |
| 29.4.9 Continuous communication in DMA mode using LPUART . . . . . | 813 |
| Transmission using DMA . . . . . | 814 |
| Reception using DMA . . . . . | 815 |
| Error flagging and interrupt generation in multibuffer communication . . . . . | 816 |
| 29.4.10 RS232 Hardware flow control and RS485 Driver Enable using LPUART . . . . . | 816 |
| RS232 RTS flow control . . . . . | 817 |
| RS232 CTS flow control . . . . . | 817 |
| RS485 Driver Enable . . . . . | 818 |
| 29.4.11 Wakeup from Stop mode using LPUART . . . . . | 819 |
| Using Mute mode with Stop mode . . . . . | 820 |
| Determining the maximum LPUART baud rate allowing to wakeup correctly from Stop mode when the LPUART clock source is the HSI clock . . . . . | 820 |
| 29.5 LPUART in low-power mode . . . . . | 821 |
| 29.6 LPUART interrupts . . . . . | 821 |
| 29.7 LPUART registers . . . . . | 823 |
| 29.7.1 Control register 1 (LPUART_CR1) . . . . . | 823 |
| 29.7.2 Control register 2 (LPUART_CR2) . . . . . | 826 |
| 29.7.3 Control register 3 (LPUART_CR3) . . . . . | 828 |
| 29.7.4 Baud rate register (LPUART_BRR) . . . . . | 830 |
| 29.7.5 Request register (LPUART_RQR) . . . . . | 830 |
| 29.7.6 Interrupt & status register (LPUART_ISR) . . . . . | 831 |
| 29.7.7 Interrupt flag clear register (LPUART_ICR) . . . . . | 834 |
- 29.7.8 Receive data register (LPUART_RDR) . . . . . 835
- 29.7.9 Transmit data register (LPUART_TDR) . . . . . 835
- 29.7.10 LPUART register map . . . . . 837
30 Serial peripheral interface/ inter-IC sound (SPI/I2S) . . . . . 838
- 30.1 Introduction . . . . . 838
- 30.1.1 SPI main features . . . . . 838
- 30.1.2 SPI extended features . . . . . 839
- 30.1.3 I2S features . . . . . 839
- 30.2 SPI/I2S implementation . . . . . 839
- 30.3 SPI functional description . . . . . 840
- 30.3.1 General description . . . . . 840
- 30.3.2 Communications between one master and one slave . . . . . 841
- Full-duplex communication. . . . . 841
- Half-duplex communication . . . . . 841
- Simplex communications . . . . . 842
- 30.3.3 Standard multi-slave communication . . . . . 844
- 30.3.4 Multi-master communication . . . . . 845
- 30.3.5 Slave select (NSS) pin management . . . . . 845
- 30.3.6 Communication formats . . . . . 847
- Clock phase and polarity controls. . . . . 847
- Data frame format. . . . . 848
- 30.3.7 SPI configuration . . . . . 849
- 30.3.8 Procedure for enabling SPI . . . . . 849
- 30.3.9 Data transmission and reception procedures . . . . . 850
- Rx and Tx buffers . . . . . 850
- Tx buffer handling. . . . . 850
- Rx buffer handling . . . . . 850
- Sequence handling. . . . . 850
- 30.3.10 Procedure for disabling the SPI . . . . . 852
- 30.3.11 Communication using DMA (direct memory addressing) . . . . . 853
- 30.3.12 SPI status flags . . . . . 855
- Tx buffer empty flag (TXE) . . . . . 855
- Rx buffer not empty (RXNE) . . . . . 855
- Busy flag (BSY) . . . . . 855
- 30.3.13 SPI error flags . . . . . 856
- Overrun flag (OVR). . . . . 856
- Mode fault (MODF). . . . . 856
- CRC error (CRCERR) . . . . . 857
| TI mode frame format error (FRE) . . . . . | 857 |
| 30.4 SPI special features . . . . . | 857 |
| 30.4.1 TI mode . . . . . | 857 |
| TI protocol in master mode. . . . . | 857 |
| 30.4.2 CRC calculation . . . . . | 858 |
| CRC principle . . . . . | 858 |
| CRC transfer managed by CPU . . . . . | 858 |
| CRC transfer managed by DMA. . . . . | 859 |
| Resetting the SPIx_TXCRC and SPIx_RXCRC values . . . . . | 859 |
| 30.5 SPI interrupts . . . . . | 860 |
| 30.6 I 2 S functional description . . . . . | 861 |
| 30.6.1 I 2 S general description . . . . . | 861 |
| 30.6.2 I 2 S full-duplex . . . . . | 862 |
| 30.6.3 Supported audio protocols . . . . . | 863 |
| I 2 S Philips standard . . . . . | 864 |
| MSB justified standard . . . . . | 866 |
| LSB justified standard. . . . . | 867 |
| PCM standard. . . . . | 869 |
| 30.6.4 Clock generator . . . . . | 870 |
| 30.6.5 I 2 S master mode . . . . . | 872 |
| Procedure. . . . . | 872 |
| Transmission sequence . . . . . | 872 |
| Reception sequence . . . . . | 873 |
| 30.6.6 I 2 S slave mode . . . . . | 874 |
| Transmission sequence . . . . . | 874 |
| Reception sequence . . . . . | 875 |
| 30.6.7 I 2 S status flags . . . . . | 875 |
| Busy flag (BSY) . . . . . | 875 |
| Tx buffer empty flag (TXE) . . . . . | 876 |
| RX buffer not empty (RXNE) . . . . . | 876 |
| Channel Side flag (CHSIDE) . . . . . | 876 |
| 30.6.8 I 2 S error flags . . . . . | 876 |
| Underrun flag (UDR) . . . . . | 876 |
| Overrun flag (OVR). . . . . | 877 |
| Frame error flag (FRE) . . . . . | 877 |
| 30.6.9 I 2 S interrupts . . . . . | 877 |
| 30.6.10 DMA features . . . . . | 877 |
| 30.7 SPI and I 2 S registers . . . . . | 878 |
| 30.7.1 SPI control register 1 (SPI_CR1) (not used in I 2 S mode) . . . . . | 878 |
| 30.7.2 | SPI control register 2 (SPI_CR2) . . . . . | 880 |
| 30.7.3 | SPI status register (SPI_SR) . . . . . | 881 |
| 30.7.4 | SPI data register (SPI_DR) . . . . . | 883 |
| 30.7.5 | SPI CRC polynomial register (SPI_CRCPR) (not used in I 2 S mode) . . . . . | 883 |
| 30.7.6 | SPI RX CRC register (SPI_RXCRCR) (not used in I 2 S mode) . . . . . | 884 |
| 30.7.7 | SPI TX CRC register (SPI_TXCRCR) (not used in I 2 S mode) . . . . . | 884 |
| 30.7.8 | SPI_I 2 S configuration register (SPI_I2SCFGGR) . . . . . | 885 |
| 30.7.9 | SPI_I 2 S prescaler register (SPI_I2SPR) . . . . . | 886 |
| 30.7.10 | SPI register map . . . . . | 887 |
| 31 | Universal serial bus full-speed device interface (USB) . . . . . | 888 |
| 31.1 | Introduction . . . . . | 888 |
| 31.2 | USB main features . . . . . | 888 |
| 31.3 | USB implementation . . . . . | 888 |
| 31.4 | USB functional description . . . . . | 889 |
| 31.4.1 | Description of USB blocks . . . . . | 890 |
| 31.5 | Programming considerations . . . . . | 891 |
| 31.5.1 | Generic USB device programming . . . . . | 891 |
| 31.5.2 | System and power-on reset . . . . . | 892 |
| USB reset (RESET interrupt) . . . . . | 892 | |
| Structure and usage of packet buffers . . . . . | 892 | |
| Endpoint initialization . . . . . | 894 | |
| IN packets (data transmission) . . . . . | 894 | |
| OUT and SETUP packets (data reception) . . . . . | 895 | |
| Control transfers . . . . . | 896 | |
| 31.5.3 | Double-buffered endpoints . . . . . | 897 |
| 31.5.4 | Isochronous transfers . . . . . | 899 |
| 31.5.5 | Suspend/Resume events . . . . . | 900 |
| 31.6 | USB and USB SRAM registers . . . . . | 903 |
| 31.6.1 | Common registers . . . . . | 903 |
| USB control register (USB_CNTR) . . . . . | 903 | |
| USB interrupt status register (USB_ISTR) . . . . . | 905 | |
| USB frame number register (USB_FNR) . . . . . | 908 | |
| USB device address (USB_DADDR) . . . . . | 908 | |
| Buffer table address (USB_BTABLE) . . . . . | 909 | |
| LPM control and status register (USB_LPMCSR) . . . . . | 909 | |
| Battery charging detector (USB_BCDR) . . . . . | 910 |
| Endpoint-specific registers . . . . . | 911 |
| USB endpoint n register (USB_EPnR), n=[0..7] . . . . . | 911 |
| 31.6.2 Buffer descriptor table . . . . . | 916 |
| Transmission buffer address n (USB_ADDRn_TX) . . . . . | 916 |
| Transmission byte count n (USB_COUNTn_TX) . . . . . | 916 |
| Reception buffer address n (USB_ADDRn_RX) . . . . . | 917 |
| Reception byte count n (USB_COUNTn_RX) . . . . . | 917 |
| 31.6.3 USB register map . . . . . | 919 |
| 32 Debug support (DBG) . . . . . | 921 |
| 32.1 Overview . . . . . | 921 |
| 32.2 Reference Arm® documentation . . . . . | 922 |
| 32.3 Pinout and debug port pins . . . . . | 922 |
| 32.3.1 SWD port pins . . . . . | 922 |
| 32.3.2 SW-DP pin assignment . . . . . | 922 |
| 32.3.3 Internal pull-up & pull-down on SWD pins . . . . . | 923 |
| 32.4 ID codes and locking mechanism . . . . . | 923 |
| 32.4.1 MCU device ID code . . . . . | 923 |
| DBG_IDCODE . . . . . | 923 |
| 32.5 SWD port . . . . . | 924 |
| 32.5.1 SWD protocol introduction . . . . . | 924 |
| 32.5.2 SWD protocol sequence . . . . . | 924 |
| 32.5.3 SW-DP state machine (reset, idle states, ID code) . . . . . | 925 |
| 32.5.4 DP and AP read/write accesses . . . . . | 926 |
| 32.5.5 SW-DP registers . . . . . | 926 |
| 32.5.6 SW-AP registers . . . . . | 927 |
| 32.6 Core debug . . . . . | 928 |
| 32.7 BPU (Break Point Unit) . . . . . | 928 |
| 32.7.1 BPU functionality . . . . . | 928 |
| 32.8 DWT (Data Watchpoint) . . . . . | 929 |
| 32.8.1 DWT functionality . . . . . | 929 |
| 32.8.2 DWT Program Counter Sample Register . . . . . | 929 |
| 32.9 MCU debug component (DBG) . . . . . | 929 |
| 32.9.1 Debug support for low-power modes . . . . . | 929 |
| 32.9.2 Debug support for timers, watchdog and I 2 C . . . . . | 930 |
| 32.9.3 Debug MCU configuration register (DBG_CR) . . . . . | 930 |
| 32.9.4 Debug MCU APB1 freeze register (DBG_APB1_FZ) . . . . . | 932 |
32.9.5 Debug MCU APB2 freeze register (DBG_APB2_FZ) . . . . . 934
32.10 DBG register map . . . . . 935
33 Device electronic signature . . . . . 936
33.1 Memory size register . . . . . 936
33.1.1 Flash size register . . . . . 936
33.2 Unique device ID registers (96 bits) . . . . . 936
Appendix A Code examples. . . . . 938
A.1 Introduction . . . . . 938
A.2 NVM/RCC Operation code example . . . . . 938
A.2.1 Increasing the CPU frequency preparation sequence code . . . . . 938
A.2.2 Decreasing the CPU frequency preparation sequence code . . . . . 938
A.2.3 Switch from PLL to HSI16 sequence code . . . . . 939
A.2.4 Switch to PLL sequence code. . . . . 939
A.3 NVM Operation code example . . . . . 940
A.3.1 Unlocking the data EEPROM and FLASH_PECR register code example . . . . . 940
A.3.2 Locking data EEPROM and FLASH_PECR register code example. . . . . 940
A.3.3 Unlocking the NVM program memory code example . . . . . 940
A.3.4 Unlocking the option bytes area code example . . . . . 941
A.3.5 Write to data EEPROM code example . . . . . 941
A.3.6 Erase to data EEPROM code example . . . . . 941
A.3.7 Program Option byte code example . . . . . 942
A.3.8 Erase Option byte code example . . . . . 942
A.3.9 Program a single word to Flash program memory code example . . . . . 943
A.3.10 Program half-page to Flash program memory code example . . . . . 944
A.3.11 Erase a page in Flash program memory code example. . . . . 945
A.3.12 Mass erase code example . . . . . 946
A.4 Clock Controller. . . . . 947
A.4.1 HSE start sequence code example . . . . . 947
A.4.2 PLL configuration modification code example . . . . . 948
A.4.3 MCO selection code example. . . . . 949
A.5 GPIOs . . . . . 949
A.5.1 Locking mechanism code example. . . . . 949
A.5.2 Alternate function selection sequence code example. . . . . 949
A.5.3 Analog GPIO configuration code example . . . . . 949
| A.6 | DMA . . . . . | 950 |
| A.6.1 | DMA Channel Configuration sequence code example . . . . . | 950 |
| A.7 | Interrupts and event . . . . . | 950 |
| A.7.1 | NVIC initialization example . . . . . | 950 |
| A.7.2 | Extended interrupt selection code example . . . . . | 950 |
| A.8 | ADC . . . . . | 951 |
| A.8.1 | Calibration code example . . . . . | 951 |
| A.8.2 | ADC enable sequence code example . . . . . | 951 |
| A.8.3 | ADC disable sequence code example . . . . . | 952 |
| A.8.4 | ADC clock selection code example . . . . . | 952 |
| A.8.5 | Single conversion sequence code example - Software trigger . . . . . | 952 |
| A.8.6 | Continuous conversion sequence code example - Software trigger . . . . . | 953 |
| A.8.7 | Single conversion sequence code example - Hardware trigger . . . . . | 953 |
| A.8.8 | Continuous conversion sequence code example - Hardware trigger . . . . . | 954 |
| A.8.9 | DMA one shot mode sequence code example . . . . . | 954 |
| A.8.10 | DMA circular mode sequence code example . . . . . | 955 |
| A.8.11 | Wait mode sequence code example . . . . . | 955 |
| A.8.12 | Auto off and no wait mode sequence code example . . . . . | 955 |
| A.8.13 | Auto off and wait mode sequence code example . . . . . | 956 |
| A.8.14 | Analog watchdog code example . . . . . | 956 |
| A.8.15 | Oversampling code example . . . . . | 957 |
| A.8.16 | Temperature configuration code example . . . . . | 957 |
| A.8.17 | Temperature computation code example . . . . . | 957 |
| A.9 | DAC . . . . . | 958 |
| A.9.1 | Independent trigger without wave generation code example . . . . . | 958 |
| A.9.2 | Independent trigger with single triangle generation code example . . . . . | 958 |
| A.9.3 | DMA initialization code example . . . . . | 958 |
| A.10 | TSC code example . . . . . | 959 |
| A.10.1 | TSC configuration code example . . . . . | 959 |
| A.10.2 | TSC interrupt code example . . . . . | 960 |
| A.11 | Timers . . . . . | 960 |
| A.11.1 | Upcounter on TI2 rising edge code example . . . . . | 960 |
| A.11.2 | Up counter on each 2 ETR rising edges code example . . . . . | 960 |
| A.11.3 | Input capture configuration code example . . . . . | 961 |
| A.11.4 | Input capture data management code example . . . . . | 961 |
| A.11.5 | PWM input configuration code example . . . . . | 962 |
| A.11.6 | PWM input with DMA configuration code example . . . . . | 962 |
| A.11.7 | Output compare configuration code example . . . . . | 963 |
| A.11.8 | Edge-aligned PWM configuration example. . . . . | 963 |
| A.11.9 | Center-aligned PWM configuration example . . . . . | 964 |
| A.11.10 | ETR configuration to clear OCxREF code example . . . . . | 964 |
| A.11.11 | Encoder interface code example . . . . . | 965 |
| A.11.12 | Reset mode code example . . . . . | 965 |
| A.11.13 | Gated mode code example. . . . . | 966 |
| A.11.14 | Trigger mode code example . . . . . | 966 |
| A.11.15 | External clock mode 2 + trigger mode code example. . . . . | 967 |
| A.11.16 | One-Pulse mode code example . . . . . | 967 |
| A.11.17 | Timer prescaling another timer code example . . . . . | 968 |
| A.11.18 | Timer enabling another timer code example. . . . . | 968 |
| A.11.19 | Master and slave synchronization code example . . . . . | 969 |
| A.11.20 | Two timers synchronized by an external trigger code example . . . . . | 971 |
| A.11.21 | DMA burst feature code example . . . . . | 972 |
| A.12 | Low-power timer (LPTIM) . . . . . | 973 |
| A.12.1 | Pulse counter configuration code example. . . . . | 973 |
| A.13 | IWDG code example . . . . . | 973 |
| A.13.1 | IWDG configuration code example . . . . . | 973 |
| A.13.2 | IWDG configuration with window code example. . . . . | 973 |
| A.14 | WWDG code example. . . . . | 974 |
| A.14.1 | WWDG configuration code example. . . . . | 974 |
| A.15 | RTC code example . . . . . | 974 |
| A.15.1 | RTC calendar configuration code example. . . . . | 974 |
| A.15.2 | RTC alarm configuration code example . . . . . | 975 |
| A.15.3 | RTC WUT configuration code example . . . . . | 975 |
| A.15.4 | RTC read calendar code example . . . . . | 976 |
| A.15.5 | RTC calibration code example . . . . . | 976 |
| A.15.6 | RTC tamper and time stamp configuration code example . . . . . | 976 |
| A.15.7 | RTC tamper and time stamp code example . . . . . | 977 |
| A.15.8 | RTC clock output code example . . . . . | 977 |
| A.16 | I2C code example . . . . . | 977 |
| A.16.1 | I2C configured in slave mode code example . . . . . | 977 |
| A.16.2 | I2C slave transmitter code example . . . . . | 978 |
| A.16.3 | I2C slave receiver code example . . . . . | 978 |
| A.16.4 | I2C configured in master mode to receive code example . . . . . | 978 |
| A.16.5 | I2C configured in master mode to transmit code example . . . . . | 979 |
| A.16.6 | I2C master transmitter code example . . . . . | 979 |
| A.16.7 | I2C master receiver code example . . . . . | 979 |
| A.16.8 | I2C configured in master mode to transmit with DMA code example . . | 979 |
| A.16.9 | I2C configured in slave mode to receive with DMA code example . . . . | 980 |
| A.17 | USART code example . . . . . | 980 |
| A.17.1 | USART transmitter configuration code example . . . . . | 980 |
| A.17.2 | USART transmit byte code example . . . . . | 980 |
| A.17.3 | USART transfer complete code example . . . . . | 980 |
| A.17.4 | USART receiver configuration code example . . . . . | 980 |
| A.17.5 | USART receive byte code example . . . . . | 981 |
| A.17.6 | USART LIN mode code example . . . . . | 981 |
| A.17.7 | USART synchronous mode code example . . . . . | 981 |
| A.17.8 | USART single-wire half-duplex code example . . . . . | 982 |
| A.17.9 | USART smartcard mode code example . . . . . | 982 |
| A.17.10 | USART IrDA mode code example . . . . . | 982 |
| A.17.11 | USART DMA code example . . . . . | 983 |
| A.17.12 | USART hardware flow control code example . . . . . | 983 |
| A.18 | LPUART code example . . . . . | 984 |
| A.18.1 | LPUART receiver configuration code example . . . . . | 984 |
| A.18.2 | LPUART receive byte code example . . . . . | 984 |
| A.19 | SPI code example . . . . . | 984 |
| A.19.1 | SPI master configuration code example . . . . . | 984 |
| A.19.2 | SPI slave configuration code example . . . . . | 984 |
| A.19.3 | SPI full duplex communication code example . . . . . | 984 |
| A.19.4 | SPI master configuration with DMA code example . . . . . | 985 |
| A.19.5 | SPI slave configuration with DMA code example . . . . . | 985 |
| A.19.6 | SPI interrupt code example . . . . . | 985 |
| A.20 | DBG code example . . . . . | 985 |
| A.20.1 | DBG read device Id code example . . . . . | 985 |
| A.20.2 | DBG debug in LPM code example . . . . . | 985 |
| Revision history | . . . . . | 986 |
List of tables
| Table 1. | STM32L0x2 memory density . . . . . | 53 |
| Table 2. | Overview of features per category . . . . . | 53 |
| Table 3. | STM32L0x2 peripheral register boundary addresses . . . . . | 59 |
| Table 4. | Boot modes . . . . . | 63 |
| Table 5. | NVM organization (category 3 devices) . . . . . | 66 |
| Table 6. | NVM organization for UFB = 0 (192 Kbyte category 5 devices) . . . . . | 67 |
| Table 7. | Flash memory and data EEPROM remapping (192 Kbyte category 5 devices) . . . . . | 68 |
| Table 8. | NVM organization for UFB = 0 (128 Kbyte category 5 devices) . . . . . | 68 |
| Table 9. | Flash memory and data EEPROM remapping (128 Kbyte category 5 devices) . . . . . | 69 |
| Table 10. | NVM organization for UFB = 0 (64 Kbyte category 5 devices) . . . . . | 69 |
| Table 11. | Boot pin and BFB2 bit configuration . . . . . | 70 |
| Table 12. | Link between master clock power range and frequencies . . . . . | 72 |
| Table 13. | Delays to memory access and number of wait states . . . . . | 72 |
| Table 14. | Internal buffer management . . . . . | 75 |
| Table 15. | Configurations for buffers and speculative reading . . . . . | 78 |
| Table 16. | Dhrystone performances in all memory interface configurations . . . . . | 79 |
| Table 17. | NVM write/erase timings . . . . . | 93 |
| Table 18. | NVM write/erase duration . . . . . | 93 |
| Table 19. | Protection level and content of RDP Option bytes . . . . . | 97 |
| Table 20. | Link between protection bits of FLASH_WRPROTx register and protected address in Flash program memory . . . . . | 98 |
| Table 21. | Memory access vs mode, protection and Flash program memory sectors . . . . . | 99 |
| Table 22. | Flash interrupt request . . . . . | 102 |
| Table 23. | Flash interface - register map and reset values . . . . . | 119 |
| Table 24. | Option byte format . . . . . | 120 |
| Table 25. | Option byte organization . . . . . | 120 |
| Table 26. | CRC internal input/output signals . . . . . | 123 |
| Table 27. | CRC register map and reset values . . . . . | 128 |
| Table 28. | Segment accesses according to the Firewall state . . . . . | 132 |
| Table 29. | Segment granularity and area ranges . . . . . | 133 |
| Table 30. | Firewall register map and reset values . . . . . | 140 |
| Table 31. | Performance versus VCORE ranges . . . . . | 144 |
| Table 32. | Summary of low-power modes . . . . . | 152 |
| Table 33. | Sleep-now . . . . . | 156 |
| Table 34. | Sleep-on-exit . . . . . | 157 |
| Table 35. | Sleep-now (Low-power sleep) . . . . . | 158 |
| Table 36. | Sleep-on-exit (Low-power sleep) . . . . . | 159 |
| Table 37. | Stop mode . . . . . | 161 |
| Table 38. | Standby mode . . . . . | 163 |
| Table 39. | PWR - register map and reset values . . . . . | 171 |
| Table 40. | HSE/LSE clock sources . . . . . | 177 |
| Table 41. | System clock source frequency . . . . . | 182 |
| Table 42. | RCC register map and reset values . . . . . | 221 |
| Table 43. | CRS features . . . . . | 224 |
| Table 44. | Effect of low-power modes on CRS . . . . . | 228 |
| Table 45. | Interrupt control bits . . . . . | 228 |
| Table 46. | CRS register map and reset values . . . . . | 233 |
| Table 47. | Port bit configuration table . . . . . | 237 |
| Table 48. | GPIO register map and reset values . . . . . | 250 |
| Table 49. | SYSCFG register map and reset values . . . . . | 259 |
| Table 50. | DMA implementation . . . . . | 262 |
| Table 51. | DMA requests for each channel . . . . . | 263 |
| Table 52. | Programmable data width and endian behavior (when PINC = MINC = 1) . . . . . | 271 |
| Table 53. | DMA interrupt requests . . . . . | 272 |
| Table 54. | DMA register map and reset values . . . . . | 282 |
| Table 55. | List of vectors . . . . . | 285 |
| Table 56. | EXTI lines connections . . . . . | 292 |
| Table 57. | Extended interrupt/event controller register map and reset values . . . . . | 297 |
| Table 58. | ADC input/output pins . . . . . | 300 |
| Table 59. | ADC internal input/output signals . . . . . | 301 |
| Table 60. | External triggers . . . . . | 301 |
| Table 61. | Latency between trigger and start of conversion . . . . . | 306 |
| Table 62. | Configuring the trigger polarity . . . . . | 312 |
| Table 63. | tSAR timings depending on resolution . . . . . | 314 |
| Table 64. | Analog watchdog comparison . . . . . | 323 |
| Table 65. | Analog watchdog channel selection . . . . . | 323 |
| Table 66. | Maximum output results vs N and M. Grayed values indicates truncation . . . . . | 327 |
| Table 67. | ADC interrupts . . . . . | 332 |
| Table 68. | ADC register map and reset values . . . . . | 347 |
| Table 69. | DAC pins . . . . . | 350 |
| Table 70. | External triggers . . . . . | 353 |
| Table 71. | DAC register map and reset values . . . . . | 371 |
| Table 72. | COMP register map and reset values . . . . . | 379 |
| Table 73. | Acquisition sequence summary . . . . . | 383 |
| Table 74. | Spread spectrum deviation versus AHB clock frequency . . . . . | 385 |
| Table 75. | I/O state depending on its mode and IODEF bit value . . . . . | 386 |
| Table 76. | Effect of low-power modes on TSC . . . . . | 388 |
| Table 77. | Interrupt control bits . . . . . | 388 |
| Table 78. | TSC register map and reset values . . . . . | 397 |
| Table 79. | AES internal input/output signals . . . . . | 400 |
| Table 80. | CTR mode initialization vector definition . . . . . | 416 |
| Table 81. | Key endianness in AES_KEYRx registers . . . . . | 419 |
| Table 82. | DMA channel configuration for memory-to-AES data transfer . . . . . | 420 |
| Table 83. | DMA channel configuration for AES-to-memory data transfer . . . . . | 421 |
| Table 84. | AES interrupt requests . . . . . | 423 |
| Table 85. | Processing latency (in clock cycle) . . . . . | 423 |
| Table 86. | AES register map and reset values . . . . . | 431 |
| Table 87. | RNG internal input/output signals . . . . . | 434 |
| Table 88. | RNG interrupt requests . . . . . | 439 |
| Table 89. | RNG register map and reset map . . . . . | 443 |
| Table 90. | Counting direction versus encoder signals . . . . . | 475 |
| Table 91. | TIM2/TIM3 internal trigger connection . . . . . | 492 |
| Table 92. | Output control bit for standard OCx channels . . . . . | 502 |
| Table 93. | TIM2/3 register map and reset values . . . . . | 510 |
| Table 94. | Counting direction versus encoder signals . . . . . | 543 |
| Table 95. | TIMx Internal trigger connection . . . . . | 553 |
| Table 96. | Output control bit for standard OCx channels . . . . . | 561 |
| Table 97. | TIM21/22 register map and reset values . . . . . | 565 |
| Table 98. | TIM6/7 register map and reset values . . . . . | 579 |
| Table 99. | STM32L0x2 LPTIM features . . . . . | 581 |
| Table 100. | LPTIM1 external trigger connection . . . . . | 582 |
| Table 101. | Prescaler division ratios . . . . . | 583 |
| Table 102. | Encoder counting scenarios . . . . . | 589 |
| Table 103. | Effect of low-power modes on the LPTIM . . . . . | 590 |
| Table 104. | Interrupt events . . . . . | 591 |
| Table 105. | LPTIM register map and reset values . . . . . | 600 |
| Table 106. | IWDG register map and reset values . . . . . | 609 |
| Table 107. | WWDG register map and reset values . . . . . | 615 |
| Table 108. | RTC implementation . . . . . | 617 |
| Table 109. | RTC pin PC13 configuration . . . . . | 619 |
| Table 110. | RTC_OUT mapping . . . . . | 620 |
| Table 111. | Effect of low-power modes on RTC . . . . . | 633 |
| Table 112. | Interrupt control bits . . . . . | 633 |
| Table 113. | RTC register map and reset values . . . . . | 658 |
| Table 114. | STM32L0x2 I2C features . . . . . | 661 |
| Table 115. | I2C input/output pins . . . . . | 664 |
| Table 116. | I2C internal input/output signals . . . . . | 664 |
| Table 117. | Comparison of analog vs. digital filters . . . . . | 666 |
| Table 118. | I2C-SMBus specification data setup and hold times . . . . . | 669 |
| Table 119. | I2C configuration . . . . . | 673 |
| Table 120. | I2C-SMBus specification clock timings . . . . . | 684 |
| Table 121. | Examples of timing settings for f I2CCLK = 8 MHz . . . . . | 694 |
| Table 122. | Examples of timings settings for f I2CCLK = 16 MHz . . . . . | 694 |
| Table 123. | SMBus timeout specifications . . . . . | 696 |
| Table 124. | SMBus with PEC configuration . . . . . | 699 |
| Table 125. | Examples of TIMEOUTA settings for various I2CCLK frequencies (max t TIMEOUT = 25 ms) . . . . . | 700 |
| Table 126. | Examples of TIMEOUTB settings for various I2CCLK frequencies . . . . . | 700 |
| Table 127. | Examples of TIMEOUTA settings for various I2CCLK frequencies (max t IDLE = 50 µs) . . . . . | 700 |
| Table 128. | Effect of low-power modes on the I2C . . . . . | 711 |
| Table 129. | I2C Interrupt requests . . . . . | 712 |
| Table 130. | I2C register map and reset values . . . . . | 727 |
| Table 131. | STM32L0x2 USART/LPUART features . . . . . | 731 |
| Table 132. | Noise detection from sampled data . . . . . | 743 |
| Table 133. | Error calculation for programmed baud rates at f
CK
= 32 MHz in both cases of oversampling by 16 or by 8 . . . . . | 746 |
| Table 134. | Tolerance of the USART receiver when BRR [3:0] = 0000 . . . . . | 747 |
| Table 135. | Tolerance of the USART receiver when BRR [3:0] is different from 0000 . . . . . | 747 |
| Table 136. | Frame formats . . . . . | 752 |
| Table 137. | Effect of low-power modes on the USART . . . . . | 771 |
| Table 138. | USART interrupt requests . . . . . | 771 |
| Table 139. | USART register map and reset values . . . . . | 794 |
| Table 140. | STM32L0x2 USART/LPUART features . . . . . | 798 |
| Table 141. | Error calculation for programmed baud rates at f ck = 32.768 kHz . . . . . | 808 |
| Table 142. | Error calculation for programmed baud rates at f ck = 32 MHz . . . . . | 808 |
| Table 143. | Tolerance of the LPUART receiver . . . . . | 809 |
| Table 144. | Frame formats . . . . . | 812 |
| Table 145. | Effect of low-power modes on the LPUART . . . . . | 821 |
| Table 146. | LPUART interrupt requests . . . . . | 821 |
| Table 147. | LPUART register map and reset values . . . . . | 837 |
| Table 148. | STM32L0x2 SPI implementation . . . . . | 839 |
| Table 149. | SPI interrupt requests . . . . . | 860 |
| Table 150. | Audio-frequency precision using standard 8 MHz HSE . . . . . | 871 |
| Table 151. | I 2 S interrupt requests . . . . . | 877 |
| Table 152. | SPI register map and reset values . . . . . | 887 |
| Table 153. | STM32L0x2 USB implementation. . . . . | 888 |
| Table 154. | Double-buffering buffer flag definition. . . . . | 898 |
| Table 155. | Bulk double-buffering memory buffers usage . . . . . | 898 |
| Table 156. | Isochronous memory buffers usage . . . . . | 900 |
| Table 157. | Resume event detection . . . . . | 901 |
| Table 158. | Reception status encoding . . . . . | 914 |
| Table 159. | Endpoint type encoding . . . . . | 914 |
| Table 160. | Endpoint kind meaning . . . . . | 914 |
| Table 161. | Transmission status encoding . . . . . | 915 |
| Table 162. | Definition of allocated buffer memory . . . . . | 918 |
| Table 163. | USB register map and reset values . . . . . | 919 |
| Table 164. | SW debug port pins . . . . . | 922 |
| Table 165. | REV_ID values . . . . . | 924 |
| Table 166. | Packet request (8-bits) . . . . . | 924 |
| Table 167. | ACK response (3 bits). . . . . | 925 |
| Table 168. | DATA transfer (33 bits). . . . . | 925 |
| Table 169. | SW-DP registers . . . . . | 926 |
| Table 170. | 32-bit debug port registers addressed through the shifted value A[3:2] . . . . . | 927 |
| Table 171. | Core debug registers . . . . . | 928 |
| Table 172. | DBG register map and reset values . . . . . | 935 |
| Table 173. | Document revision history . . . . . | 986 |
List of figures
Figure 1. System architecture . . . . . 55
Figure 2. Memory map . . . . . 58
Figure 3. Structure of one internal buffer . . . . . 74
Figure 4. Timing to fetch and execute instructions with prefetch disabled. . . . . 76
Figure 5. Timing to fetch and execute instructions with prefetch enabled . . . . . 78
Figure 6. RDP levels . . . . . 97
Figure 7. CRC calculation unit block diagram . . . . . 123
Figure 8. STM32L0x2 firewall connection schematics. . . . . 130
Figure 9. Firewall functional states . . . . . 134
Figure 10. Power supply overview . . . . . 142
Figure 11. Performance versus VDD and VCORE range . . . . . 145
Figure 12. Power supply supervisors . . . . . 148
Figure 13. Power-on reset/power-down reset waveform . . . . . 149
Figure 14. BOR thresholds . . . . . 150
Figure 15. PVD thresholds . . . . . 151
Figure 16. Simplified diagram of the reset circuit. . . . . 173
Figure 17. Clock tree . . . . . 176
Figure 18. Using TIM21 channel 1 input capture to measure frequencies . . . . . 184
Figure 19. CRS block diagram. . . . . 225
Figure 20. CRS counter behavior . . . . . 226
Figure 21. Basic structure of an I/O port bit . . . . . 236
Figure 22. Basic structure of a 5-Volt tolerant I/O port bit . . . . . 236
Figure 23. Input floating / pull up / pull down configurations . . . . . 241
Figure 24. Output configuration . . . . . 242
Figure 25. Alternate function configuration . . . . . 242
Figure 26. High impedance-analog configuration . . . . . 243
Figure 27. DMA request mapping . . . . . 263
Figure 28. DMA block diagram . . . . . 265
Figure 29. Extended interrupts and events controller (EXTI) block diagram . . . . . 289
Figure 30. Extended interrupt/event GPIO mapping . . . . . 291
Figure 31. ADC block diagram . . . . . 300
Figure 32. ADC calibration. . . . . 303
Figure 33. Calibration factor forcing . . . . . 304
Figure 34. Enabling/disabling the ADC . . . . . 305
Figure 35. ADC clock scheme . . . . . 305
Figure 36. ADC connectivity . . . . . 307
Figure 37. Analog to digital conversion time . . . . . 311
Figure 38. ADC conversion timings . . . . . 311
Figure 39. Stopping an ongoing conversion . . . . . 312
Figure 40. Single conversions of a sequence, software trigger . . . . . 315
Figure 41. Continuous conversion of a sequence, software trigger. . . . . 315
Figure 42. Single conversions of a sequence, hardware trigger . . . . . 316
Figure 43. Continuous conversions of a sequence, hardware trigger . . . . . 316
Figure 44. Data alignment and resolution (oversampling disabled: OVSE = 0). . . . . 317
Figure 45. Example of overrun (OVR) . . . . . 318
Figure 46. Wait mode conversion (continuous mode, software trigger). . . . . 320
Figure 47. Behavior with WAIT = 0, AUTOFF = 1 . . . . . 321
| Figure 48. | Behavior with WAIT = 1, AUTOFF = 1 . . . . . | 322 |
| Figure 49. | Analog watchdog guarded area . . . . . | 323 |
| Figure 50. | ADC_AWD1_OUT signal generation . . . . . | 324 |
| Figure 51. | ADC_AWD1_OUT signal generation (AWD flag not cleared by software) . . . . . | 325 |
| Figure 52. | ADC1_AWD_OUT signal generation (on a single channel) . . . . . | 325 |
| Figure 53. | Analog watchdog threshold update . . . . . | 326 |
| Figure 54. | 20-bit to 16-bit result truncation . . . . . | 327 |
| Figure 55. | Numerical example with 5-bits shift and rounding . . . . . | 327 |
| Figure 56. | Triggered oversampling mode (TOVS bit = 1) . . . . . | 329 |
| Figure 57. | Temperature sensor and VREFINT channel block diagram . . . . . | 330 |
| Figure 58. | DAC block diagram . . . . . | 350 |
| Figure 59. | Data registers in single DAC channel mode . . . . . | 351 |
| Figure 60. | Timing diagram for conversion with trigger disabled TEN = 0 . . . . . | 352 |
| Figure 61. | Data registers in dual DAC channel mode . . . . . | 354 |
| Figure 62. | DAC LFSR register calculation algorithm . . . . . | 358 |
| Figure 63. | DAC conversion (SW trigger enabled) with LFSR wave generation . . . . . | 359 |
| Figure 64. | DAC triangle wave generation . . . . . | 359 |
| Figure 65. | DAC conversion (SW trigger enabled) with triangle wave generation . . . . . | 360 |
| Figure 66. | Comparator 1 and 2 block diagrams . . . . . | 374 |
| Figure 67. | TSC block diagram . . . . . | 381 |
| Figure 68. | Surface charge transfer analog I/O group structure . . . . . | 382 |
| Figure 69. | Sampling capacitor voltage variation . . . . . | 383 |
| Figure 70. | Charge transfer acquisition sequence . . . . . | 384 |
| Figure 71. | Spread spectrum variation principle . . . . . | 385 |
| Figure 72. | AES block diagram . . . . . | 400 |
| Figure 73. | ECB encryption and decryption principle . . . . . | 402 |
| Figure 74. | CBC encryption and decryption principle . . . . . | 403 |
| Figure 75. | CTR encryption and decryption principle . . . . . | 404 |
| Figure 76. | STM32 cryptolib AES flowchart example . . . . . | 405 |
| Figure 77. | Encryption key derivation for ECB/CBC decryption (Mode 2). . . . . | 408 |
| Figure 78. | Example of suspend mode management . . . . . | 409 |
| Figure 79. | ECB encryption . . . . . | 409 |
| Figure 80. | ECB decryption . . . . . | 410 |
| Figure 81. | CBC encryption . . . . . | 410 |
| Figure 82. | CBC decryption . . . . . | 411 |
| Figure 83. | ECB/CBC encryption (Mode 1) . . . . . | 412 |
| Figure 84. | ECB/CBC decryption (Mode 3) . . . . . | 413 |
| Figure 85. | Message construction in CTR mode . . . . . | 415 |
| Figure 86. | CTR encryption . . . . . | 415 |
| Figure 87. | CTR decryption . . . . . | 416 |
| Figure 88. | 128-bit block construction with respect to data swap . . . . . | 418 |
| Figure 89. | DMA transfer of a 128-bit data block during input phase . . . . . | 420 |
| Figure 90. | DMA transfer of a 128-bit data block during output phase . . . . . | 421 |
| Figure 91. | AES interrupt signal generation . . . . . | 423 |
| Figure 92. | RNG block diagram . . . . . | 434 |
| Figure 93. | Entropy source model . . . . . | 435 |
| Figure 94. | General-purpose timer block diagram . . . . . | 445 |
| Figure 95. | Counter timing diagram with prescaler division change from 1 to 2 . . . . . | 447 |
| Figure 96. | Counter timing diagram with prescaler division change from 1 to 4 . . . . . | 447 |
| Figure 97. | Counter timing diagram, internal clock divided by 1 . . . . . | 448 |
| Figure 98. | Counter timing diagram, internal clock divided by 2 . . . . . | 449 |
| Figure 99. | Counter timing diagram, internal clock divided by 4 . . . . . | 449 |
| Figure 100. Counter timing diagram, internal clock divided by N . . . . . | 450 |
| Figure 101. Counter timing diagram, Update event when ARPE=0 (TIMx_ARR not preloaded). . . . . | 450 |
| Figure 102. Counter timing diagram, Update event when ARPE=1 (TIMx_ARR preloaded). . . . . | 451 |
| Figure 103. Counter timing diagram, internal clock divided by 1 . . . . . | 452 |
| Figure 104. Counter timing diagram, internal clock divided by 2 . . . . . | 452 |
| Figure 105. Counter timing diagram, internal clock divided by 4 . . . . . | 453 |
| Figure 106. Counter timing diagram, internal clock divided by N . . . . . | 453 |
| Figure 107. Counter timing diagram, Update event when repetition counter is not used . . . . . | 454 |
| Figure 108. Counter timing diagram, internal clock divided by 1, TIMx_ARR=0x6 . . . . . | 455 |
| Figure 109. Counter timing diagram, internal clock divided by 2 . . . . . | 456 |
| Figure 110. Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 . . . . . | 456 |
| Figure 111. Counter timing diagram, internal clock divided by N . . . . . | 457 |
| Figure 112. Counter timing diagram, Update event with ARPE=1 (counter underflow). . . . . | 457 |
| Figure 113. Counter timing diagram, Update event with ARPE=1 (counter overflow). . . . . | 458 |
| Figure 114. Control circuit in normal mode, internal clock divided by 1 . . . . . | 459 |
| Figure 115. TI2 external clock connection example. . . . . | 459 |
| Figure 116. Control circuit in external clock mode 1 . . . . . | 460 |
| Figure 117. External trigger input block . . . . . | 461 |
| Figure 118. Control circuit in external clock mode 2 . . . . . | 462 |
| Figure 119. Capture/compare channel (example: channel 1 input stage). . . . . | 463 |
| Figure 120. Capture/compare channel 1 main circuit . . . . . | 463 |
| Figure 121. Output stage of capture/compare channel (channel 1). . . . . | 464 |
| Figure 122. PWM input mode timing . . . . . | 466 |
| Figure 123. Output compare mode, toggle on OC1. . . . . | 468 |
| Figure 124. Edge-aligned PWM waveforms (ARR=8). . . . . | 469 |
| Figure 125. Center-aligned PWM waveforms (ARR=8). . . . . | 471 |
| Figure 126. Example of one-pulse mode. . . . . | 472 |
| Figure 127. Clearing TIMx_OCxREF . . . . . | 474 |
| Figure 128. Example of counter operation in encoder interface mode . . . . . | 476 |
| Figure 129. Example of encoder interface mode with TI1FP1 polarity inverted . . . . . | 476 |
| Figure 130. Control circuit in reset mode . . . . . | 477 |
| Figure 131. Control circuit in gated mode . . . . . | 478 |
| Figure 132. Control circuit in trigger mode . . . . . | 479 |
| Figure 133. Control circuit in external clock mode 2 + trigger mode . . . . . | 481 |
| Figure 134. Master/Slave timer example . . . . . | 481 |
| Figure 135. Gating timer y with OC1REF of timer x. . . . . | 483 |
| Figure 136. Gating timer y with Enable of timer x . . . . . | 484 |
| Figure 137. Triggering timer y with update of timer x. . . . . | 485 |
| Figure 138. Triggering timer y with Enable of timer x . . . . . | 485 |
| Figure 139. Triggering timer x and y with timer x TI1 input . . . . . | 486 |
| Figure 140. General-purpose timer block diagram (TIM21/22) . . . . . | 513 |
| Figure 141. Counter timing diagram with prescaler division change from 1 to 2 . . . . . | 515 |
| Figure 142. Counter timing diagram with prescaler division change from 1 to 4 . . . . . | 516 |
| Figure 143. Counter timing diagram, internal clock divided by 1 . . . . . | 517 |
| Figure 144. Counter timing diagram, internal clock divided by 2 . . . . . | 518 |
| Figure 145. Counter timing diagram, internal clock divided by 4 . . . . . | 518 |
| Figure 146. Counter timing diagram, internal clock divided by N. . . . . | 519 |
| Figure 147. Counter timing diagram, update event when ARPE=0 (TIMx_ARR not preloaded). . . . . | 519 |
| Figure 148. Counter timing diagram, update event when ARPE=1 (TIMx_ARR preloaded). . . . . | 520 |
| Figure 149. Counter timing diagram, internal clock divided by 1 . . . . . | 521 |
| Figure 150. Counter timing diagram, internal clock divided by 2 . . . . . | 521 |
| Figure 151. Counter timing diagram, internal clock divided by 4 . . . . . | 522 |
| Figure 152. Counter timing diagram, internal clock divided by N . . . . . | 522 |
| Figure 153. Counter timing diagram, internal clock divided by 1, TIMx_ARR=0x6 . . . . . | 524 |
| Figure 154. Counter timing diagram, internal clock divided by 2 . . . . . | 524 |
| Figure 155. Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 . . . . . | 525 |
| Figure 156. Counter timing diagram, internal clock divided by N . . . . . | 525 |
| Figure 157. Counter timing diagram, Update event with ARPE=1 (counter underflow) . . . . . | 526 |
| Figure 158. Counter timing diagram, Update event with ARPE=1 (counter overflow) . . . . . | 526 |
| Figure 159. Control circuit in normal mode, internal clock divided by 1 . . . . . | 527 |
| Figure 160. TI2 external clock connection example . . . . . | 528 |
| Figure 161. Control circuit in external clock mode 1 . . . . . | 529 |
| Figure 162. External trigger input block . . . . . | 529 |
| Figure 163. Control circuit in external clock mode 2 . . . . . | 530 |
| Figure 164. Capture/compare channel (example: channel 1 input stage) . . . . . | 531 |
| Figure 165. Capture/compare channel 1 main circuit . . . . . | 531 |
| Figure 166. Output stage of capture/compare channel (channel 1 and 2) . . . . . | 532 |
| Figure 167. PWM input mode timing . . . . . | 534 |
| Figure 168. Output compare mode, toggle on OC1 . . . . . | 536 |
| Figure 169. Edge-aligned PWM waveforms (ARR=8) . . . . . | 537 |
| Figure 170. Center-aligned PWM waveforms (ARR=8) . . . . . | 538 |
| Figure 171. Clearing TIMx_OCxREF . . . . . | 540 |
| Figure 172. Example of one pulse mode . . . . . | 541 |
| Figure 173. Example of counter operation in encoder interface mode . . . . . | 543 |
| Figure 174. Example of encoder interface mode with TI1FP1 polarity inverted . . . . . | 544 |
| Figure 175. Control circuit in reset mode . . . . . | 545 |
| Figure 176. Control circuit in gated mode . . . . . | 546 |
| Figure 177. Control circuit in trigger mode . . . . . | 547 |
| Figure 178. Basic timer block diagram . . . . . | 567 |
| Figure 179. Counter timing diagram with prescaler division change from 1 to 2 . . . . . | 569 |
| Figure 180. Counter timing diagram with prescaler division change from 1 to 4 . . . . . | 569 |
| Figure 181. Counter timing diagram, internal clock divided by 1 . . . . . | 570 |
| Figure 182. Counter timing diagram, internal clock divided by 2 . . . . . | 571 |
| Figure 183. Counter timing diagram, internal clock divided by 4 . . . . . | 571 |
| Figure 184. Counter timing diagram, internal clock divided by N . . . . . | 572 |
| Figure 185. Counter timing diagram, update event when ARPE = 0 (TIMx_ARR not preloaded) . . . . . | 572 |
| Figure 186. Counter timing diagram, update event when ARPE=1 (TIMx_ARR preloaded) . . . . . | 573 |
| Figure 187. Control circuit in normal mode, internal clock divided by 1 . . . . . | 574 |
| Figure 188. Low-power timer block diagram . . . . . | 581 |
| Figure 189. Glitch filter timing diagram . . . . . | 583 |
| Figure 190. LPTIM output waveform, single counting mode configuration . . . . . | 585 |
| Figure 191. LPTIM output waveform, Single counting mode configuration and Set-once mode activated (WAVE bit is set) . . . . . | 585 |
| Figure 192. LPTIM output waveform, Continuous counting mode configuration . . . . . | 586 |
| Figure 193. Waveform generation . . . . . | 587 |
| Figure 194. Encoder mode counting sequence . . . . . | 590 |
| Figure 195. Independent watchdog block diagram . . . . . | 601 |
| Figure 196. Watchdog block diagram . . . . . | 611 |
| Figure 197. Window watchdog timing diagram . . . . . | 612 |
| Figure 198. RTC block diagram . . . . . | 618 |
| Figure 199. I2C1/3 block diagram . . . . . | 662 |
| Figure 200. I2C2 block diagram . . . . . | 663 |
| Figure 201. I2C bus protocol . . . . . | 665 |
| Figure 202. Setup and hold timings . . . . . | 667 |
| Figure 203. I2C initialization flow . . . . . | 670 |
| Figure 204. Data reception . . . . . | 671 |
| Figure 205. Data transmission . . . . . | 672 |
| Figure 206. Slave initialization flow . . . . . | 675 |
| Figure 207. Transfer sequence flow for I2C slave transmitter, NOSTRETCH = 0 . . . . . | 677 |
| Figure 208. Transfer sequence flow for I2C slave transmitter, NOSTRETCH = 1 . . . . . | 678 |
| Figure 209. Transfer bus diagrams for I2C slave transmitter . . . . . | 679 |
| Figure 210. Transfer sequence flow for slave receiver with NOSTRETCH = 0 . . . . . | 680 |
| Figure 211. Transfer sequence flow for slave receiver with NOSTRETCH = 1 . . . . . | 681 |
| Figure 212. Transfer bus diagrams for I2C slave receiver . . . . . | 681 |
| Figure 213. Master clock generation . . . . . | 683 |
| Figure 214. Master initialization flow . . . . . | 685 |
| Figure 215. 10-bit address read access with HEAD10R = 0 . . . . . | 685 |
| Figure 216. 10-bit address read access with HEAD10R = 1 . . . . . | 686 |
| Figure 217. Transfer sequence flow for I2C master transmitter for N≤255 bytes . . . . . | 687 |
| Figure 218. Transfer sequence flow for I2C master transmitter for N>255 bytes . . . . . | 688 |
| Figure 219. Transfer bus diagrams for I2C master transmitter . . . . . | 689 |
| Figure 220. Transfer sequence flow for I2C master receiver for N≤255 bytes . . . . . | 691 |
| Figure 221. Transfer sequence flow for I2C master receiver for N >255 bytes . . . . . | 692 |
| Figure 222. Transfer bus diagrams for I2C master receiver . . . . . | 693 |
| Figure 223. Timeout intervals for \( t_{LOW:SEXT} \) , \( t_{LOW:MEXT} \) . . . . . | 697 |
| Figure 224. Transfer sequence flow for SMBus slave transmitter N bytes + PEC . . . . . | 701 |
| Figure 225. Transfer bus diagrams for SMBus slave transmitter (SBC=1) . . . . . | 702 |
| Figure 226. Transfer sequence flow for SMBus slave receiver N Bytes + PEC . . . . . | 703 |
| Figure 227. Bus transfer diagrams for SMBus slave receiver (SBC=1) . . . . . | 704 |
| Figure 228. Bus transfer diagrams for SMBus master transmitter . . . . . | 705 |
| Figure 229. Bus transfer diagrams for SMBus master receiver . . . . . | 707 |
| Figure 230. USART block diagram . . . . . | 733 |
| Figure 231. Word length programming . . . . . | 735 |
| Figure 232. Configurable stop bits . . . . . | 737 |
| Figure 233. TC/TXE behavior when transmitting . . . . . | 738 |
| Figure 234. Start bit detection when oversampling by 16 or 8 . . . . . | 739 |
| Figure 235. Data sampling when oversampling by 16 . . . . . | 742 |
| Figure 236. Data sampling when oversampling by 8 . . . . . | 743 |
| Figure 237. Mute mode using Idle line detection . . . . . | 750 |
| Figure 238. Mute mode using address mark detection . . . . . | 751 |
| Figure 239. Break detection in LIN mode (11-bit break length - LBDL bit is set) . . . . . | 754 |
| Figure 240. Break detection in LIN mode vs. Framing error detection. . . . . | 755 |
| Figure 241. USART example of synchronous transmission. . . . . | 756 |
| Figure 242. USART data clock timing diagram (M bits = 00) . . . . . | 756 |
| Figure 243. USART data clock timing diagram (M bits = 01) . . . . . | 757 |
| Figure 244. RX data setup/hold time . . . . . | 757 |
| Figure 245. ISO 7816-3 asynchronous protocol . . . . . | 759 |
| Figure 246. Parity error detection using the 1.5 stop bits . . . . . | 760 |
| Figure 247. IrDA SIR ENDEC- block diagram . . . . . | 764 |
| Figure 248. IrDA data modulation (3/16) -Normal Mode . . . . . | 765 |
| Figure 249. Transmission using DMA . . . . . | 766 |
| Figure 250. Reception using DMA . . . . . | 767 |
| Figure 251. Hardware flow control between 2 USARTs . . . . . | 767 |
| Figure 252. RS232 RTS flow control . . . . . | 768 |
| Figure 253. RS232 CTS flow control . . . . . | 769 |
| Figure 254. USART interrupt mapping diagram . . . . . | 772 |
| Figure 255. LPUART block diagram . . . . . | 799 |
| Figure 256. Word length programming . . . . . | 801 |
| Figure 257. Configurable stop bits . . . . . | 802 |
| Figure 258. TC/TXE behavior when transmitting . . . . . | 804 |
| Figure 259. Mute mode using Idle line detection . . . . . | 811 |
| Figure 260. Mute mode using address mark detection . . . . . | 812 |
| Figure 261. Transmission using DMA . . . . . | 815 |
| Figure 262. Reception using DMA . . . . . | 816 |
| Figure 263. Hardware flow control between 2 LPUARTs . . . . . | 816 |
| Figure 264. RS232 RTS flow control . . . . . | 817 |
| Figure 265. RS232 CTS flow control . . . . . | 818 |
| Figure 266. LPUART interrupt mapping diagram . . . . . | 822 |
| Figure 267. SPI block diagram. . . . . | 840 |
| Figure 268. Full-duplex single master/ single slave application. . . . . | 841 |
| Figure 269. Half-duplex single master/ single slave application . . . . . | 842 |
| Figure 270. Simplex single master/single slave application (master in transmit-only/ slave in receive-only mode) . . . . . | 843 |
| Figure 271. Master and three independent slaves. . . . . | 844 |
| Figure 272. Multi-master application . . . . . | 845 |
| Figure 273. Hardware/software slave select management . . . . . | 846 |
| Figure 274. Data clock timing diagram . . . . . | 848 |
| Figure 275. TXE/RXNE/BSY behavior in master / full-duplex mode (BIDIMODE=0, RXONLY=0) in the case of continuous transfers . . . . . | 851 |
| Figure 276. TXE/RXNE/BSY behavior in slave / full-duplex mode (BIDIMODE=0, RXONLY=0) in the case of continuous transfers . . . . . | 852 |
| Figure 277. Transmission using DMA . . . . . | 854 |
| Figure 278. Reception using DMA . . . . . | 855 |
| Figure 279. TI mode transfer . . . . . | 858 |
| Figure 280. I 2 S block diagram . . . . . | 861 |
| Figure 281. Full-duplex communication. . . . . | 863 |
| Figure 282. I 2 S Philips protocol waveforms (16/32-bit full accuracy, CPOL = 0). . . . . | 864 |
| Figure 283. I 2 S Philips standard waveforms (24-bit frame with CPOL = 0). . . . . | 864 |
| Figure 284. Transmitting 0x8EAA33 . . . . . | 865 |
| Figure 285. Receiving 0x8EAA33 . . . . . | 865 |
| Figure 286. I 2 S Philips standard (16-bit extended to 32-bit packet frame with CPOL = 0) . . . . . | 865 |
| Figure 287. Example of 16-bit data frame extended to 32-bit channel frame . . . . . | 866 |
| Figure 288. MSB Justified 16-bit or 32-bit full-accuracy length with CPOL = 0 . . . . . | 866 |
| Figure 289. MSB justified 24-bit frame length with CPOL = 0 . . . . . | 866 |
| Figure 290. MSB justified 16-bit extended to 32-bit packet frame with CPOL = 0 . . . . . | 867 |
| Figure 291. LSB justified 16-bit or 32-bit full-accuracy with CPOL = 0 . . . . . | 867 |
| Figure 292. LSB justified 24-bit frame length with CPOL = 0 . . . . . | 867 |
| Figure 293. Operations required to transmit 0x3478AE. . . . . | 868 |
| Figure 294. Operations required to receive 0x3478AE . . . . . | 868 |
| Figure 295. LSB justified 16-bit extended to 32-bit packet frame with CPOL = 0 . . . . . | 868 |
| Figure 296. Example of 16-bit data frame extended to 32-bit channel frame . . . . . | 869 |
| Figure 297. PCM standard waveforms (16-bit) . . . . . | 869 |
| Figure 298. PCM standard waveforms (16-bit extended to 32-bit packet frame). . . . . | 869 |
| Figure 299. Audio sampling frequency definition . . . . . | 870 |
| Figure 300. I 2 S clock generator architecture . . . . . | 870 |
| Figure 301. USB peripheral block diagram . . . . . | 889 |
| Figure 302. Packet buffer areas with examples of buffer description table locations . . . . . | 893 |
| Figure 303. Block diagram of STM32L0x2 MCU and Cortex ® -M0+-level debug support . . . . . | 921 |
Chapters
- 1. Documentation conventions
- 2. System and memory overview
- 3. Flash program memory and data EEPROM (FLASH)
- 4. Cyclic redundancy check calculation unit (CRC)
- 5. Firewall (FW)
- 6. Power control (PWR)
- 7. Reset and clock control (RCC)
- 8. Clock recovery system (CRS)
- 9. General-purpose I/Os (GPIO)
- 10. System configuration controller (SYSCFG)
- 11. Direct memory access controller (DMA)
- 12. Nested vectored interrupt controller (NVIC)
- 13. Extended interrupt and event controller (EXTI)
- 14. Analog-to-digital converter (ADC)
- 15. Digital-to-analog converter (DAC)
- 16. Comparator (COMP)
- 17. Touch sensing controller (TSC)
- 18. AES hardware accelerator (AES)
- 19. True random number generator (RNG)
- 20. General-purpose timers (TIM2/TIM3)
- 21. General-purpose timers (TIM21/22)
- 22. Basic timers (TIM6/7)
- 23. Low-power timer (LPTIM)
- 24. Independent watchdog (IWDG)
- 25. System window watchdog (WWDG)
- 26. Real-time clock (RTC)
- 27. Inter-integrated circuit (I2C) interface
- 28. Universal synchronous/asynchronous receiver transmitter (USART/UART)
- 29. Low-power universal asynchronous receiver transmitter (LPUART)
- 30. Serial peripheral interface/ inter-IC sound (SPI/I2S)
- 31. Universal serial bus full-speed device interface (USB)
- 32. Debug support (DBG)
- 33. Device electronic signature
- Index