RM0451-STM32L0x0

Introduction

This reference manual targets application developers. It provides complete information on how to use the STM32L0x0 microcontroller memory and peripherals.

The STM32L0x0 is a line of microcontrollers with different memory sizes, packages and peripherals. It includes STM32L010xx part numbers.

For ordering information, mechanical, and electrical device characteristics please refer to the corresponding datasheets.

For information on the Arm ® Cortex ® -M0+ core, please refer to the Cortex ® -M0+ Technical Reference Manual .

The STM32L0x0 microcontrollers include state-of-the-art patented technology.

Contents

3.6Memory interface management . . . . .79
3.6.1Operation priority and evolution . . . . .79
3.6.2Sequence of operations . . . . .80
3.6.3Change the number of wait states while reading . . . . .81
3.6.4Power-down . . . . .81
3.7Flash register description . . . . .82
3.7.1Access control register (FLASH_ACR) . . . . .83
3.7.2Program and erase control register (FLASH_PECR) . . . . .84
3.7.3Power-down key register (FLASH_PDKEYR) . . . . .87
3.7.4PECR unlock key register (FLASH_PEKEYR) . . . . .87
3.7.5Program and erase key register (FLASH_PRGKEYR) . . . . .87
3.7.6Option bytes unlock key register (FLASH_OPTKEYR) . . . . .88
3.7.7Status register (FLASH_SR) . . . . .89
3.7.8Option bytes register (FLASH_OPTR) . . . . .91
3.7.9Write protection register 1 (FLASH_WRPROT1) . . . . .93
3.7.10Write protection register 2 (FLASH_WRPROT2) . . . . .94
3.7.11Flash register map . . . . .95
3.8Option bytes . . . . .96
3.8.1Option bytes description . . . . .96
3.8.2Mismatch when loading protection flags . . . . .97
3.8.3Reloading Option bytes by software . . . . .97
4Cyclic redundancy check calculation unit (CRC) . . . . .98
4.1Introduction . . . . .98
4.2CRC main features . . . . .98
4.3CRC functional description . . . . .99
4.3.1CRC block diagram . . . . .99
4.3.2CRC internal signals . . . . .99
4.3.3CRC operation . . . . .99
4.4CRC registers . . . . .101
4.4.1CRC data register (CRC_DR) . . . . .101
4.4.2CRC independent data register (CRC_IDR) . . . . .101
4.4.3CRC control register (CRC_CR) . . . . .102
4.4.4CRC initial value (CRC_INIT) . . . . .103
4.4.5CRC polynomial (CRC_POL) . . . . .103
4.4.6CRC register map . . . . .104
5Firewall (FW) . . . . .105
5.1Introduction . . . . .105
5.2Firewall main features . . . . .105
5.3Firewall functional description . . . . .106
5.3.1Firewall AMBA bus snoop . . . . .106
5.3.2Functional requirements . . . . .106
5.3.3Firewall segments . . . . .107
5.3.4Segment accesses and properties . . . . .108
5.3.5Firewall initialization . . . . .109
5.3.6Firewall states . . . . .110
5.4Firewall registers . . . . .112
5.4.1Code segment start address (FW_CSSA) . . . . .112
5.4.2Code segment length (FW_CSL) . . . . .112
5.4.3Non-volatile data segment start address (FW_NVDSSA) . . . . .113
5.4.4Non-volatile data segment length (FW_NVDLSL) . . . . .113
5.4.5Volatile data segment start address (FW_VDSSA) . . . . .114
5.4.6Volatile data segment length (FW_VDSL) . . . . .114
5.4.7Configuration register (FW_CR) . . . . .115
5.4.8Firewall register map . . . . .116
6Power control (PWR) . . . . .117
6.1Power supplies . . . . .117
6.1.1Independent A/D converter supply . . . . .118
6.1.2RTC and RTC backup registers . . . . .118
6.1.3Voltage regulator . . . . .118
6.1.4Dynamic voltage scaling management . . . . .119
6.1.5Dynamic voltage scaling configuration . . . . .120
6.1.6Voltage regulator and clock management when modifying the
VCORE range . . . . .
120
6.1.7Voltage range and limitations when VDD ranges from 1.8 V to 2.0 V . . . . .121
6.2Power supply supervisor . . . . .121
6.2.1Power-on reset (POR)/power-down reset (PDR) . . . . .122
6.2.2Brownout reset (BOR) . . . . .123
6.2.3Internal voltage reference (VREFINT) . . . . .124
6.3Low-power modes . . . . .125
6.3.1Behavior of clocks in low-power modes . . . . .126
6.3.2Slowing down system clocks . . . . .127
6.3.3Peripheral clock gating . . . . .127
6.3.4Low-power run mode (LP run) . . . . .127
6.3.5Entering low-power mode . . . . .128
6.3.6Exiting low-power mode . . . . .128
6.3.7Sleep mode . . . . .129
6.3.8Low-power sleep mode (LP sleep) . . . . .130
6.3.9Stop mode . . . . .132
6.3.10Standby mode . . . . .135
6.3.11Waking up the device from Stop and Standby modes using the RTC . . . . .136
6.4Power control registers . . . . .138
6.4.1PWR power control register (PWR_CR) . . . . .138
6.4.2PWR power control/status register (PWR_CSR) . . . . .141
6.4.3PWR register map . . . . .143
7Reset and clock control (RCC) . . . . .144
7.1Reset . . . . .144
7.1.1System reset . . . . .144
7.1.2Power reset . . . . .145
7.1.3RTC and backup registers reset . . . . .145
7.2Clocks . . . . .146
7.2.1HSE clock . . . . .149
7.2.2HSI16 clock . . . . .151
7.2.3MSI clock . . . . .151
7.2.4PLL . . . . .152
7.2.5LSE clock . . . . .153
7.2.6LSI clock . . . . .153
7.2.7System clock (SYSCLK) selection . . . . .154
7.2.8System clock source frequency versus voltage range . . . . .154
7.2.9HSE clock security system (CSS) . . . . .154
7.2.10LSE Clock Security System . . . . .155
7.2.11RTC clock . . . . .155
7.2.12Watchdog clock . . . . .156
7.2.13Clock-out capability . . . . .156
7.2.14Internal/external clock measurement using TIM21 . . . . .156
7.2.15Clock-independent system clock sources for TIM2/TIM21/TIM22 . . . . .157
7.3RCC registers . . . . .158
7.3.1Clock control register (RCC_CR) . . . . .158
7.3.2Internal clock sources calibration register (RCC_ICSCR) . . . . .161
7.3.3Clock configuration register (RCC_CFGR) . . . . .162
7.3.4Clock interrupt enable register (RCC_CIER) . . . . .164
7.3.5Clock interrupt flag register (RCC_CIFR) . . . . .166
7.3.6Clock interrupt clear register (RCC_CICR) . . . . .167
7.3.7GPIO reset register (RCC_IOPRSTR) . . . . .168
7.3.8AHB peripheral reset register (RCC_AHBRSTR) . . . . .169
7.3.9APB2 peripheral reset register (RCC_APB2RSTR) . . . . .170
7.3.10APB1 peripheral reset register (RCC_APB1RSTR) . . . . .171
7.3.11GPIO clock enable register (RCC_IOPENR) . . . . .172
7.3.12AHB peripheral clock enable register (RCC_AHBENR) . . . . .174
7.3.13APB2 peripheral clock enable register (RCC_APB2ENR) . . . . .175
7.3.14APB1 peripheral clock enable register (RCC_APB1ENR) . . . . .177
7.3.15GPIO clock enable in Sleep mode register (RCC_IOPSMENR) . . . . .179
7.3.16AHB peripheral clock enable in Sleep mode register (RCC_AHBSMENR) . . . . .180
7.3.17APB2 peripheral clock enable in Sleep mode register (RCC_APB2SMENR) . . . . .181
7.3.18APB1 peripheral clock enable in Sleep mode register (RCC_APB1SMENR) . . . . .182
7.3.19Clock configuration register (RCC_CCIPR) . . . . .183
7.3.20Control/status register (RCC_CSR) . . . . .184
7.3.21RCC register map . . . . .188
8General-purpose I/Os (GPIO) . . . . .191
8.1Introduction . . . . .191
8.2GPIO main features . . . . .191
8.3GPIO functional description . . . . .191
8.3.1General-purpose I/O (GPIO) . . . . .193
8.3.2I/O pin alternate function multiplexer and mapping . . . . .194
8.3.3I/O port control registers . . . . .195
8.3.4I/O port data registers . . . . .195
8.3.5I/O data bitwise handling . . . . .195
8.3.6GPIO locking mechanism . . . . .195
8.3.7I/O alternate function input/output . . . . .196
8.3.8External interrupt/wakeup lines . . . . .196
8.3.9Input configuration . . . . .196
8.3.10Output configuration . . . . .197
8.3.11Alternate function configuration . . . . .198
8.3.12Analog configuration . . . . .199
8.3.13Using the HSE or LSE oscillator pins as GPIOs . . . . .199
8.3.14Using the GPIO pins in the RTC supply domain . . . . .199
8.3.15BOOT0/GPIO pin sharing . . . . .200
8.4GPIO registers . . . . .200
8.4.1GPIO port mode register (GPIOx_MODER)
(x =A to E and H) . . . . .
200
8.4.2GPIO port output type register (GPIOx_OTYPER)
(x = A to E and H) . . . . .
200
8.4.3GPIO port output speed register (GPIOx_OSPEEDR)
(x = A to E and H) . . . . .
201
8.4.4GPIO port pull-up/pull-down register (GPIOx_PUPDR)
(x = A to E and H) . . . . .
201
8.4.5GPIO port input data register (GPIOx_IDR)
(x = A to E and H) . . . . .
202
8.4.6GPIO port output data register (GPIOx_ODR)
(x = A to E and H) . . . . .
202
8.4.7GPIO port bit set/reset register (GPIOx_BSRR)
(x = A to E and H) . . . . .
203
8.4.8GPIO port configuration lock register (GPIOx_LCKR)
(x = A to E and H) . . . . .
203
8.4.9GPIO alternate function low register (GPIOx_AFRL)
(x = A to E and H) . . . . .
204
8.4.10GPIO alternate function high register (GPIOx_AFRH)
(x = A to E and H) . . . . .
205
8.4.11GPIO port bit reset register (GPIOx_BRR) (x = A to E and H) . . . . .205
8.4.12GPIO register map . . . . .206
9System configuration controller (SYSCFG) . . . . .208
9.1Introduction . . . . .208
9.2SYSCFG registers . . . . .209
9.2.1SYSCFG memory remap register (SYSCFG_CFGR1) . . . . .209
9.2.2SYSCFG peripheral mode configuration register (SYSCFG_CFGR2) . . . . .210
9.2.3Reference control and status register (SYSCFG_CFGR3) . . . . .210
9.2.4SYSCFG external interrupt configuration register 1
(SYSCFG_EXTICR1) . . . . .
211
9.2.5SYSCFG external interrupt configuration register 2
(SYSCFG_EXTICR2) . . . . .
213
12.2EXTI main features . . . . .242
12.3EXTI functional description . . . . .242
12.3.1EXTI block diagram . . . . .243
12.3.2Wakeup event management . . . . .243
12.3.3Peripherals asynchronous interrupts . . . . .244
12.3.4Hardware interrupt selection . . . . .244
12.3.5Hardware event selection . . . . .244
12.3.6Software interrupt/event selection . . . . .244
12.4EXTI interrupt/event line mapping . . . . .245
12.5EXTI registers . . . . .247
12.5.1EXTI interrupt mask register (EXTI_IMR) . . . . .247
12.5.2EXTI event mask register (EXTI_EMR) . . . . .247
12.5.3EXTI rising edge trigger selection register (EXTI_RTSR) . . . . .248
12.5.4Falling edge trigger selection register (EXTI_FTSR) . . . . .249
12.5.5EXTI software interrupt event register (EXTI_SWIER) . . . . .249
12.5.6EXTI pending register (EXTI_PR) . . . . .250
12.5.7EXTI register map . . . . .251
13Analog-to-digital converter (ADC) . . . . .252
13.1Introduction . . . . .252
13.2ADC main features . . . . .253
13.3ADC functional description . . . . .254
13.3.1ADC pins and internal signals . . . . .254
13.3.2ADC voltage regulator (ADVREGEN) . . . . .255
13.3.3Calibration (ADCAL) . . . . .256
13.3.4ADC on-off control (ADEN, ADDIS, ADRDY) . . . . .258
13.3.5ADC clock (CKMODE, PRESC[3:0], LFMEN) . . . . .259
13.3.6ADC connectivity . . . . .261
13.3.7Configuring the ADC . . . . .262
13.3.8Channel selection (CHSEL, SCANDIR) . . . . .262
13.3.9Programmable sampling time (SMP) . . . . .262
13.3.10Single conversion mode (CONT = 0) . . . . .263
13.3.11Continuous conversion mode (CONT = 1) . . . . .263
13.3.12Starting conversions (ADSTART) . . . . .264
13.3.13Timings . . . . .265
13.3.14Stopping an ongoing conversion (ADSTP) . . . . .266
13.4Conversion on external trigger and trigger polarity (EXTSEL, EXTEN) .266
13.4.1Discontinuous mode (DISCEN) . . . . .267
13.4.2Programmable resolution (RES) - Fast conversion mode . . . . .267
13.4.3End of conversion, end of sampling phase (EOC, EOSMP flags) . . . . .268
13.4.4End of conversion sequence (EOS flag) . . . . .268
13.4.5Example timing diagrams (single/continuous modes
hardware/software triggers) . . . . .
269
13.5Data management . . . . .271
13.5.1Data register and data alignment (ADC_DR, ALIGN) . . . . .271
13.5.2ADC overrun (OVR, OVRMOD) . . . . .271
13.5.3Managing a sequence of data converted without using the DMA . . . . .272
13.5.4Managing converted data without using the DMA without overrun . . . . .272
13.5.5Managing converted data using the DMA . . . . .272
13.6Low-power features . . . . .274
13.6.1Wait mode conversion . . . . .274
13.6.2Auto-off mode (AUTOFF) . . . . .275
13.7Analog window watchdog (AWDEN, AWDSGL, AWDCH,
ADC_TR) . . . . .
276
13.7.1Description of the analog watchdog . . . . .276
13.7.2ADC_AWD1_OUT output signal generation . . . . .277
13.7.3Analog watchdog threshold control . . . . .279
13.8Oversampler . . . . .280
13.8.1ADC operating modes supported when oversampling . . . . .282
13.8.2Analog watchdog . . . . .282
13.8.3Triggered mode . . . . .282
13.9Internal reference voltage . . . . .283
13.10ADC interrupts . . . . .285
13.11ADC registers . . . . .286
13.11.1ADC interrupt and status register (ADC_ISR) . . . . .286
13.11.2ADC interrupt enable register (ADC_IER) . . . . .287
13.11.3ADC control register (ADC_CR) . . . . .289
13.11.4ADC configuration register 1 (ADC_CFGR1) . . . . .291
13.11.5ADC configuration register 2 (ADC_CFGR2) . . . . .295
13.11.6ADC sampling time register (ADC_SMPR) . . . . .296
13.11.7ADC watchdog threshold register (ADC_TR) . . . . .297
13.11.8ADC channel selection register (ADC_CHSELR) . . . . .297
13.11.9ADC data register (ADC_DR) . . . . .298
13.11.10ADC Calibration factor (ADC_CALFACT) . . . . .298
13.11.11ADC common configuration register (ADC_CCR) . . . . .299
13.12ADC register map . . . . .300
14General-purpose timer (TIM2) . . . . .302
14.1TIM2 introduction . . . . .302
14.2TIM2 main features . . . . .302
14.3TIM2 functional description . . . . .304
14.3.1Time-base unit . . . . .304
14.3.2Counter modes . . . . .306
14.3.3Clock selection . . . . .316
14.3.4Capture/compare channels . . . . .320
14.3.5Input capture mode . . . . .322
14.3.6PWM input mode . . . . .324
14.3.7Forced output mode . . . . .325
14.3.8Output compare mode . . . . .325
14.3.9PWM mode . . . . .326
14.3.10One-pulse mode . . . . .330
14.3.11Clearing the OCxREF signal on an external event . . . . .331
14.3.12Encoder interface mode . . . . .332
14.3.13Timer input XOR function . . . . .334
14.3.14Timers and external trigger synchronization . . . . .335
14.3.15Timer synchronization . . . . .339
14.3.16Debug mode . . . . .345
14.4TIM2 registers . . . . .346
14.4.1TIMx control register 1 (TIMx_CR1) . . . . .346
14.4.2TIMx control register 2 (TIMx_CR2) . . . . .348
14.4.3TIMx slave mode control register (TIMx_SMCR) . . . . .349
14.4.4TIMx DMA/Interrupt enable register (TIMx_DIER) . . . . .351
14.4.5TIMx status register (TIMx_SR) . . . . .352
14.4.6TIMx event generation register (TIMx_EGR) . . . . .354
14.4.7TIMx capture/compare mode register 1 (TIMx_CCMR1) . . . . .355
14.4.8TIMx capture/compare mode register 2 (TIMx_CCMR2) . . . . .358
14.4.9TIMx capture/compare enable register (TIMx_CCER) . . . . .359
14.4.10TIMx counter (TIMx_CNT) . . . . .361
14.4.11TIMx prescaler (TIMx_PSC) . . . . .361
14.4.12TIMx auto-reload register (TIMx_ARR) . . . . .361
14.4.13TIMx capture/compare register 1 (TIMx_CCR1) . . . . .362
14.4.14TIMx capture/compare register 2 (TIMx_CCR2) . . . . .362
14.4.15TIMx capture/compare register 3 (TIMx_CCR3) . . . . .363
14.4.16TIMx capture/compare register 4 (TIMx_CCR4) . . . . .363
14.4.17TIMx DMA control register (TIMx_DCR) . . . . .364
14.4.18TIMx DMA address for full transfer (TIMx_DMAR) . . . . .364
14.4.19TIM2 option register (TIM2_OR) . . . . .366
14.5TIMx register map . . . . .367
15General-purpose timers (TIM21/22) . . . . .369
15.1Introduction . . . . .369
15.2TIM21/22 main features . . . . .369
15.2.1TIM21/22 main features . . . . .369
15.3TIM21/22 functional description . . . . .371
15.3.1Timebase unit . . . . .371
15.3.2Counter modes . . . . .373
15.3.3Clock selection . . . . .384
15.3.4Capture/compare channels . . . . .387
15.3.5Input capture mode . . . . .389
15.3.6PWM input mode . . . . .391
15.3.7Forced output mode . . . . .392
15.3.8Output compare mode . . . . .392
15.3.9PWM mode . . . . .393
15.3.10Clearing the OCxREF signal on an external event . . . . .396
15.3.11One-pulse mode . . . . .397
15.3.12Encoder interface mode . . . . .399
15.3.13TIM21/22 external trigger synchronization . . . . .401
15.3.14Timer synchronization (TIM21/22) . . . . .404
15.3.15Debug mode . . . . .404
15.4TIM21/22 registers . . . . .405
15.4.1TIM21/22 control register 1 (TIMx_CR1) . . . . .405
15.4.2TIM21/22 control register 2 (TIMx_CR2) . . . . .407
15.4.3TIM21/22 slave mode control register (TIMx_SMCR) . . . . .408
15.4.4TIM21/22 Interrupt enable register (TIMx_DIER) . . . . .410
15.4.5TIM21/22 status register (TIMx_SR) . . . . .411
15.4.6TIM21/22 event generation register (TIMx_EGR) . . . . .413
15.4.7TIM21/22 capture/compare mode register 1 (TIMx_CCMR1) . . . . .414
15.4.8TIM21/22 capture/compare enable register (TIMx_CCER) . . . . .417
15.4.9TIM21/22 counter (TIMx_CNT) . . . . .418
15.4.10TIM21/22 prescaler (TIMx_PSC) . . . . .418
15.4.11TIM21/22 auto-reload register (TIMx_ARR) . . . . .418
15.4.12TIM21/22 capture/compare register 1 (TIMx_CCR1) . . . . .419
15.4.13TIM21/22 capture/compare register 2 (TIMx_CCR2) . . . . .419
15.4.14TIM21 option register (TIM21_OR) . . . . .420
15.4.15TIM22 option register (TIM22_OR) . . . . .421
15.4.16TIM21/22 register map . . . . .422
16Low-power timer (LPTIM) . . . . .424
16.1Introduction . . . . .424
16.2LPTIM main features . . . . .424
16.3LPTIM implementation . . . . .425
16.4LPTIM functional description . . . . .425
16.4.1LPTIM block diagram . . . . .425
16.4.2LPTIM trigger mapping . . . . .426
16.4.3LPTIM reset and clocks . . . . .426
16.4.4Glitch filter . . . . .426
16.4.5Prescaler . . . . .427
16.4.6Trigger multiplexer . . . . .428
16.4.7Operating mode . . . . .428
16.4.8Timeout function . . . . .430
16.4.9Waveform generation . . . . .430
16.4.10Register update . . . . .431
16.4.11Counter mode . . . . .432
16.4.12Timer enable . . . . .433
16.4.13Encoder mode . . . . .433
16.4.14Debug mode . . . . .434
16.5LPTIM low-power modes . . . . .434
16.6LPTIM interrupts . . . . .435
16.7LPTIM registers . . . . .435
16.7.1LPTIM interrupt and status register (LPTIM_ISR) . . . . .436
16.7.2LPTIM interrupt clear register (LPTIM_ICR) . . . . .437
16.7.3LPTIM interrupt enable register (LPTIM_IER) . . . . .437
16.7.4LPTIM configuration register (LPTIM_CFGR) . . . . .438
16.7.5LPTIM control register (LPTIM_CR) . . . . .441
16.7.6LPTIM compare register (LPTIM_CMP) . . . . .442
16.7.7LPTIM autoreload register (LPTIM_ARR) . . . . .443
16.7.8LPTIM counter register (LPTIM_CNT) . . . . .443
16.7.9LPTIM register map . . . . .444
17Independent watchdog (IWDG) . . . . .445
17.1Introduction . . . . .445
17.2IWDG main features . . . . .445
17.3IWDG functional description . . . . .445
17.3.1IWDG block diagram . . . . .445
17.3.2Window option . . . . .446
17.3.3Hardware watchdog . . . . .447
17.3.4Register access protection . . . . .447
17.3.5Debug mode . . . . .447
17.4IWDG registers . . . . .448
17.4.1IWDG key register (IWDG_KR) . . . . .448
17.4.2IWDG prescaler register (IWDG_PR) . . . . .449
17.4.3IWDG reload register (IWDG_RLR) . . . . .450
17.4.4IWDG status register (IWDG_SR) . . . . .451
17.4.5IWDG window register (IWDG_WINR) . . . . .452
17.4.6IWDG register map . . . . .453
18System window watchdog (WWDG) . . . . .454
18.1Introduction . . . . .454
18.2WWDG main features . . . . .454
18.3WWDG functional description . . . . .454
18.3.1WWDG block diagram . . . . .455
18.3.2Enabling the watchdog . . . . .455
18.3.3Controlling the down-counter . . . . .455
18.3.4How to program the watchdog timeout . . . . .455
18.3.5Debug mode . . . . .457
18.4WWDG interrupts . . . . .457
18.5WWDG registers . . . . .457
18.5.1WWDG control register (WWDG_CR) . . . . .457
18.5.2WWDG configuration register (WWDG_CFR) . . . . .458
18.5.3WWDG status register (WWDG_SR) .....458
18.5.4WWDG register map .....459
19Real-time clock (RTC) .....460
19.1Introduction .....460
19.2RTC main features .....461
19.3RTC implementation .....461
19.4RTC functional description .....462
19.4.1RTC block diagram .....462
19.4.2GPIOs controlled by the RTC .....463
19.4.3Clock and prescalers .....464
19.4.4Real-time clock and calendar .....465
19.4.5Programmable alarms .....466
19.4.6Periodic auto-wakeup .....466
19.4.7RTC initialization and configuration .....467
19.4.8Reading the calendar .....468
19.4.9Resetting the RTC .....469
19.4.10RTC synchronization .....470
19.4.11RTC reference clock detection .....470
19.4.12RTC smooth digital calibration .....471
19.4.13Time-stamp function .....473
19.4.14Tamper detection .....474
19.4.15Calibration clock output .....476
19.4.16Alarm output .....476
19.5RTC low-power modes .....477
19.6RTC interrupts .....477
19.7RTC registers .....478
19.7.1RTC time register (RTC_TR) .....478
19.7.2RTC date register (RTC_DR) .....479
19.7.3RTC control register (RTC_CR) .....480
19.7.4RTC initialization and status register (RTC_ISR) .....483
19.7.5RTC prescaler register (RTC_PRER) .....486
19.7.6RTC wakeup timer register (RTC_WUTR) .....487
19.7.7RTC alarm A register (RTC_ALRMAR) .....488
19.7.8RTC alarm B register (RTC_ALRMBR) .....489
19.7.9RTC write protection register (RTC_WPR) .....490

20.6I2C interrupts . . . . .556
20.7I2C registers . . . . .557
20.7.1I2C control register 1 (I2C_CR1) . . . . .557
20.7.2I2C control register 2 (I2C_CR2) . . . . .560
20.7.3I2C own address 1 register (I2C_OAR1) . . . . .562
20.7.4I2C own address 2 register (I2C_OAR2) . . . . .563
20.7.5I2C timing register (I2C_TIMINGR) . . . . .564
20.7.6I2C timeout register (I2C_TIMEOUTR) . . . . .565
20.7.7I2C interrupt and status register (I2C_ISR) . . . . .566
20.7.8I2C interrupt clear register (I2C_ICR) . . . . .568
20.7.9I2C PEC register (I2C_PECR) . . . . .569
20.7.10I2C receive data register (I2C_RXDR) . . . . .570
20.7.11I2C transmit data register (I2C_TXDR) . . . . .570
20.7.12I2C register map . . . . .571
21Universal synchronous/asynchronous receiver transmitter (USART/UART) . . . . .573
21.1Introduction . . . . .573
21.2USART main features . . . . .573
21.3USART extended features . . . . .574
21.4USART implementation . . . . .575
21.5USART functional description . . . . .575
21.5.1USART character description . . . . .578
21.5.2USART transmitter . . . . .580
21.5.3USART receiver . . . . .583
21.5.4USART baud rate generation . . . . .588
21.5.5Tolerance of the USART receiver to clock deviation . . . . .590
21.5.6USART auto baud rate detection . . . . .592
21.5.7Multiprocessor communication using USART . . . . .593
21.5.8Modbus communication using USART . . . . .595
21.5.9USART parity control . . . . .596
21.5.10USART LIN (local interconnection network) mode . . . . .597
21.5.11USART synchronous mode . . . . .599
21.5.12USART Single-wire Half-duplex communication . . . . .602
21.5.13USART Smartcard mode . . . . .602
21.5.14USART IrDA SIR ENDEC block . . . . .607
21.5.15USART continuous communication in DMA mode . . . . .609
21.5.16RS232 hardware flow control and RS485 driver enable using USART . . . . .611
21.5.17Wakeup from Stop mode using USART . . . . .613
21.6USART in low-power modes . . . . .615
21.7USART interrupts . . . . .615
21.8USART registers . . . . .617
21.8.1USART control register 1 (USART_CR1) . . . . .617
21.8.2USART control register 2 (USART_CR2) . . . . .620
21.8.3USART control register 3 (USART_CR3) . . . . .624
21.8.4USART baud rate register (USART_BRR) . . . . .628
21.8.5USART guard time and prescaler register (USART_GTPR) . . . . .628
21.8.6USART receiver timeout register (USART_RTOR) . . . . .629
21.8.7USART request register (USART_RQR) . . . . .630
21.8.8USART interrupt and status register (USART_ISR) . . . . .631
21.8.9USART interrupt flag clear register (USART_ICR) . . . . .636
21.8.10USART receive data register (USART_RDR) . . . . .638
21.8.11USART transmit data register (USART_TDR) . . . . .638
21.8.12USART register map . . . . .639
22Low-power universal asynchronous receiver transmitter (LPUART) . . . . .641
22.1Introduction . . . . .641
22.2LPUART main features . . . . .642
22.3LPUART implementation . . . . .642
22.4LPUART functional description . . . . .643
22.4.1LPUART character description . . . . .646
22.4.2LPUART transmitter . . . . .648
22.4.3LPUART receiver . . . . .650
22.4.4LPUART baud rate generation . . . . .653
22.4.5Tolerance of the LPUART receiver to clock deviation . . . . .655
22.4.6Multiprocessor communication using LPUART . . . . .656
22.4.7LPUART parity control . . . . .658
22.4.8Single-wire Half-duplex communication using LPUART . . . . .659
22.4.9Continuous communication in DMA mode using LPUART . . . . .659
22.4.10RS232 Hardware flow control and RS485 Driver Enable using LPUART . . . . .662
22.4.11Wakeup from Stop mode using LPUART . . . . .665
22.5LPUART in low-power mode . . . . .667
22.6LPUART interrupts . . . . .667
22.7LPUART registers . . . . .669
22.7.1Control register 1 (LPUART_CR1) . . . . .669
22.7.2Control register 2 (LPUART_CR2) . . . . .672
22.7.3Control register 3 (LPUART_CR3) . . . . .674
22.7.4Baud rate register (LPUART_BRR) . . . . .676
22.7.5Request register (LPUART_RQR) . . . . .676
22.7.6Interrupt & status register (LPUART_ISR) . . . . .677
22.7.7Interrupt flag clear register (LPUART_ICR) . . . . .680
22.7.8Receive data register (LPUART_RDR) . . . . .681
22.7.9Transmit data register (LPUART_TDR) . . . . .681
22.7.10LPUART register map . . . . .683
23Serial peripheral interface (SPI) . . . . .684
23.1Introduction . . . . .684
23.1.1SPI main features . . . . .684
23.1.2SPI extended features . . . . .685
23.2SPI implementation . . . . .685
23.3SPI functional description . . . . .686
23.3.1General description . . . . .686
23.3.2Communications between one master and one slave . . . . .687
23.3.3Standard multi-slave communication . . . . .690
23.3.4Multi-master communication . . . . .691
23.3.5Slave select (NSS) pin management . . . . .691
23.3.6Communication formats . . . . .693
23.3.7SPI configuration . . . . .695
23.3.8Procedure for enabling SPI . . . . .695
23.3.9Data transmission and reception procedures . . . . .696
23.3.10Procedure for disabling the SPI . . . . .698
23.3.11Communication using DMA (direct memory addressing) . . . . .699
23.3.12SPI status flags . . . . .701
23.3.13SPI error flags . . . . .702
23.4SPI special features . . . . .703
23.4.1TI mode . . . . .703
23.4.2CRC calculation . . . . .704
23.5SPI interrupts . . . . .706
23.6SPI registers . . . . .707
23.6.1SPI control register 1 (SPI_CR1) . . . . .707
23.6.2SPI control register 2 (SPI_CR2) . . . . .709
23.6.3SPI status register (SPI_SR) . . . . .710
23.6.4SPI data register (SPI_DR) . . . . .712
23.6.5SPI CRC polynomial register (SPI_CRCPR) . . . . .712
23.6.6SPI RX CRC register (SPI_RXCRCR) . . . . .713
23.6.7SPI TX CRC register (SPI_TXCRCR) . . . . .713
23.6.8SPI register map . . . . .714
24Debug support (DBG) . . . . .715
24.1Overview . . . . .715
24.2Reference Arm® documentation . . . . .716
24.3Pinout and debug port pins . . . . .716
24.3.1SWD port pins . . . . .716
24.3.2SW-DP pin assignment . . . . .716
24.3.3Internal pull-up & pull-down on SWD pins . . . . .717
24.4ID codes and locking mechanism . . . . .717
24.4.1MCU device ID code . . . . .717
24.5SWD port . . . . .718
24.5.1SWD protocol introduction . . . . .718
24.5.2SWD protocol sequence . . . . .718
24.5.3SW-DP state machine (reset, idle states, ID code) . . . . .719
24.5.4DP and AP read/write accesses . . . . .720
24.5.5SW-DP registers . . . . .720
24.5.6SW-AP registers . . . . .721
24.6Core debug . . . . .722
24.7BPU (Break Point Unit) . . . . .722
24.7.1BPU functionality . . . . .722
24.8DWT (Data Watchpoint) . . . . .723
24.8.1DWT functionality . . . . .723
24.8.2DWT Program Counter Sample Register . . . . .723
24.9MCU debug component (DBG) . . . . .723
24.9.1Debug support for low-power modes . . . . .723
24.9.2Debug support for timers, watchdog and I 2 C . . . . .724
24.9.3Debug MCU configuration register (DBG_CR) . . . . .724
24.9.4Debug MCU APB1 freeze register (DBG_APB1_FZ) . . . . .726
24.9.5Debug MCU APB2 freeze register (DBG_APB2_FZ) . . . . .728
24.10DBG register map . . . . .729
25Device electronic signature . . . . .730
25.1Memory size register . . . . .730
25.1.1Flash size register . . . . .730
25.2Unique device ID registers (96 bits) . . . . .730
Appendix ACode examples. . . . .732
A.1Introduction . . . . .732
A.2NVM/RCC Operation code example . . . . .732
A.2.1Increasing the CPU frequency preparation sequence code . . . . .732
A.2.2Decreasing the CPU frequency preparation sequence code . . . . .732
A.2.3Switch from PLL to HSI16 sequence code . . . . .733
A.2.4Switch to PLL sequence code. . . . .733
A.3NVM Operation code example . . . . .734
A.3.1Unlocking the data EEPROM and FLASH_PECR register code example . . . . .734
A.3.2Locking data EEPROM and FLASH_PECR register code example . . . . .734
A.3.3Unlocking the NVM program memory code example . . . . .734
A.3.4Unlocking the option bytes area code example . . . . .735
A.3.5Write to data EEPROM code example . . . . .735
A.3.6Erase to data EEPROM code example . . . . .735
A.3.7Program Option byte code example . . . . .736
A.3.8Erase Option byte code example . . . . .736
A.3.9Program a single word to Flash program memory code example . . . . .737
A.3.10Program half-page to Flash program memory code example . . . . .738
A.3.11Erase a page in Flash program memory code example . . . . .739
A.3.12Mass erase code example . . . . .740
A.4Clock Controller. . . . .741
A.4.1HSE start sequence code example . . . . .741
A.4.2PLL configuration modification code example . . . . .742
A.4.3MCO selection code example. . . . .743
A.5GPIOs . . . . .743
A.5.1Locking mechanism code example. . . . .743
A.5.2Alternate function selection sequence code example . . . . .743
A.5.3Analog GPIO configuration code example . . . . .743
A.6DMA . . . . .744
A.6.1DMA Channel Configuration sequence code example . . . . .744
A.7Interrupts and event . . . . .744
A.7.1NVIC initialization example . . . . .744
A.7.2Extended interrupt selection code example . . . . .744
A.8ADC . . . . .745
A.8.1Calibration code example . . . . .745
A.8.2ADC enable sequence code example . . . . .745
A.8.3ADC disable sequence code example . . . . .746
A.8.4ADC clock selection code example . . . . .746
A.8.5Single conversion sequence code example - Software trigger . . . . .746
A.8.6Continuous conversion sequence code example - Software trigger . . . . .747
A.8.7Single conversion sequence code example - Hardware trigger . . . . .747
A.8.8Continuous conversion sequence code example - Hardware trigger . . . . .748
A.8.9DMA one shot mode sequence code example . . . . .748
A.8.10DMA circular mode sequence code example . . . . .749
A.8.11Wait mode sequence code example . . . . .749
A.8.12Auto off and no wait mode sequence code example . . . . .749
A.8.13Auto off and wait mode sequence code example . . . . .750
A.8.14Analog watchdog code example . . . . .750
A.8.15Oversampling code example . . . . .751
A.9Timers . . . . .751
A.9.1Upcounter on TI2 rising edge code example . . . . .751
A.9.2Up counter on each 2 ETR rising edges code example . . . . .751
A.9.3Input capture configuration code example . . . . .752
A.9.4Input capture data management code example . . . . .752
A.9.5PWM input configuration code example . . . . .753
A.9.6PWM input with DMA configuration code example . . . . .753
A.9.7Output compare configuration code example . . . . .754
A.9.8Edge-aligned PWM configuration example . . . . .755
A.9.9Center-aligned PWM configuration example . . . . .755
A.9.10ETR configuration to clear OCxREF code example . . . . .756
A.9.11Encoder interface code example . . . . .756
A.9.12Reset mode code example . . . . .757
A.9.13Gated mode code example . . . . .757
A.9.14Trigger mode code example . . . . .758
A.9.15External clock mode 2 + trigger mode code example. . . . .758
A.9.16One-Pulse mode code example . . . . .758
A.9.17Timer prescaling another timer code example . . . . .759
A.9.18Timer enabling another timer code example. . . . .760
A.9.19Master and slave synchronization code example. . . . .761
A.9.20Two timers synchronized by an external trigger code example . . . . .762
A.9.21DMA burst feature code example . . . . .763
A.10Low-power timer (LPTIM) . . . . .764
A.10.1Pulse counter configuration code example. . . . .764
A.11IWDG code example . . . . .764
A.11.1IWDG configuration code example. . . . .764
A.11.2IWDG configuration with window code example. . . . .765
A.12WWDG code example. . . . .765
A.12.1WWDG configuration code example. . . . .765
A.13RTC code example . . . . .765
A.13.1RTC calendar configuration code example. . . . .765
A.13.2RTC alarm configuration code example . . . . .766
A.13.3RTC WUT configuration code example . . . . .766
A.13.4RTC read calendar code example . . . . .767
A.13.5RTC calibration code example . . . . .767
A.13.6RTC tamper and time stamp configuration code example . . . . .768
A.13.7RTC tamper and time stamp code example . . . . .768
A.13.8RTC clock output code example. . . . .768
A.14I2C code example . . . . .769
A.14.1I2C configured in slave mode code example . . . . .769
A.14.2I2C slave transmitter code example . . . . .769
A.14.3I2C slave receiver code example . . . . .769
A.14.4I2C configured in master mode to receive code example. . . . .770
A.14.5I2C configured in master mode to transmit code example . . . . .770
A.14.6I2C master transmitter code example. . . . .770
A.14.7I2C master receiver code example. . . . .770
A.14.8I2C configured in master mode to transmit with DMA code example . . . . .771
A.14.9I2C configured in slave mode to receive with DMA code example. . . . .771
A.15USART code example. . . . .771
A.15.1USART transmitter configuration code example. . . . .771

Revision history . . . . . 777

List of tables

Table 1.STM32L010 memory density . . . . .34
Table 2.Overview of features per category . . . . .34
Table 3.STM32L010xx peripheral register boundary addresses . . . . .41
Table 4.Boot modes . . . . .44
Table 5.Boot modes . . . . .44
Table 6.NVM organization (category 1 devices) . . . . .47
Table 7.NVM organization (category 2 devices) . . . . .47
Table 8.NVM organization (category 3 devices) . . . . .48
Table 9.NVM organization (category 5 devices) . . . . .49
Table 10.Link between master clock power range and frequencies . . . . .50
Table 11.Delays to memory access and number of wait states . . . . .50
Table 12.Internal buffer management . . . . .53
Table 13.Configurations for buffers and speculative reading . . . . .56
Table 14.Dhrystone performances in all memory interface configurations . . . . .57
Table 15.NVM write/erase timings . . . . .70
Table 16.NVM write/erase duration . . . . .70
Table 17.Protection level and content of RDP Option bytes . . . . .74
Table 18.Link between protection bits of FLASH_WRPPROTx register
and protected address in Flash program memory . . . . .
75
Table 19.Memory access vs mode, protection and Flash program memory sectors . . . . .76
Table 20.Flash interrupt request . . . . .79
Table 21.Flash interface - register map and reset values . . . . .95
Table 22.Option byte format . . . . .96
Table 23.Option byte organization . . . . .96
Table 24.CRC internal input/output signals . . . . .99
Table 25.CRC register map and reset values . . . . .104
Table 26.Segment accesses according to the Firewall state . . . . .108
Table 27.Segment granularity and area ranges . . . . .109
Table 28.Firewall register map and reset values . . . . .116
Table 29.Performance versus VCORE ranges . . . . .119
Table 30.Summary of low-power modes . . . . .125
Table 31.Sleep-now . . . . .129
Table 32.Sleep-on-exit . . . . .130
Table 33.Sleep-now (Low-power sleep) . . . . .131
Table 34.Sleep-on-exit (Low-power sleep) . . . . .132
Table 35.Stop mode . . . . .134
Table 36.Standby mode . . . . .136
Table 37.PWR - register map and reset values . . . . .143
Table 38.HSE/LSE clock sources . . . . .149
Table 39.System clock source frequency . . . . .154
Table 40.RCC register map and reset values . . . . .188
Table 41.Port bit configuration table . . . . .193
Table 42.GPIO register map and reset values . . . . .206
Table 43.SYSCFG register map and reset values . . . . .215
Table 44.DMA implementation . . . . .217
Table 45.DMA requests for each channel . . . . .218
Table 46.Programmable data width and endian behavior (when PINC = MINC = 1) . . . . .225
Table 47.DMA interrupt requests . . . . .226
Table 48.DMA register map and reset values . . . . .236
Table 49.List of vectors . . . . .239
Table 50.EXTI lines connections . . . . .246
Table 51.Extended interrupt/event controller register map and reset values. . . . .251
Table 52.ADC input/output pins . . . . .254
Table 53.ADC internal input/output signals . . . . .255
Table 54.External triggers . . . . .255
Table 55.Latency between trigger and start of conversion . . . . .260
Table 56.Configuring the trigger polarity . . . . .266
Table 57.tSAR timings depending on resolution . . . . .268
Table 58.Analog watchdog comparison. . . . .277
Table 59.Analog watchdog channel selection . . . . .277
Table 60.Maximum output results vs N and M. Grayed values indicates truncation . . . . .281
Table 61.ADC interrupts . . . . .285
Table 62.ADC register map and reset values . . . . .300
Table 63.Counting direction versus encoder signals. . . . .333
Table 64.TIM2/TIM3 internal trigger connection . . . . .350
Table 65.Output control bit for standard OCx channels. . . . .360
Table 66.TIM2 register map and reset values . . . . .367
Table 67.Counting direction versus encoder signals. . . . .400
Table 68.Output control bit for standard OCx channels. . . . .418
Table 69.TIM21/22 register map and reset values . . . . .422
Table 70.STM32L010xx LPTIM features . . . . .425
Table 71.LPTIM1 external trigger connection . . . . .426
Table 72.Prescaler division ratios . . . . .427
Table 73.Encoder counting scenarios . . . . .433
Table 74.Effect of low-power modes on the LPTIM. . . . .434
Table 75.Interrupt events. . . . .435
Table 76.LPTIM register map and reset values. . . . .444
Table 77.IWDG register map and reset values . . . . .453
Table 78.WWDG register map and reset values . . . . .459
Table 79.RTC implementation . . . . .461
Table 80.RTC pin PC13 configuration. . . . .463
Table 81.RTC_OUT mapping . . . . .464
Table 82.Effect of low-power modes on RTC . . . . .477
Table 83.Interrupt control bits . . . . .477
Table 84.RTC register map and reset values . . . . .502
Table 85.STM32L010xx I2C features . . . . .506
Table 86.I2C input/output pins. . . . .508
Table 87.I2C internal input/output signals . . . . .508
Table 88.Comparison of analog vs. digital filters. . . . .510
Table 89.I2C-SMBUS specification data setup and hold times . . . . .513
Table 90.I2C configuration. . . . .517
Table 91.I2C-SMBUS specification clock timings . . . . .528
Table 92.Examples of timing settings for fI2CCLK = 8 MHz . . . . .538
Table 93.Examples of timings settings for fI2CCLK = 16 MHz . . . . .538
Table 94.SMBus timeout specifications . . . . .540
Table 95.SMBus with PEC configuration. . . . .543
Table 96.Examples of TIMEOUTA settings for various I2CCLK frequencies
(max tTIMEOUT = 25 ms) . . . . .
544
Table 97.Examples of TIMEOUTB settings for various I2CCLK frequencies . . . . .544
Table 98.Examples of TIMEOUTA settings for various I2CCLK frequencies
(max \( t_{IDLE} = 50 \mu s \) ) . . . . .544
Table 99.Effect of low-power modes on the I2C . . . . .555
Table 100.I2C Interrupt requests . . . . .556
Table 101.I2C register map and reset values . . . . .571
Table 102.STM32L010x USART/LPUART features . . . . .575
Table 103.Noise detection from sampled data . . . . .587
Table 104.Error calculation for programmed baud rates at \( f_{CK} = 32 \text{ MHz} \) in both cases of oversampling by 16 or by 8. . . . .590
Table 105.Tolerance of the USART receiver when BRR [3:0] = 0000. . . . .591
Table 106.Tolerance of the USART receiver when BRR [3:0] is different from 0000 . . . . .591
Table 107.Frame formats . . . . .596
Table 108.Effect of low-power modes on the USART . . . . .615
Table 109.USART interrupt requests. . . . .615
Table 110.USART register map and reset values . . . . .639
Table 111.STM32L010x USART/LPUART features . . . . .643
Table 112.Error calculation for programmed baud rates at \( f_{ck} = 32.768 \text{ kHz} \) . . . . .654
Table 113.Error calculation for programmed baud rates at \( f_{ck} = 32 \text{ MHz} \) . . . . .654
Table 114.Tolerance of the LPUART receiver. . . . .655
Table 115.Frame formats . . . . .658
Table 116.Effect of low-power modes on the LPUART . . . . .667
Table 117.LPUART interrupt requests. . . . .667
Table 118.LPUART register map and reset values . . . . .683
Table 119.STM32L010xx SPI implementation . . . . .685
Table 120.SPI interrupt requests . . . . .706
Table 121.SPI register map and reset values . . . . .714
Table 122.SW debug port pins . . . . .716
Table 123.REV_ID values . . . . .718
Table 124.Packet request (8-bits) . . . . .718
Table 125.ACK response (3 bits). . . . .719
Table 126.DATA transfer (33 bits). . . . .719
Table 127.SW-DP registers . . . . .720
Table 128.32-bit debug port registers addressed through the shifted value A[3:2] . . . . .721
Table 129.Core debug registers . . . . .722
Table 130.DBG register map and reset values . . . . .729
Table 131.Document revision history . . . . .777

List of figures

Figure 1.System architecture . . . . .37
Figure 2.Memory map . . . . .40
Figure 3.Structure of one internal buffer . . . . .52
Figure 4.Timing to fetch and execute instructions with prefetch disabled. . . . .54
Figure 5.Timing to fetch and execute instructions with prefetch enabled . . . . .56
Figure 6.RDP levels . . . . .74
Figure 7.CRC calculation unit block diagram . . . . .99
Figure 8.STM32L010xx firewall connection schematics . . . . .106
Figure 9.Firewall functional states . . . . .110
Figure 10.Power supply overview . . . . .117
Figure 11.Performance versus VDD and VCORE range . . . . .120
Figure 12.Power supply supervisors . . . . .122
Figure 13.Power-on reset/power-down reset waveform . . . . .123
Figure 14.BOR thresholds . . . . .124
Figure 15.Simplified diagram of the reset circuit. . . . .145
Figure 16.Clock tree . . . . .148
Figure 17.Using TIM21 channel 1 input capture to measure frequencies . . . . .156
Figure 18.Basic structure of an I/O port bit . . . . .192
Figure 19.Basic structure of a 5-Volt tolerant I/O port bit . . . . .192
Figure 20.Input floating / pull up / pull down configurations . . . . .197
Figure 21.Output configuration . . . . .198
Figure 22.Alternate function configuration . . . . .198
Figure 23.High impedance-analog configuration . . . . .199
Figure 24.DMA request mapping . . . . .218
Figure 25.DMA block diagram . . . . .219
Figure 26.Extended interrupts and events controller (EXTI) block diagram . . . . .243
Figure 27.Extended interrupt/event GPIO mapping . . . . .245
Figure 28.ADC block diagram . . . . .254
Figure 29.ADC calibration . . . . .257
Figure 30.Calibration factor forcing . . . . .258
Figure 31.Enabling/disabling the ADC . . . . .259
Figure 32.ADC clock scheme . . . . .259
Figure 33.ADC connectivity . . . . .261
Figure 34.Analog to digital conversion time . . . . .265
Figure 35.ADC conversion timings . . . . .265
Figure 36.Stopping an ongoing conversion . . . . .266
Figure 37.Single conversions of a sequence, software trigger . . . . .269
Figure 38.Continuous conversion of a sequence, software trigger . . . . .269
Figure 39.Single conversions of a sequence, hardware trigger . . . . .270
Figure 40.Continuous conversions of a sequence, hardware trigger . . . . .270
Figure 41.Data alignment and resolution (oversampling disabled: OVSE = 0). . . . .271
Figure 42.Example of overrun (OVR) . . . . .272
Figure 43.Wait mode conversion (continuous mode, software trigger). . . . .274
Figure 44.Behavior with WAIT = 0, AUTOFF = 1 . . . . .275
Figure 45.Behavior with WAIT = 1, AUTOFF = 1 . . . . .276
Figure 46.Analog watchdog guarded area . . . . .277
Figure 47.ADC_AWD1_OUT signal generation . . . . .278
Figure 48.ADC_AWD1_OUT signal generation (AWD flag not cleared by software) . . . . .279
Figure 49.ADC1_AWD_OUT signal generation (on a single channel) . . . . .279
Figure 50.Analog watchdog threshold update . . . . .280
Figure 51.20-bit to 16-bit result truncation . . . . .281
Figure 52.Numerical example with 5-bits shift and rounding . . . . .281
Figure 53.Triggered oversampling mode (TOVS bit = 1) . . . . .283
Figure 54.VREFINT channel block diagram . . . . .283
Figure 55.General-purpose timer block diagram . . . . .303
Figure 56.Counter timing diagram with prescaler division change from 1 to 2 . . . . .305
Figure 57.Counter timing diagram with prescaler division change from 1 to 4 . . . . .305
Figure 58.Counter timing diagram, internal clock divided by 1 . . . . .306
Figure 59.Counter timing diagram, internal clock divided by 2 . . . . .307
Figure 60.Counter timing diagram, internal clock divided by 4 . . . . .307
Figure 61.Counter timing diagram, internal clock divided by N . . . . .308
Figure 62.Counter timing diagram, Update event when ARPE=0 (TIMx_ARR not preloaded). . . . .308
Figure 63.Counter timing diagram, Update event when ARPE=1 (TIMx_ARR preloaded). . . . .309
Figure 64.Counter timing diagram, internal clock divided by 1 . . . . .310
Figure 65.Counter timing diagram, internal clock divided by 2 . . . . .310
Figure 66.Counter timing diagram, internal clock divided by 4 . . . . .311
Figure 67.Counter timing diagram, internal clock divided by N . . . . .311
Figure 68.Counter timing diagram, Update event when repetition counter
is not used . . . . .
312
Figure 69.Counter timing diagram, internal clock divided by 1, TIMx_ARR=0x6 . . . . .313
Figure 70.Counter timing diagram, internal clock divided by 2 . . . . .314
Figure 71.Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 . . . . .314
Figure 72.Counter timing diagram, internal clock divided by N . . . . .315
Figure 73.Counter timing diagram, Update event with ARPE=1 (counter underflow). . . . .315
Figure 74.Counter timing diagram, Update event with ARPE=1 (counter overflow). . . . .316
Figure 75.Control circuit in normal mode, internal clock divided by 1 . . . . .317
Figure 76.TI2 external clock connection example. . . . .317
Figure 77.Control circuit in external clock mode 1 . . . . .318
Figure 78.External trigger input block . . . . .319
Figure 79.Control circuit in external clock mode 2 . . . . .320
Figure 80.Capture/compare channel (example: channel 1 input stage) . . . . .321
Figure 81.Capture/compare channel 1 main circuit . . . . .321
Figure 82.Output stage of capture/compare channel (channel 1). . . . .322
Figure 83.PWM input mode timing . . . . .324
Figure 84.Output compare mode, toggle on OC1. . . . .326
Figure 85.Edge-aligned PWM waveforms (ARR=8). . . . .327
Figure 86.Center-aligned PWM waveforms (ARR=8). . . . .329
Figure 87.Example of one-pulse mode. . . . .330
Figure 88.Clearing TIMx_OCxREF . . . . .332
Figure 89.Example of counter operation in encoder interface mode . . . . .334
Figure 90.Example of encoder interface mode with TI1FP1 polarity inverted . . . . .334
Figure 91.Control circuit in reset mode . . . . .335
Figure 92.Control circuit in gated mode . . . . .336
Figure 93.Control circuit in trigger mode . . . . .337
Figure 94.Control circuit in external clock mode 2 + trigger mode . . . . .339
Figure 95.Master/Slave timer example . . . . .339
Figure 96.Gating timer y with OC1REF of timer x. . . . .341
Figure 97.Gating timer y with Enable of timer x . . . . .342
Figure 98.Triggering timer y with update of timer x. . . . .343
Figure 99.Triggering timer y with Enable of timer x343
Figure 100.Triggering timer x and y with timer x TI1 input344
Figure 101.General-purpose timer block diagram (TIM21/22)370
Figure 102.Counter timing diagram with prescaler division change from 1 to 2372
Figure 103.Counter timing diagram with prescaler division change from 1 to 4373
Figure 104.Counter timing diagram, internal clock divided by 1374
Figure 105.Counter timing diagram, internal clock divided by 2375
Figure 106.Counter timing diagram, internal clock divided by 4375
Figure 107.Counter timing diagram, internal clock divided by N376
Figure 108.Counter timing diagram, update event when ARPE=0 (TIMx_ARR not preloaded)376
Figure 109.Counter timing diagram, update event when ARPE=1 (TIMx_ARR preloaded)377
Figure 110.Counter timing diagram, internal clock divided by 1378
Figure 111.Counter timing diagram, internal clock divided by 2378
Figure 112.Counter timing diagram, internal clock divided by 4379
Figure 113.Counter timing diagram, internal clock divided by N379
Figure 114.Counter timing diagram, internal clock divided by 1, TIMx_ARR=0x6381
Figure 115.Counter timing diagram, internal clock divided by 2381
Figure 116.Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36382
Figure 117.Counter timing diagram, internal clock divided by N382
Figure 118.Counter timing diagram, Update event with ARPE=1 (counter underflow)383
Figure 119.Counter timing diagram, Update event with ARPE=1 (counter overflow)383
Figure 120.Control circuit in normal mode, internal clock divided by 1384
Figure 121.TI2 external clock connection example385
Figure 122.Control circuit in external clock mode 1386
Figure 123.External trigger input block386
Figure 124.Control circuit in external clock mode 2387
Figure 125.Capture/compare channel (example: channel 1 input stage)388
Figure 126.Capture/compare channel 1 main circuit388
Figure 127.Output stage of capture/compare channel (channel 1 and 2)389
Figure 128.PWM input mode timing391
Figure 129.Output compare mode, toggle on OC1393
Figure 130.Edge-aligned PWM waveforms (ARR=8)394
Figure 131.Center-aligned PWM waveforms (ARR=8)395
Figure 132.Clearing TIMx_OCxREF397
Figure 133.Example of one pulse mode398
Figure 134.Example of counter operation in encoder interface mode400
Figure 135.Example of encoder interface mode with TI1FP1 polarity inverted401
Figure 136.Control circuit in reset mode402
Figure 137.Control circuit in gated mode403
Figure 138.Control circuit in trigger mode404
Figure 139.Low-power timer block diagram425
Figure 140.Glitch filter timing diagram427
Figure 141.LPTIM output waveform, single counting mode configuration429
Figure 142.LPTIM output waveform, Single counting mode configuration and Set-once mode activated (WAVE bit is set)429
Figure 143.LPTIM output waveform, Continuous counting mode configuration430
Figure 144.Waveform generation431
Figure 145.Encoder mode counting sequence434
Figure 146.Independent watchdog block diagram445
Figure 147.Watchdog block diagram455
Figure 148. Window watchdog timing diagram .....456
Figure 149. RTC block diagram .....462
Figure 150. I2C1 block diagram .....507
Figure 151. I2C bus protocol .....509
Figure 152. Setup and hold timings .....511
Figure 153. I2C initialization flow .....514
Figure 154. Data reception .....515
Figure 155. Data transmission .....516
Figure 156. Slave initialization flow .....519
Figure 157. Transfer sequence flow for I2C slave transmitter, NOSTRETCH = 0 .....521
Figure 158. Transfer sequence flow for I2C slave transmitter, NOSTRETCH = 1 .....522
Figure 159. Transfer bus diagrams for I2C slave transmitter .....523
Figure 160. Transfer sequence flow for slave receiver with NOSTRETCH = 0 .....524
Figure 161. Transfer sequence flow for slave receiver with NOSTRETCH = 1 .....525
Figure 162. Transfer bus diagrams for I2C slave receiver .....525
Figure 163. Master clock generation .....527
Figure 164. Master initialization flow .....529
Figure 165. 10-bit address read access with HEAD10R = 0 .....529
Figure 166. 10-bit address read access with HEAD10R = 1 .....530
Figure 167. Transfer sequence flow for I2C master transmitter for N≤255 bytes .....531
Figure 168. Transfer sequence flow for I2C master transmitter for N>255 bytes .....532
Figure 169. Transfer bus diagrams for I2C master transmitter .....533
Figure 170. Transfer sequence flow for I2C master receiver for N≤255 bytes .....535
Figure 171. Transfer sequence flow for I2C master receiver for N >255 bytes .....536
Figure 172. Transfer bus diagrams for I2C master receiver .....537
Figure 173. Timeout intervals for \( t_{LOW:SEXT} \) , \( t_{LOW:MEXT} \) .....541
Figure 174. Transfer sequence flow for SMBus slave transmitter N bytes + PEC .....545
Figure 175. Transfer bus diagrams for SMBus slave transmitter (SBC=1) .....546
Figure 176. Transfer sequence flow for SMBus slave receiver N Bytes + PEC .....547
Figure 177. Bus transfer diagrams for SMBus slave receiver (SBC=1) .....548
Figure 178. Bus transfer diagrams for SMBus master transmitter .....549
Figure 179. Bus transfer diagrams for SMBus master receiver .....551
Figure 180. USART block diagram .....577
Figure 181. Word length programming .....579
Figure 182. Configurable stop bits .....581
Figure 183. TC/TXE behavior when transmitting .....582
Figure 184. Start bit detection when oversampling by 16 or 8 .....583
Figure 185. Data sampling when oversampling by 16 .....586
Figure 186. Data sampling when oversampling by 8 .....587
Figure 187. Mute mode using Idle line detection .....594
Figure 188. Mute mode using address mark detection .....595
Figure 189. Break detection in LIN mode (11-bit break length - LBDL bit is set) .....598
Figure 190. Break detection in LIN mode vs. Framing error detection .....599
Figure 191. USART example of synchronous transmission .....600
Figure 192. USART data clock timing diagram (M bits = 00) .....600
Figure 193. USART data clock timing diagram (M bits = 01) .....601
Figure 194. RX data setup/hold time .....601
Figure 195. ISO 7816-3 asynchronous protocol .....603
Figure 196. Parity error detection using the 1.5 stop bits .....604
Figure 197. IrDA SIR ENDEC- block diagram .....608
Figure 198. IrDA data modulation (3/16) -Normal Mode .....609
Figure 199. Transmission using DMA .....610
Figure 200. Reception using DMA . . . . .611
Figure 201. Hardware flow control between 2 USARTs . . . . .611
Figure 202. RS232 RTS flow control . . . . .612
Figure 203. RS232 CTS flow control . . . . .613
Figure 204. USART interrupt mapping diagram . . . . .616
Figure 205. LPUART block diagram . . . . .645
Figure 206. Word length programming . . . . .647
Figure 207. Configurable stop bits . . . . .648
Figure 208. TC/TXE behavior when transmitting . . . . .650
Figure 209. Mute mode using Idle line detection . . . . .657
Figure 210. Mute mode using address mark detection . . . . .658
Figure 211. Transmission using DMA . . . . .661
Figure 212. Reception using DMA . . . . .662
Figure 213. Hardware flow control between 2 LPUARTs . . . . .662
Figure 214. RS232 RTS flow control . . . . .663
Figure 215. RS232 CTS flow control . . . . .664
Figure 216. LPUART interrupt mapping diagram . . . . .668
Figure 217. SPI block diagram. . . . .686
Figure 218. Full-duplex single master/ single slave application. . . . .687
Figure 219. Half-duplex single master/ single slave application . . . . .688
Figure 220. Simplex single master/single slave application (master in transmit-only/
slave in receive-only mode) . . . . .
689
Figure 221. Master and three independent slaves. . . . .690
Figure 222. Multi-master application . . . . .691
Figure 223. Hardware/software slave select management . . . . .692
Figure 224. Data clock timing diagram . . . . .694
Figure 225. TXE/RXNE/BSY behavior in master / full-duplex mode (BIDIMODE=0,
RXONLY=0) in the case of continuous transfers . . . . .
697
Figure 226. TXE/RXNE/BSY behavior in slave / full-duplex mode (BIDIMODE=0,
RXONLY=0) in the case of continuous transfers . . . . .
698
Figure 227. Transmission using DMA . . . . .700
Figure 228. Reception using DMA . . . . .701
Figure 229. TI mode transfer . . . . .704
Figure 230. Block diagram of STM32L010xx MCU and Cortex ® -M0+-level debug support . . . . .715

Chapters