727
January 2015 DocID025023 Rev 2 1/727 1 RM0360 Reference manual STM32F030x4/6/8/C and STM32F070x6/B advanced ARM ® -based 32-bit MCUs Introduction This reference manual targets application developers. It provides complete information on how to use the STM32F030x4/6/8/C and STM32F070x6/B microcontroller memory and peripherals. It applies to STM32F030x4/6/8/C and STM32F070x6/B devices. For the purpose of this manual, STM32F030x4/6/8/C and STM32F070x6/B microcontrollers are referred to as STM32F0x0. The STM32F0x0 is a family of microcontrollers with different memory sizes, packages and peripherals. For ordering information, mechanical and electrical device characteristics, please refer to the corresponding datasheet. For information on the ARM ® Cortex ® -M0 core, please refer to the Cortex-M0 technical reference manual. Related documents Cortex-M0 technical reference manual, available from ARM website at www.arm.com STM32F0xx Cortex-M0 programming manual (PM0215) STM32F030x4/6/8/C and STM32F070x6/B datasheets available from STMicroelectronics website at www.st.com www.st.com

RM0360 Reference manual · Reference manual STM32F030x4/6/8/C and STM32F070x6/B advanced ARM ®-based 32-bit MCUs Introduction This reference manual targets application developers

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

  • January 2015 DocID025023 Rev 2 1/7271

    RM0360Reference manual

    STM32F030x4/6/8/C and STM32F070x6/B advanced ARM®-based 32-bit MCUs

    IntroductionThis reference manual targets application developers. It provides complete information on how to use the STM32F030x4/6/8/C and STM32F070x6/B microcontroller memory and peripherals.

    It applies to STM32F030x4/6/8/C and STM32F070x6/B devices.

    For the purpose of this manual, STM32F030x4/6/8/C and STM32F070x6/B microcontrollers are referred to as STM32F0x0.

    The STM32F0x0 is a family of microcontrollers with different memory sizes, packages and peripherals.

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

    For information on the ARM® Cortex®-M0 core, please refer to the Cortex-M0 technical reference manual.

    Related documents• Cortex-M0 technical reference manual, available from ARM website at www.arm.com• STM32F0xx Cortex-M0 programming manual (PM0215)• STM32F030x4/6/8/C and STM32F070x6/B datasheets available from STMicroelectronics

    website at www.st.com

    www.st.com

    http://www.st.com

  • DocID025023 Rev 2 2/727

    RM0360 Contents

    20

    Contents

    1 Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301.1 List of abbreviations for registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    1.2 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    1.3 Peripheral availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    2 System and memory overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.1 System architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    2.2 Memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    2.2.2 Memory map and register boundary addresses . . . . . . . . . . . . . . . . . . 35

    2.3 Embedded SRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    2.4 Flash memory overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    2.5 Boot configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3 Embedded Flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.1 Flash main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

    3.2 Flash memory functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.2.1 Flash memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

    3.2.2 Flash program and erase operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

    3.3 Memory protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.3.1 Read protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    3.3.2 Write protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

    3.3.3 Option byte write protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

    3.4 Flash interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

    3.5 Flash register description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.5.1 Flash access control register (FLASH_ACR) . . . . . . . . . . . . . . . . . . . . 56

    3.5.2 Flash key register (FLASH_KEYR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    3.5.3 Flash option key register (FLASH_OPTKEYR) . . . . . . . . . . . . . . . . . . . 57

    3.5.4 Flash status register (FLASH_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

    3.5.5 Flash control register (FLASH_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

    3.5.6 Flash address register (FLASH_AR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

    3.5.7 Flash Option byte register (FLASH_OBR) . . . . . . . . . . . . . . . . . . . . . . . 60

    3.5.8 Write protection register (FLASH_WRPR) . . . . . . . . . . . . . . . . . . . . . . . 61

  • Contents RM0360

    3/727 DocID025023 Rev 2

    3.5.9 Flash register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    4 Option bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634.1 Option byte description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

    4.1.1 User and read protection option bytes . . . . . . . . . . . . . . . . . . . . . . . . . . 64

    4.1.2 User data option bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

    4.1.3 Write protection option bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

    4.1.4 Option byte map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

    5 Cyclic redundancy check calculation unit (CRC) . . . . . . . . . . . . . . . . . 685.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    5.2 CRC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    5.3 CRC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    5.4 CRC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705.4.1 Data register (CRC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

    5.4.2 Independent data register (CRC_IDR) . . . . . . . . . . . . . . . . . . . . . . . . . 71

    5.4.3 Control register (CRC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

    5.4.4 Initial CRC value (CRC_INIT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    5.4.5 CRC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    6 Power control (PWR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736.1 Power supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

    6.1.1 Independent A/D converter supply and reference voltage . . . . . . . . . . . 73

    6.1.2 Voltage regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

    6.2 Power supply supervisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746.2.1 Power on reset (POR) / power down reset (PDR) . . . . . . . . . . . . . . . . . 74

    6.3 Low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756.3.1 Slowing down system clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

    6.3.2 Peripheral clock gating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

    6.3.3 Sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

    6.3.4 Stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

    6.3.5 Standby mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

    6.3.6 RTC wakeup from low-power mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

    6.4 Power control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826.4.1 Power control register (PWR_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

    6.4.2 Power control/status register (PWR_CSR) . . . . . . . . . . . . . . . . . . . . . . 82

  • DocID025023 Rev 2 4/727

    RM0360 Contents

    20

    6.4.3 PWR register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

    7 Reset and clock control (RCC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857.1 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

    7.1.1 Power reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

    7.1.2 System reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

    7.1.3 RTC domain reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

    7.2 Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 877.2.1 HSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

    7.2.2 HSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

    7.2.3 PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

    7.2.4 LSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

    7.2.5 LSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    7.2.6 System clock (SYSCLK) selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    7.2.7 Clock security system (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    7.2.8 ADC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    7.2.9 RTC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    7.2.10 Independent watchdog clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    7.2.11 Clock-out capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    7.2.12 Internal/external clock measurement with TIM14 . . . . . . . . . . . . . . . . . 96

    7.3 Low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

    7.4 RCC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 997.4.1 Clock control register (RCC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

    7.4.2 Clock configuration register (RCC_CFGR) . . . . . . . . . . . . . . . . . . . . . 101

    7.4.3 Clock interrupt register (RCC_CIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

    7.4.4 APB peripheral reset register 2 (RCC_APB2RSTR) . . . . . . . . . . . . . . 106

    7.4.5 APB peripheral reset register 1 (RCC_APB1RSTR) . . . . . . . . . . . . . . 108

    7.4.6 AHB peripheral clock enable register (RCC_AHBENR) . . . . . . . . . . . . 110

    7.4.7 APB peripheral clock enable register 2 (RCC_APB2ENR) . . . . . . . . . 111

    7.4.8 APB peripheral clock enable register 1 (RCC_APB1ENR) . . . . . . . . . 113

    7.4.9 RTC domain control register (RCC_BDCR) . . . . . . . . . . . . . . . . . . . . . 116

    7.4.10 Control/status register (RCC_CSR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    7.4.11 AHB peripheral reset register (RCC_AHBRSTR) . . . . . . . . . . . . . . . . 119

    7.4.12 Clock configuration register 2 (RCC_CFGR2) . . . . . . . . . . . . . . . . . . . 121

    7.4.13 Clock configuration register 3 (RCC_CFGR3) . . . . . . . . . . . . . . . . . . . 122

    7.4.14 Clock control register 2 (RCC_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 122

    7.4.15 RCC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

  • Contents RM0360

    5/727 DocID025023 Rev 2

    8 General-purpose I/Os (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1268.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

    8.2 GPIO main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

    8.3 GPIO functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1268.3.1 General-purpose I/O (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

    8.3.2 I/O pin alternate function multiplexer and mapping . . . . . . . . . . . . . . . 128

    8.3.3 I/O port control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

    8.3.4 I/O port data registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

    8.3.5 I/O data bitwise handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

    8.3.6 GPIO locking mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

    8.3.7 I/O alternate function input/output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

    8.3.8 External interrupt/wakeup lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

    8.3.9 Input configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

    8.3.10 Output configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

    8.3.11 Alternate function configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

    8.3.12 Analog configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

    8.3.13 Using the HSE or LSE oscillator pins as GPIOs . . . . . . . . . . . . . . . . . 134

    8.3.14 Using the GPIO pins in the RTC supply domain . . . . . . . . . . . . . . . . . 134

    8.4 GPIO registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1358.4.1 GPIO port mode register (GPIOx_MODER) (x =A..D, F) . . . . . . . . . . . 135

    8.4.2 GPIO port output type register (GPIOx_OTYPER) (x = A..D, F) . . . . . 135

    8.4.3 GPIO port output speed register (GPIOx_OSPEEDR) (x = A..D, F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

    8.4.4 GPIO port pull-up/pull-down register (GPIOx_PUPDR) (x = A..,D, F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

    8.4.5 GPIO port input data register (GPIOx_IDR) (x = A..D, F) . . . . . . . . . . 137

    8.4.6 GPIO port output data register (GPIOx_ODR) (x = A..D, F) . . . . . . . . 137

    8.4.7 GPIO port bit set/reset register (GPIOx_BSRR) (x = A..D, F) . . . . . . . 137

    8.4.8 GPIO port configuration lock register (GPIOx_LCKR) (x = A..B) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

    8.4.9 GPIO alternate function low register (GPIOx_AFRL) (x = A..D, ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

    8.4.10 GPIO alternate function high register (GPIOx_AFRH) (x = A..D, F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

    8.4.11 GPIO port bit reset register (GPIOx_BRR) (x = A..D, F) . . . . . . . . . . . 140

    8.4.12 GPIO register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

    9 System configuration controller (SYSCFG) . . . . . . . . . . . . . . . . . . . . 143

  • DocID025023 Rev 2 6/727

    RM0360 Contents

    20

    9.1 SYSCFG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1439.1.1 SYSCFG configuration register 1 (SYSCFG_CFGR1) . . . . . . . . . . . . 143

    9.1.2 SYSCFG external interrupt configuration register 1 (SYSCFG_EXTICR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

    9.1.3 SYSCFG external interrupt configuration register 2 (SYSCFG_EXTICR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

    9.1.4 SYSCFG external interrupt configuration register 3 (SYSCFG_EXTICR3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

    9.1.5 SYSCFG external interrupt configuration register 4 (SYSCFG_EXTICR4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

    9.1.6 SYSCFG configuration register 2 (SYSCFG_CFGR2) . . . . . . . . . . . . 149

    9.1.7 SYSCFG register maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

    10 Direct memory access controller (DMA) . . . . . . . . . . . . . . . . . . . . . . . 15110.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    10.2 DMA main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    10.3 DMA functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15210.3.1 DMA transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

    10.3.2 Arbiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    10.3.3 DMA channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    10.3.4 Programmable data width, data alignment and endians . . . . . . . . . . . 154

    10.3.5 Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

    10.3.6 DMA interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

    10.3.7 DMA request mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

    10.4 DMA registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16010.4.1 DMA interrupt status register (DMA_ISR) . . . . . . . . . . . . . . . . . . . . . . 160

    10.4.2 DMA interrupt flag clear register (DMA_IFCR) . . . . . . . . . . . . . . . . . . 161

    10.4.3 DMA channel x configuration register (DMA_CCRx) (x = 1..5, where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . 162

    10.4.4 DMA channel x number of data register (DMA_CNDTRx) (x = 1..5, where x = channel number) 164

    10.4.5 DMA channel x peripheral address register (DMA_CPARx) (x = 1..5, where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    10.4.6 DMA channel x memory address register (DMA_CMARx) (x = 1..5, where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

    10.4.7 DMA channel selection register (DMA_CSELR) . . . . . . . . . . . . . . . . . 166

    10.4.8 DMA register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

    11 Interrupts and events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

  • Contents RM0360

    7/727 DocID025023 Rev 2

    11.1 Nested vectored interrupt controller (NVIC) . . . . . . . . . . . . . . . . . . . . . . 16911.1.1 NVIC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

    11.1.2 SysTick calibration value register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

    11.1.3 Interrupt and exception vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

    11.2 Extended interrupts and events controller (EXTI) . . . . . . . . . . . . . . . . . 17111.2.1 Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

    11.2.2 Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

    11.2.3 Event management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

    11.2.4 Functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

    11.2.5 External and internal interrupt/event line mapping . . . . . . . . . . . . . . . 174

    11.3 EXTI registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17511.3.1 Interrupt mask register (EXTI_IMR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

    11.3.2 Event mask register (EXTI_EMR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

    11.3.3 Rising trigger selection register (EXTI_RTSR) . . . . . . . . . . . . . . . . . . 175

    11.3.4 Falling trigger selection register (EXTI_FTSR) . . . . . . . . . . . . . . . . . . 176

    11.3.5 Software interrupt event register (EXTI_SWIER) . . . . . . . . . . . . . . . . 178

    11.3.6 Pending register (EXTI_PR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

    11.3.7 EXTI register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

    12 Analog-to-digital converter (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18112.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

    12.2 ADC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

    12.3 ADC pins and internal signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

    12.4 ADC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18412.4.1 Calibration (ADCAL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

    12.4.2 ADC on-off control (ADEN, ADDIS, ADRDY) . . . . . . . . . . . . . . . . . . . . 185

    12.4.3 ADC clock (CKMODE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186

    12.4.4 Configuring the ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

    12.4.5 Channel selection (CHSEL, SCANDIR) . . . . . . . . . . . . . . . . . . . . . . . . 188

    12.4.6 Programmable sampling time (SMP) . . . . . . . . . . . . . . . . . . . . . . . . . . 188

    12.4.7 Single conversion mode (CONT=0) . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

    12.4.8 Continuous conversion mode (CONT=1) . . . . . . . . . . . . . . . . . . . . . . . 189

    12.4.9 Starting conversions (ADSTART) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

    12.4.10 Timings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

    12.4.11 Stopping an ongoing conversion (ADSTP) . . . . . . . . . . . . . . . . . . . . . 191

    12.5 Conversion on external trigger and trigger polarity (EXTSEL, EXTEN) . 191

  • DocID025023 Rev 2 8/727

    RM0360 Contents

    20

    12.5.1 Discontinuous mode (DISCEN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

    12.5.2 Programmable resolution (RES) - fast conversion mode . . . . . . . . . . 193

    12.5.3 End of conversion, end of sampling phase (EOC, EOSMP flags) . . . . 193

    12.5.4 End of conversion sequence (EOSEQ flag) . . . . . . . . . . . . . . . . . . . . 195

    12.5.5 Example timing diagrams (single/continuous modes . . . . . . . . . . . . . . . . . hardware/software triggers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    12.6 Data management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19712.6.1 Data register and data alignment (ADC_DR, ALIGN) . . . . . . . . . . . . . 197

    12.6.2 ADC overrun (OVR, OVRMOD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

    12.6.3 Managing a sequence of data converted without using the DMA . . . . 198

    12.6.4 Managing converted data without using the DMA without overrun . . . 198

    12.6.5 Managing converted data using the DMA . . . . . . . . . . . . . . . . . . . . . . 198

    12.7 Low-power features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19912.7.1 Wait mode conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

    12.7.2 Auto-off mode (AUTOFF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

    12.8 Analog window watchdog (AWDEN, AWDSGL, AWDCH, AWD_HTR/LTR, AWD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

    12.9 Temperature sensor and internal reference voltage . . . . . . . . . . . . . . . . 203

    12.10 ADC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204

    12.11 ADC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20512.11.1 ADC interrupt and status register (ADC_ISR) . . . . . . . . . . . . . . . . . . . 205

    12.11.2 ADC interrupt enable register (ADC_IER) . . . . . . . . . . . . . . . . . . . . . . 206

    12.11.3 ADC control register (ADC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

    12.11.4 ADC configuration register 1 (ADC_CFGR1) . . . . . . . . . . . . . . . . . . . . 209

    12.11.5 ADC configuration register 2 (ADC_CFGR2) . . . . . . . . . . . . . . . . . . . . 213

    12.11.6 ADC sampling time register (ADC_SMPR) . . . . . . . . . . . . . . . . . . . . . 213

    12.11.7 ADC watchdog threshold register (ADC_TR) . . . . . . . . . . . . . . . . . . . 214

    12.11.8 ADC channel selection register (ADC_CHSELR) . . . . . . . . . . . . . . . . 215

    12.11.9 ADC data register (ADC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

    12.11.10 ADC common configuration register (ADC_CCR) . . . . . . . . . . . . . . . . 216

    12.11.11 ADC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

    13 Advanced-control timers (TIM1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21813.1 TIM1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

    13.2 TIM1 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

    13.3 TIM1 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22013.3.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

  • Contents RM0360

    9/727 DocID025023 Rev 2

    13.3.2 Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

    13.3.3 Repetition counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

    13.3.4 Clock sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

    13.3.5 Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

    13.3.6 Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240

    13.3.7 PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

    13.3.8 Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

    13.3.9 Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242

    13.3.10 PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

    13.3.11 Complementary outputs and dead-time insertion . . . . . . . . . . . . . . . . 247

    13.3.12 Using the break function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

    13.3.13 Clearing the OCxREF signal on an external event . . . . . . . . . . . . . . . 252

    13.3.14 6-step PWM generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

    13.3.15 One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

    13.3.16 Encoder interface mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

    13.3.17 Timer input XOR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

    13.3.18 Interfacing with Hall sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

    13.3.19 TIMx and external trigger synchronization . . . . . . . . . . . . . . . . . . . . . . 261

    13.3.20 Timer synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264

    13.3.21 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264

    13.4 TIM1 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26513.4.1 TIM1 control register 1 (TIM1_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 265

    13.4.2 TIM1 control register 2 (TIM1_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 266

    13.4.3 TIM1 slave mode control register (TIM1_SMCR) . . . . . . . . . . . . . . . . 268

    13.4.4 TIM1 DMA/interrupt enable register (TIM1_DIER) . . . . . . . . . . . . . . . . 270

    13.4.5 TIM1 status register (TIM1_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

    13.4.6 TIM1 event generation register (TIM1_EGR) . . . . . . . . . . . . . . . . . . . . 273

    13.4.7 TIM1 capture/compare mode register 1 (TIM1_CCMR1) . . . . . . . . . . 275

    13.4.8 TIM1 capture/compare mode register 2 (TIM1_CCMR2) . . . . . . . . . . 278

    13.4.9 TIM1 capture/compare enable register (TIM1_CCER) . . . . . . . . . . . . 279

    13.4.10 TIM1 counter (TIM1_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

    13.4.11 TIM1 prescaler (TIM1_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

    13.4.12 TIM1 auto-reload register (TIM1_ARR) . . . . . . . . . . . . . . . . . . . . . . . . 283

    13.4.13 TIM1 repetition counter register (TIM1_RCR) . . . . . . . . . . . . . . . . . . . 284

    13.4.14 TIM1 capture/compare register 1 (TIM1_CCR1) . . . . . . . . . . . . . . . . . 284

    13.4.15 TIM1 capture/compare register 2 (TIM1_CCR2) . . . . . . . . . . . . . . . . . 285

    13.4.16 TIM1 capture/compare register 3 (TIM1_CCR3) . . . . . . . . . . . . . . . . . 285

  • DocID025023 Rev 2 10/727

    RM0360 Contents

    20

    13.4.17 TIM1 capture/compare register 4 (TIM1_CCR4) . . . . . . . . . . . . . . . . . 286

    13.4.18 TIM1 break and dead-time register (TIM1_BDTR) . . . . . . . . . . . . . . . 286

    13.4.19 TIM1 DMA control register (TIM1_DCR) . . . . . . . . . . . . . . . . . . . . . . . 288

    13.4.20 TIM1 DMA address for full transfer (TIM1_DMAR) . . . . . . . . . . . . . . . 289

    13.4.21 TIM1 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

    14 General-purpose timers (TIM3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29214.1 TIM3 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

    14.2 TIM3 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

    14.3 TIM3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29314.3.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

    14.3.2 Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

    14.3.3 Clock sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306

    14.3.4 Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

    14.3.5 Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311

    14.3.6 PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313

    14.3.7 Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314

    14.3.8 Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314

    14.3.9 PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

    14.3.10 One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

    14.3.11 Clearing the OCxREF signal on an external event . . . . . . . . . . . . . . . 321

    14.3.12 Encoder interface mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

    14.3.13 Timer input XOR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

    14.3.14 Timers and external trigger synchronization . . . . . . . . . . . . . . . . . . . . 324

    14.3.15 Timer synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

    14.3.16 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

    14.4 TIM3 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33514.4.1 TIM3 control register 1 (TIM3_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 335

    14.4.2 TIM3 control register 2 (TIM3_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 337

    14.4.3 TIM3 slave mode control register (TIM3_SMCR) . . . . . . . . . . . . . . . . 338

    14.4.4 TIM3 DMA/Interrupt enable register (TIM3_DIER) . . . . . . . . . . . . . . . 340

    14.4.5 TIM3 status register (TIM3_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342

    14.4.6 TIM3 event generation register (TIM3_EGR) . . . . . . . . . . . . . . . . . . . . 344

    14.4.7 TIM3 capture/compare mode register 1 (TIM3_CCMR1) . . . . . . . . . . 345

    14.4.8 TIM3 capture/compare mode register 2 (TIM3_CCMR2) . . . . . . . . . . 348

    14.4.9 TIM3 capture/compare enable register (TIM3_CCER) . . . . . . . . . . . . 349

    14.4.10 TIM3 counter (TIM3_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

  • Contents RM0360

    11/727 DocID025023 Rev 2

    14.4.11 TIM3 prescaler (TIM3_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

    14.4.12 TIM3 auto-reload register (TIM3_ARR) . . . . . . . . . . . . . . . . . . . . . . . . 351

    14.4.13 TIM3 capture/compare register 1 (TIM3_CCR1) . . . . . . . . . . . . . . . . . 351

    14.4.14 TIM3 capture/compare register 2 (TIM3_CCR2) . . . . . . . . . . . . . . . . . 352

    14.4.15 TIM3 capture/compare register 3 (TIM3_CCR3) . . . . . . . . . . . . . . . . . 352

    14.4.16 TIM3 capture/compare register 4 (TIM3_CCR4) . . . . . . . . . . . . . . . . . 353

    14.4.17 TIM3 DMA control register (TIM3_DCR) . . . . . . . . . . . . . . . . . . . . . . . 353

    14.4.18 TIM3 DMA address for full transfer (TIM3_DMAR) . . . . . . . . . . . . . . . 354

    14.4.19 TIM3 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356

    15 Basic timer (TIM6/TIM7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35815.1 TIM6/TIM7 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358

    15.2 TIM6/TIM7 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358

    15.3 TIM6/TIM7 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35915.3.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

    15.3.2 Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361

    15.3.3 Clock source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

    15.3.4 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

    15.4 TIM6/TIM7 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36615.4.1 TIM6/TIM7 control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . . . 366

    15.4.2 TIM6/TIM7 DMA/Interrupt enable register (TIMx_DIER) . . . . . . . . . . . 367

    15.4.3 TIM6/TIM7 status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . . . 368

    15.4.4 TIM6/TIM7 event generation register (TIMx_EGR) . . . . . . . . . . . . . . . 368

    15.4.5 TIM6/TIM7 counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368

    15.4.6 TIM6/TIM7 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369

    15.4.7 TIM6/TIM7 auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . . . 369

    15.4.8 TIM6/TIM7 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370

    16 General-purpose timer (TIM14) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37116.1 TIM14 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

    16.2 TIM14 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

    16.3 TIM14 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37216.3.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

    16.3.2 Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

    16.3.3 Clock source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

    16.3.4 Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

  • DocID025023 Rev 2 12/727

    RM0360 Contents

    20

    16.3.5 Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

    16.3.6 Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    16.3.7 Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

    16.3.8 PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

    16.3.9 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382

    16.4 TIM14 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38316.4.1 TIM14 control register 1 (TIM14_CR1) . . . . . . . . . . . . . . . . . . . . . . . . 383

    16.4.2 TIM14 interrupt enable register (TIM14_DIER) . . . . . . . . . . . . . . . . . . 384

    16.4.3 TIM14 status register (TIM14_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384

    16.4.4 TIM14 event generation register (TIM14_EGR) . . . . . . . . . . . . . . . . . . 385

    16.4.5 TIM14 capture/compare mode register 1 (TIM14_CCMR1) . . . . . . . . 386

    16.4.6 TIM14 capture/compare enable register (TIM14_CCER) . . . . . . . . . . 388

    16.4.7 TIM14 counter (TIM14_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389

    16.4.8 TIM14 prescaler (TIM14_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389

    16.4.9 TIM14 auto-reload register (TIM14_ARR) . . . . . . . . . . . . . . . . . . . . . . 389

    16.4.10 TIM14 capture/compare register 1 (TIM14_CCR1) . . . . . . . . . . . . . . . 390

    16.4.11 TIM14 option register (TIM14_OR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 390

    16.4.12 TIM14 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391

    17 General-purpose timers (TIM15/16/17) . . . . . . . . . . . . . . . . . . . . . . . . 39317.1 TIM15/16/17 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

    17.2 TIM15 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

    17.3 TIM16 and TIM17 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

    17.4 TIM15/16/17 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39717.4.1 Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397

    17.4.2 Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399

    17.4.3 Repetition counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403

    17.4.4 Clock sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404

    17.4.5 Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

    17.4.6 Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410

    17.4.7 PWM input mode (only for TIM15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411

    17.4.8 Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411

    17.4.9 Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

    17.4.10 PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

    17.4.11 Complementary outputs and dead-time insertion . . . . . . . . . . . . . . . . 414

    17.4.12 Using the break function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417

    17.4.13 One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420

  • Contents RM0360

    13/727 DocID025023 Rev 2

    17.4.14 TIM15 external trigger synchronization . . . . . . . . . . . . . . . . . . . . . . . . 422

    17.4.15 Timer synchronization (TIM15) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

    17.4.16 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

    17.5 TIM15 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42517.5.1 TIM15 control register 1 (TIM15_CR1) . . . . . . . . . . . . . . . . . . . . . . . . 425

    17.5.2 TIM15 control register 2 (TIM15_CR2) . . . . . . . . . . . . . . . . . . . . . . . . 426

    17.5.3 TIM15 slave mode control register (TIM15_SMCR) . . . . . . . . . . . . . . 428

    17.5.4 TIM15 DMA/interrupt enable register (TIM15_DIER) . . . . . . . . . . . . . . 429

    17.5.5 TIM15 status register (TIM15_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430

    17.5.6 TIM15 event generation register (TIM15_EGR) . . . . . . . . . . . . . . . . . . 432

    17.5.7 TIM15 capture/compare mode register 1 (TIM15_CCMR1) . . . . . . . . 433

    17.5.8 TIM15 capture/compare enable register (TIM15_CCER) . . . . . . . . . . 436

    17.5.9 TIM15 counter (TIM15_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

    17.5.10 TIM15 prescaler (TIM15_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

    17.5.11 TIM15 auto-reload register (TIM15_ARR) . . . . . . . . . . . . . . . . . . . . . . 439

    17.5.12 TIM15 repetition counter register (TIM15_RCR) . . . . . . . . . . . . . . . . . 440

    17.5.13 TIM15 capture/compare register 1 (TIM15_CCR1) . . . . . . . . . . . . . . . 440

    17.5.14 TIM15 capture/compare register 2 (TIM15_CCR2) . . . . . . . . . . . . . . . 441

    17.5.15 TIM15 break and dead-time register (TIM15_BDTR) . . . . . . . . . . . . . 441

    17.5.16 TIM15 DMA control register (TIM15_DCR) . . . . . . . . . . . . . . . . . . . . . 444

    17.5.17 TIM15 DMA address for full transfer (TIM15_DMAR) . . . . . . . . . . . . . 444

    17.5.18 TIM15 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445

    17.6 TIM16 and TIM17 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44717.6.1 TIM16 and TIM17 control register 1 (TIM16_CR1 and TIM17_CR1) . . 447

    17.6.2 TIM16 and TIM17 control register 2 (TIM16_CR2 and TIM17_CR2) . . 448

    17.6.3 TIM16 and TIM17 DMA/interrupt enable register (TIM16_DIER and TIM17_DIER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449

    17.6.4 TIM16 and TIM17 status register (TIM16_SR and TIM17_SR) . . . . . . 450

    17.6.5 TIM16 and TIM17 event generation register (TIM16_EGR and TIM17_EGR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

    17.6.6 TIM16 and TIM17 capture/compare mode register 1 (TIM16_CCMR1 and TIM17_CCMR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

    17.6.7 TIM16 and TIM17 capture/compare enable register (TIM16_CCER and TIM17_CCER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456

    17.6.8 TIM16 and TIM17 counter (TIM16_CNT and TIM17_CNT) . . . . . . . . . 458

    17.6.9 TIM16 and TIM17 prescaler (TIM16_PSC and TIM17_PSC) . . . . . . . 458

    17.6.10 TIM16 and TIM17 auto-reload register (TIM16_ARR and TIM17_ARR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458

  • DocID025023 Rev 2 14/727

    RM0360 Contents

    20

    17.6.11 TIM16 and TIM17 repetition counter register (TIM16_RCR and TIM17_RCR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459

    17.6.12 TIM16 and TIM17 capture/compare register 1 (TIM16_CCR1 and TIM17_CCR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459

    17.6.13 TIM16 and TIM17 break and dead-time register (TIM16_BDTR and TIM17_BDTR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460

    17.6.14 TIM16 and TIM17 DMA control register (TIM16_DCR and TIM17_DCR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462

    17.6.15 TIM16 and TIM17 DMA address for full transfer (TIM16_DMAR and TIM17_DMAR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462

    17.6.16 TIM16 and TIM17 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464

    18 Infrared interface (IRTIM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466

    19 Independent watchdog (IWDG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46719.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467

    19.2 IWDG main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467

    19.3 IWDG functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46719.3.1 IWDG block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467

    19.3.2 Window option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468

    19.3.3 Hardware watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468

    19.3.4 Register access protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469

    19.3.5 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469

    19.4 IWDG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46919.4.1 Key register (IWDG_KR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469

    19.4.2 Prescaler register (IWDG_PR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470

    19.4.3 Reload register (IWDG_RLR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471

    19.4.4 Status register (IWDG_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472

    19.4.5 Window register (IWDG_WINR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473

    19.4.6 IWDG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474

    20 System window watchdog (WWDG) . . . . . . . . . . . . . . . . . . . . . . . . . . 47520.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

    20.2 WWDG main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

    20.3 WWDG functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47520.3.1 Enabling the watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476

    20.3.2 Controlling the downcounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476

    20.3.3 Advanced watchdog interrupt feature . . . . . . . . . . . . . . . . . . . . . . . . . 476

  • Contents RM0360

    15/727 DocID025023 Rev 2

    20.3.4 How to program the watchdog timeout . . . . . . . . . . . . . . . . . . . . . . . . 477

    20.3.5 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478

    20.4 WWDG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47820.4.1 Control register (WWDG_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478

    20.4.2 Configuration register (WWDG_CFR) . . . . . . . . . . . . . . . . . . . . . . . . . 479

    20.4.3 Status register (WWDG_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479

    20.4.4 WWDG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480

    21 Real-time clock (RTC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48121.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

    21.2 RTC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

    21.3 RTC implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482

    21.4 RTC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48321.4.1 RTC block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483

    21.4.2 GPIOs controlled by the RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484

    21.4.3 Clock and prescalers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486

    21.4.4 Real-time clock and calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

    21.4.5 Programmable alarm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

    21.4.6 Periodic auto-wakeup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488

    21.4.7 RTC initialization and configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 488

    21.4.8 Reading the calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490

    21.4.9 Resetting the RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491

    21.4.10 RTC synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491

    21.4.11 RTC reference clock detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492

    21.4.12 RTC smooth digital calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493

    21.4.13 Time-stamp function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

    21.4.14 Tamper detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

    21.4.15 Calibration clock output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496

    21.4.16 Alarm output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497

    21.5 RTC low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497

    21.6 RTC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497

    21.7 RTC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49821.7.1 RTC time register (RTC_TR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499

    21.7.2 RTC date register (RTC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500

    21.7.3 RTC control register (RTC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501

    21.7.4 RTC initialization and status register (RTC_ISR) . . . . . . . . . . . . . . . . . 504

  • DocID025023 Rev 2 16/727

    RM0360 Contents

    20

    21.7.5 RTC prescaler register (RTC_PRER) . . . . . . . . . . . . . . . . . . . . . . . . . 506

    21.7.6 RTC wakeup timer register (RTC_WUTR) . . . . . . . . . . . . . . . . . . . . . . 507

    21.7.7 RTC alarm A register (RTC_ALRMAR) . . . . . . . . . . . . . . . . . . . . . . . . 508

    21.7.8 RTC write protection register (RTC_WPR) . . . . . . . . . . . . . . . . . . . . . 509

    21.7.9 RTC sub second register (RTC_SSR) . . . . . . . . . . . . . . . . . . . . . . . . . 510

    21.7.10 RTC shift control register (RTC_SHIFTR) . . . . . . . . . . . . . . . . . . . . . . 511

    21.7.11 RTC timestamp time register (RTC_TSTR) . . . . . . . . . . . . . . . . . . . . . 512

    21.7.12 RTC timestamp date register (RTC_TSDR) . . . . . . . . . . . . . . . . . . . . 513

    21.7.13 RTC time-stamp sub second register (RTC_TSSSR) . . . . . . . . . . . . . 514

    21.7.14 RTC calibration register (RTC_CALR) . . . . . . . . . . . . . . . . . . . . . . . . . 515

    21.7.15 RTC tamper and alternate function configuration register (RTC_TAFCR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516

    21.7.16 RTC alarm A sub second register (RTC_ALRMASSR) . . . . . . . . . . . . 519

    21.7.17 RTC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520

    22 Inter-integrated circuit (I2C) interface . . . . . . . . . . . . . . . . . . . . . . . . . 52222.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522

    22.2 I2C main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522

    22.3 I2C implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523

    22.4 I2C functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52322.4.1 I2C block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524

    22.4.2 I2C2 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525

    22.4.3 I2C clock requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525

    22.4.4 Mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526

    22.4.5 I2C initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527

    22.4.6 Software reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531

    22.4.7 Data transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532

    22.4.8 I2C slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534

    22.4.9 I2C master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543

    22.4.10 I2C_TIMINGR register configuration examples . . . . . . . . . . . . . . . . . . 555

    22.4.11 SMBus specific features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556

    22.4.12 SMBus initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559

    22.4.13 SMBus: I2C_TIMEOUTR register configuration examples . . . . . . . . . 561

    22.4.14 SMBus slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562

    22.4.15 Error conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569

    22.4.16 DMA requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570

    22.4.17 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571

  • Contents RM0360

    17/727 DocID025023 Rev 2

    22.5 I2C low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571

    22.6 I2C interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572

    22.7 I2C registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57322.7.1 Control register 1 (I2C_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573

    22.7.2 Control register 2 (I2C_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577

    22.7.3 Own address 1 register (I2C_OAR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 580

    22.7.4 Own address 2 register (I2C_OAR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 581

    22.7.5 Timing register (I2C_TIMINGR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582

    22.7.6 Timeout register (I2C_TIMEOUTR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 583

    22.7.7 Interrupt and status register (I2C_ISR) . . . . . . . . . . . . . . . . . . . . . . . . 584

    22.7.8 Interrupt clear register (I2C_ICR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586

    22.7.9 PEC register (I2C_PECR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587

    22.7.10 Receive data register (I2C_RXDR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 588

    22.7.11 Transmit data register (I2C_TXDR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 588

    22.7.12 I2C register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589

    23 Universal synchronous asynchronous receiver transmitter (USART) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59123.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591

    23.2 USART main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591

    23.3 USART implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593

    23.4 USART functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59423.4.1 USART character description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596

    23.4.2 Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597

    23.4.3 Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600

    23.4.4 Baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606

    23.4.5 Tolerance of the USART receiver to clock deviation . . . . . . . . . . . . . . 608

    23.4.6 Auto baud rate detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609

    23.4.7 Multiprocessor communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609

    23.4.8 Parity control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612

    23.4.9 USART synchronous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612

    23.4.10 Single-wire half-duplex communication . . . . . . . . . . . . . . . . . . . . . . . . 615

    23.4.11 Continuous communication using DMA . . . . . . . . . . . . . . . . . . . . . . . . 615

    23.4.12 RS232 Hardware flow control and RS485 Driver Enable . . . . . . . . . . 618

    23.5 USART low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620

    23.6 USART interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620

  • DocID025023 Rev 2 18/727

    RM0360 Contents

    20

    23.7 USART registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62123.7.1 Control register 1 (USARTx_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621

    23.7.2 Control register 2 (USARTx_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624

    23.7.3 Control register 3 (USARTx_CR3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627

    23.7.4 Baud rate register (USARTx_BRR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 630

    23.7.5 Guard time and prescaler register (USARTx_GTPR) . . . . . . . . . . . . . 630

    23.7.6 Receiver timeout register (USARTx_RTOR) . . . . . . . . . . . . . . . . . . . . 631

    23.7.7 Request register (USARTx_RQR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631

    23.7.8 Interrupt & status register (USARTx_ISR) . . . . . . . . . . . . . . . . . . . . . . 632

    23.7.9 Interrupt flag clear register (USARTx_ICR) . . . . . . . . . . . . . . . . . . . . . 635

    23.7.10 Receive data register (USARTx_RDR) . . . . . . . . . . . . . . . . . . . . . . . . 636

    23.7.11 Transmit data register (USARTx_TDR) . . . . . . . . . . . . . . . . . . . . . . . . 637

    23.7.12 USART register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637

    24 Serial peripheral interface (SPI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63924.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639

    24.2 SPI main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639

    24.3 SPI implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640

    24.4 SPI functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64024.4.1 General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640

    24.4.2 Communications between one master and one slave . . . . . . . . . . . . . 641

    24.4.3 Standard multi-slave communication . . . . . . . . . . . . . . . . . . . . . . . . . . 643

    24.4.4 Slave select (NSS) pin management . . . . . . . . . . . . . . . . . . . . . . . . . . 644

    24.4.5 Communication formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646

    24.4.6 Configuration of SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 648

    24.4.7 Procedure for enabling SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649

    24.4.8 Data transmission and reception procedures . . . . . . . . . . . . . . . . . . . 649

    24.4.9 SPI status flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659

    24.4.10 SPI error flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660

    24.4.11 NSS pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661

    24.4.12 TI mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661

    24.4.13 CRC calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662

    24.5 SPI interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664

    24.6 SPI registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66524.6.1 SPI control register 1 (SPIx_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665

    24.6.2 SPI control register 2 (SPIx_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667

  • Contents RM0360

    19/727 DocID025023 Rev 2

    24.6.3 SPI status register (SPIx_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670

    24.6.4 SPI data register (SPIx_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672

    24.6.5 SPI CRC polynomial register (SPIx_CRCPR) . . . . . . . . . . . . . . . . . . . 672

    24.6.6 SPI Rx CRC register (SPIx_RXCRCR) . . . . . . . . . . . . . . . . . . . . . . . . 673

    24.6.7 SPI Tx CRC register (SPIx_TXCRCR) . . . . . . . . . . . . . . . . . . . . . . . . 673

    24.6.8 SPI register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674

    25 Universal serial bus full-speed device interface (USB) . . . . . . . . . . . 67525.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675

    25.2 USB main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675

    25.3 USB implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675

    25.4 USB functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67625.4.1 Description of USB blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677

    25.5 Programming considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67825.5.1 Generic USB device programming . . . . . . . . . . . . . . . . . . . . . . . . . . . 678

    25.5.2 System and power-on reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679

    25.5.3 Double-buffered endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683

    25.5.4 Isochronous transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686

    25.5.5 Suspend/Resume events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687

    25.6 USB registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68925.6.1 Common registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689

    25.6.2 Endpoint-specific registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696

    25.6.3 Buffer descriptor table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701

    25.6.4 USB register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705

    26 Debug support (DBG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70726.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707

    26.2 Reference ARM documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708

    26.3 Pinout and debug port pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70826.3.1 SWD port pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709

    26.3.2 SW-DP pin assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709

    26.3.3 Internal pull-up & pull-down on SWD pins . . . . . . . . . . . . . . . . . . . . . . 709

    26.4 ID codes and locking mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70926.4.1 MCU device ID code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710

    26.5 SWD port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71026.5.1 SWD protocol introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710

  • DocID025023 Rev 2 20/727

    RM0360 Contents

    20

    26.5.2 SWD protocol sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711

    26.5.3 SW-DP state machine (reset, idle states, ID code) . . . . . . . . . . . . . . . 712

    26.5.4 DP and AP read/write accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712

    26.5.5 SW-DP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713

    26.5.6 SW-AP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714

    26.6 Core debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714

    26.7 BPU (Break Point Unit) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71526.7.1 BPU functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715

    26.8 DWT (Data Watchpoint) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71526.8.1 DWT functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715

    26.8.2 DWT Program Counter Sample Register . . . . . . . . . . . . . . . . . . . . . . 715

    26.9 MCU debug component (DBGMCU) . . . . . . . . . . . . . . . . . . . . . . . . . . . 71526.9.1 Debug support for low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . 716

    26.9.2 Debug support for timers, watchdog and I2C . . . . . . . . . . . . . . . . . . . . 716

    26.9.3 Debug MCU configuration register (DBGMCU_CR) . . . . . . . . . . . . . . 717

    26.9.4 Debug MCU APB1 freeze register (DBGMCU_APB1_FZ) . . . . . . . . . 718

    26.9.5 Debug MCU APB2 freeze register (DBGMCU_APB2_FZ) . . . . . . . . . 720

    26.9.6 DBG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721

    27 Device electronic signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72227.1 Memory size data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722

    27.1.1 Flash size data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722

    28 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723

  • List of tables RM0360

    21/727 DocID025023 Rev 2

    List of tables

    Table 1. STM32F0x0 memory boundary addresses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Table 2. STM32F0x0 peripheral register boundary addresses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37Table 3. Boot modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Table 4. Flash memory organization (STM32F030x4, STM32F030x6, STM32F070x6 and

    STM32F030x8 devices) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Table 5. Flash memory organization (STM32F070xB, STM32F030xC devices) . . . . . . . . . . . . . . . 45Table 6. Flash memory read protection status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Table 7. Access status versus protection level and execution modes . . . . . . . . . . . . . . . . . . . . . . . 54Table 8. Flash interrupt request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Table 9. Flash interface - register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61Table 10. Option byte format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63Table 11. Option byte organization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63Table 12. Option byte map and ST production values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Table 13. CRC register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72Table 14. Low-power mode summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Table 15. Sleep-now. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Table 16. Sleep-on-exit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Table 17. Stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79Table 18. Standby mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Table 19. PWR register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84Table 20. RCC register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124Table 21. Port bit configuration table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127Table 22. GPIO register map and reset values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141Table 23. SYSCFG register map and reset values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150Table 24. Programmable data width & endian behavior (when bits PINC = MINC = 1) . . . . . . . . . . 155Table 25. DMA interrupt requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156Table 26. Summary of the DMA requests for each channel

    on STM32F030x4/6, STM32F070x6, STM32F070xB and STM32F030x8 devices . . . . . 158Table 27. Summary of the DMA requests for each channel on STM32F030xC devices . . . . . . . . . 159Table 28. DMA register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167Table 29. DMA register map and reset values (registers available on STM32F070xB and

    STM32F030xC devices only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

    Table 30. DMA register map and reset values(register available on STM32F030xC devices only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

    Table 31. Vector table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169Table 32. External interrupt/event controller register map and reset values. . . . . . . . . . . . . . . . . . . 180Table 33. ADC internal signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183Table 34. ADC pins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183Table 35. Latency between trigger and start of conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187Table 36. Configuring the trigger polarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192Table 37. External triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192Table 38. tSAR timings depending on resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193Table 39. Analog watchdog comparison. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Table 40. Analog watchdog channel selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Table 41. ADC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204Table 42. ADC register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217Table 43. Counting direction versus encoder signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

  • DocID025023 Rev 2 22/727

    RM0360 List of tables

    23

    Table 44. TIMx Internal trigger connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270Table 45. Output control bits for complementary OCx and OCxN channels with

    break feature. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282Table 46. TIM1 register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290Table 47. Counting direction versus encoder signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322Table 48. TIM3 internal trigger connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340Table 49. Output control bit for standard OCx channels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350Table 50. TIM3 register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356Table 51. TIM6/TIM7 register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370Table 52. Output control bit for standard OCx channels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388Table 53. TIM14 register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391Table 54. TIMx Internal trigger connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429Table 55. Output control bits for complementary OCx and OCxN channels with break feature . . . . 438Table 56. TIM15 register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445Table 57. Output control bits for complementary OCx and OCxN channels with break feature . . . . 457Table 58. TIM16 and TIM17 register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464Table 59. IWDG register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474Table 60. WWDG register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480Table 61. STM32F0x0 RTC implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482Table 62. RTC pin PC13 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485Table 63. LSE pin PC14 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485Table 64. LSE pin PC15 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486Table 65. Effect of low-power modes on RTC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497Table 66. Interrupt control bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498Table 67. RTC register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520Table 68. STM32F0x0 I2C implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523Table 69. Comparison of analog vs. digital filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527Table 70. I2C-SMBUS specification data setup and hold times . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530Table 71. I2C configuration table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534Table 72. I2C-SMBUS specification clock timings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544Table 73. Examples of timings settings for fI2CCLK = 8 MHz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555Table 74. Examples of timings settings for fI2CCLK = 16 MHz . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555Table 75. Examples of timings settings for fI2CCLK = 48 MHz . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556Table 76. SMBus timeout specifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558Table 77. SMBUS with PEC configuration table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560Table 78. Examples of TIMEOUTA settings for various I2CCLK frequencies

    (max tTIMEOUT = 25 ms) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561Table 79. Examples of TIMEOUTB settings for various I2CCLK frequencies . . . . . . . . . . . . . . . . . 562Table 80. Examples of TIMEOUTA settings for various I2CCLK frequencies

    (max tIDLE = 50 μs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562Table 81. low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571Table 82. I2C Interrupt requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572Table 83. I2C register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589Table 84. STM32F0x0 USART implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593Table 85. STM32F0x0 USART implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594Table 86. Noise detection from sampled data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605Table 87. Error calculation for programmed baud rates at fCK = 48 MHz in both cases of

    oversampling by 16 or by 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607Table 88. Tolerance of the USART receiver when BRR [3:0] = 0000. . . . . . . . . . . . . . . . . . . . . . . . 608Table 89. Tolerance of the USART receiver when BRR [3:0] is different from 0000 . . . . . . . . . . . . 608Table 90. Frame formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612Table 91. Effect of low-power modes on the USART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620

  • List of tables RM0360

    23/727 DocID025023 Rev 2

    Table 92. USART interrupt requests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620Table 93. USART register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637Table 94. STM32F0x0 SPI implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640Table 95. SPI interrupt requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664Table 96. SPI register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674Table 97. STM32F0x0 USB implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675Table 98. Double-buffering buffer flag definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684Table 99. Bulk double-buffering memory buffers usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685Table 100. Isochronous memory buffers usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686Table 101. Resume event detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688Table 102. Reception status encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699Table 103. Endpoint type encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700Table 104. Endpoint kind meaning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700Table 105. Transmission status encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700Table 106. Definition of allocated buffer memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704Table 107. USB register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705Table 108. SW debug port pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709Table 109. Packet request (8-bits) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711Table 110. ACK response (3 bits). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711Table 111. DATA transfer (33 bits) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711Table 112. SW-DP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713Table 113. 32-bit debug port registers addressed through the shifted value A[3:2] . . . . . . . . . . . . . . 714Table 114. Core debug registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714Table 115. DBG register map and reset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721Table 116. Document revision history. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723

  • DocID025023 Rev 2 24/727

    RM0360 List of figures

    29

    List of figures

    Figure 1. System architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Figure 2. Memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Figure 3. Programming procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Figure 4. Flash memory Page Erase procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Figure 5. Flash memory Mass Erase procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Figure 6. CRC calculation unit block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Figure 7. Power supply overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Figure 8. Power on reset/power down reset waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74Figure 9. Simplified diagram of the reset circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Figure 10. Clock tree (STM32F030x4, STM32F030x6 and STM32F030x8 devices) . . . . . . . . . . . . . 88Figure 11. Clock tree (STM32F070x6, STM32F070xB and STM32F030xC). . . . . . . . . . . . . . . . . . . . 89Figure 12. HSE/ LSE clock sources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90Figure 13. Frequency measurement with TIM14 in capture mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . 96Figure 14. Basic structure of an I/O port bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127Figure 15. Input floating/pull up/pull down configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131Figure 16. Output configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1