stm32 reference manual

1072
April 2010 Doc ID 13902 Rev 11 1/1072 RM0008 Reference manual STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and STM32F107xx advanced ARM-based 32-bit MCUs Introduction This reference manual targets application developers. It provides complete information on how to use the STM32F101xx, STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx microcontroller memory and peripherals. The STM32F101xx, STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx will be referred to as STM32F10xxx throughout the document, unless otherwise specified. The STM32F10xxx is a family of microcontrollers with different memory sizes, packages and peripherals. For ordering information, mechanical and electrical device characteristics please refer to the low-, medium-, high- and XL-density STM32F101xx and STM32F103xx datasheets, to the low- and medium-density STM32F102xx datasheets and to the STM32F105xx/STM32F107xx connectivity line datasheet. For information on programming, erasing and protection of the internal Flash memory please refer to: RM0042, the Flash programming manual for low-, medium- high-density and connectivity line STM32F10xxx devices PM0068, the Flash programming manual for XL-density STM32F10xxx devices. For information on the ARM Cortex™-M3 core, please refer to the STM32F10xxx Cortex™- M3 programming manual (PM0056). Related documents Available from www.st.com: STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx/STM32F107xx and datasheets STM32F10xxx Cortex™-M3 programming manual (PM0056) STM32F10xxx Flash programming manual (PM0042) STM32F10xxx XL-density Flash programming manual (PM0068) www.st.com

Upload: roberto-navoni

Post on 17-May-2015

2.738 views

Category:

Technology


64 download

DESCRIPTION

This documents contains useful documentation for developing driver

TRANSCRIPT

  • 1. RM0008Reference manual STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xxand STM32F107xx advanced ARM-based 32-bit MCUs Introduction This reference manual targets application developers. It provides complete information on how to use the STM32F101xx, STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx microcontroller memory and peripherals. The STM32F101xx, STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx will be referred to as STM32F10xxx throughout the document, unless otherwise specified. The STM32F10xxx is a family of microcontrollers with different memory sizes, packages and peripherals. For ordering information, mechanical and electrical device characteristics please refer to the low-, medium-, high- and XL-density STM32F101xx and STM32F103xx datasheets, to the low- and medium-density STM32F102xx datasheets and to the STM32F105xx/STM32F107xx connectivity line datasheet. For information on programming, erasing and protection of the internal Flash memory please refer to: RM0042, the Flash programming manual for low-, medium- high-density andconnectivity line STM32F10xxx devices PM0068, the Flash programming manual for XL-density STM32F10xxx devices. For information on the ARM Cortex-M3 core, please refer to the STM32F10xxx Cortex- M3 programming manual (PM0056). Related documents Available from www.st.com: STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx/STM32F107xx and datasheets STM32F10xxx Cortex-M3 programming manual (PM0056) STM32F10xxx Flash programming manual (PM0042) STM32F10xxx XL-density Flash programming manual (PM0068)April 2010 Doc ID 13902 Rev 11 1/1072www.st.com

2. Contents RM0008Contents1Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 1.1List of abbreviations for registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 1.2Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 1.3Peripheral availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402Memory and bus architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.1System architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.2Memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 2.3Memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442.3.1 Embedded SRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472.3.2 Bit banding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472.3.3 Embedded Flash memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2.4Boot configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543CRC calculation unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.1CRC introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.2CRC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.3CRC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3.4CRC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573.4.1 Data register (CRC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573.4.2 Independent data register (CRC_IDR) . . . . . . . . . . . . . . . . . . . . . . . . . 573.4.3 Control register (CRC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583.4.4 CRC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584Power control (PWR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4.1Power supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594.1.1 Independent A/D converter supply and reference voltage . . . . . . . . . . . 604.1.2 Battery backup domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614.1.3 Voltage regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 4.2Power supply supervisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624.2.1 Power on reset (POR)/power down reset (PDR) . . . . . . . . . . . . . . . . . . 624.2.2 Programmable voltage detector (PVD) . . . . . . . . . . . . . . . . . . . . . . . . . 62 4.3Low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642/1072 Doc ID 13902 Rev 11 3. RM0008Contents4.3.1Slowing down system clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644.3.2Peripheral clock gating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654.3.3Sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654.3.4Stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664.3.5Standby mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674.3.6Auto-wakeup (AWU) from low-power mode . . . . . . . . . . . . . . . . . . . . . . 69 4.4Power control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694.4.1Power control register (PWR_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694.4.2Power control/status register (PWR_CSR) . . . . . . . . . . . . . . . . . . . . . . 714.4.3PWR register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725Backup registers (BKP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.1BKP introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.2BKP main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.3BKP functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.1Tamper detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.2RTC calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 5.4BKP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755.4.1Backup data register x (BKP_DRx) (x = 1 ..42) . . . . . . . . . . . . . . . . . . . 755.4.2RTC clock calibration register (BKP_RTCCR) . . . . . . . . . . . . . . . . . . . . 755.4.3Backup control register (BKP_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765.4.4Backup control/status register (BKP_CSR) . . . . . . . . . . . . . . . . . . . . . . 765.4.5BKP register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 776Low-, medium-, high- and XL-density reset and clock control (RCC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 6.1Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 816.1.1System reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 816.1.2Power reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826.1.3Backup domain reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 6.2Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836.2.1HSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 856.2.2HSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866.2.3PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866.2.4LSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876.2.5LSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876.2.6System clock (SYSCLK) selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Doc ID 13902 Rev 113/1072 4. ContentsRM0008 6.2.7 Clock security system (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 6.2.8 RTC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 6.2.9 Watchdog clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 6.2.10Clock-out capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 6.3 RCC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 6.3.1 Clock control register (RCC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 6.3.2 Clock configuration register (RCC_CFGR) . . . . . . . . . . . . . . . . . . . . . . 92 6.3.3 Clock interrupt register (RCC_CIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.3.4 APB2 peripheral reset register (RCC_APB2RSTR) . . . . . . . . . . . . . . . 97 6.3.5 APB1 peripheral reset register (RCC_APB1RSTR) . . . . . . . . . . . . . . . 99 6.3.6 AHB peripheral clock enable register (RCC_AHBENR) . . . . . . . . . . . 102 6.3.7 APB2 peripheral clock enable register (RCC_APB2ENR) . . . . . . . . . . 103 6.3.8 APB1 peripheral clock enable register (RCC_APB1ENR) . . . . . . . . . . 105 6.3.9 Backup domain control register (RCC_BDCR) . . . . . . . . . . . . . . . . . . 108 6.3.10Control/status register (RCC_CSR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 6.3.11RCC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1117Connectivity line devices: reset and clock control (RCC) . . . . . . . . . 112 7.1 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 7.1.1 System reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 7.1.2 Power reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 7.1.3 Backup domain reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 7.2 Clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 7.2.1 HSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 7.2.2 HSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 7.2.3 PLLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 7.2.4 LSE clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 7.2.5 LSI clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 7.2.6 System clock (SYSCLK) selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 7.2.7 Clock security system (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 7.2.8 RTC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 7.2.9 Watchdog clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 7.2.10Clock-out capability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 7.3 RCC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 7.3.1 Clock control register (RCC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 7.3.2 Clock configuration register (RCC_CFGR) . . . . . . . . . . . . . . . . . . . . . 123 7.3.3 Clock interrupt register (RCC_CIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 1264/1072 Doc ID 13902 Rev 11 5. RM0008Contents 7.3.4 APB2 peripheral reset register (RCC_APB2RSTR) . . . . . . . . . . . . . . 129 7.3.5 APB1 peripheral reset register (RCC_APB1RSTR) . . . . . . . . . . . . . . 130 7.3.6 AHB Peripheral Clock enable register (RCC_AHBENR) . . . . . . . . . . . 133 7.3.7 APB2 peripheral clock enable register (RCC_APB2ENR) . . . . . . . . . . 134 7.3.8 APB1 peripheral clock enable register (RCC_APB1ENR) . . . . . . . . . . 136 7.3.9 Backup domain control register (RCC_BDCR) . . . . . . . . . . . . . . . . . . 138 7.3.10Control/status register (RCC_CSR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 7.3.11AHB peripheral clock reset register (RCC_AHBRSTR) . . . . . . . . . . . . 141 7.3.12Clock configuration register2 (RCC_CFGR2) . . . . . . . . . . . . . . . . . . . 142 7.3.13RCC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1448General-purpose and alternate-function I/Os (GPIOs and AFIOs) . . 146 8.1 GPIO functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 8.1.1 General-purpose I/O (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 8.1.2 Atomic bit set or reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 8.1.3 External interrupt/wakeup lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 8.1.4 Alternate functions (AF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 8.1.5 Software remapping of I/O alternate functions . . . . . . . . . . . . . . . . . . 149 8.1.6 GPIO locking mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 8.1.7 Input configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 8.1.8 Output configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 8.1.9 Alternate function configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 8.1.10Analog configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 8.1.11Peripherals GPIO configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 8.2 GPIO registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 8.2.1 Port configuration register low (GPIOx_CRL) (x=A..G) . . . . . . . . . . . . 157 8.2.2 Port configuration register high (GPIOx_CRH) (x=A..G) . . . . . . . . . . . 158 8.2.3 Port input data register (GPIOx_IDR) (x=A..G) . . . . . . . . . . . . . . . . . . 158 8.2.4 Port output data register (GPIOx_ODR) (x=A..G) . . . . . . . . . . . . . . . . 159 8.2.5 Port bit set/reset register (GPIOx_BSRR) (x=A..G) . . . . . . . . . . . . . . . 159 8.2.6 Port bit reset register (GPIOx_BRR) (x=A..G) . . . . . . . . . . . . . . . . . . . 160 8.2.7 Port configuration lock register (GPIOx_LCKR) (x=A..G) . . . . . . . . . . 160 8.3 Alternate function I/O and debug configuration (AFIO) . . . . . . . . . . . . . 161 8.3.1 Using OSC32_IN/OSC32_OUT pins as GPIO ports PC14/PC15 . . . . 161 8.3.2 Using OSC_IN/OSC_OUT pins as GPIO ports PD0/PD1 . . . . . . . . . . 161 8.3.3 CAN1 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 8.3.4 CAN2 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Doc ID 13902 Rev 11 5/1072 6. Contents RM0008 8.3.5 JTAG/SWD alternate function remapping . . . . . . . . . . . . . . . . . . . . . . 162 8.3.6 ADC alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 8.3.7 Timer alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 8.3.8 USART alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . 166 8.3.9 I2C1 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 8.3.10SPI1 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 8.3.11SPI3/I2S3 alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . 167 8.3.12Ethernet alternate function remapping . . . . . . . . . . . . . . . . . . . . . . . . 167 8.4 AFIO registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 8.4.1 Event control register (AFIO_EVCR) . . . . . . . . . . . . . . . . . . . . . . . . . . 169 8.4.2 AF remap and debug I/O configuration register (AFIO_MAPR) . . . . . . 170 8.4.3 External interrupt configuration register 1 (AFIO_EXTICR1) . . . . . . . . 176 8.4.4 External interrupt configuration register 2 (AFIO_EXTICR2) . . . . . . . . 176 8.4.5 External interrupt configuration register 3 (AFIO_EXTICR3) . . . . . . . . 177 8.4.6 External interrupt configuration register 4 (AFIO_EXTICR4) . . . . . . . . 177 8.4.7 AF remap and debug I/O configuration register2 (AFIO_MAPR2) . . . . 178 8.5 GPIO and AFIO register maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1799Interrupts and events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 9.1 Nested vectored interrupt controller (NVIC) . . . . . . . . . . . . . . . . . . . . . . 181 9.1.1 SysTick calibration value register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 9.1.2 Interrupt and exception vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 9.2 External interrupt/event controller (EXTI) . . . . . . . . . . . . . . . . . . . . . . . . 189 9.2.1 Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 9.2.2 Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 9.2.3 Wakeup event management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 9.2.4 Functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 9.2.5 External interrupt/event line mapping . . . . . . . . . . . . . . . . . . . . . . . . . 191 9.3 EXTI registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 9.3.1 Interrupt mask register (EXTI_IMR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 9.3.2 Event mask register (EXTI_EMR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 9.3.3 Rising trigger selection register (EXTI_RTSR) . . . . . . . . . . . . . . . . . . 194 9.3.4 Falling trigger selection register (EXTI_FTSR) . . . . . . . . . . . . . . . . . . 194 9.3.5 Software interrupt event register (EXTI_SWIER) . . . . . . . . . . . . . . . . . 195 9.3.6 Pending register (EXTI_PR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 9.3.7 EXTI register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1966/1072Doc ID 13902 Rev 11 7. RM0008 Contents10 DMA controller (DMA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 10.1DMA introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 10.2DMA main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 10.3DMA functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 10.3.1DMA transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 10.3.2Arbiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 10.3.3DMA channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 10.3.4Programmable data width, data alignment and endians . . . . . . . . . . . 202 10.3.5Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 10.3.6Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 10.3.7DMA request mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 10.4DMA registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 10.4.1DMA interrupt status register (DMA_ISR) . . . . . . . . . . . . . . . . . . . . . . 207 10.4.2DMA interrupt flag clear register (DMA_IFCR) . . . . . . . . . . . . . . . . . . 208 10.4.3DMA channel x configuration register (DMA_CCRx) (x = 1..7, where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 10.4.4DMA channel x number of data register (DMA_CNDTRx) (x = 1..7), where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 10.4.5DMA channel x peripheral address register (DMA_CPARx) (x = 1..7), where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 10.4.6DMA channel x memory address register (DMA_CMARx) (x = 1..7), where x = channel number) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 10.4.7DMA register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21211 Analog-to-digital converter (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 11.1ADC introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 11.2ADC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 11.3ADC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 11.3.1ADC on-off control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 11.3.2ADC clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 11.3.3Channel selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 11.3.4Single conversion mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 11.3.5Continuous conversion mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 11.3.6Timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 11.3.7Analog watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 11.3.8Scan mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 11.3.9Injected channel management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220Doc ID 13902 Rev 11 7/1072 8. ContentsRM000811.3.10 Discontinuous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 11.4 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 11.5 Data alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 11.6 Channel-by-channel programmable sample time . . . . . . . . . . . . . . . . . . 223 11.7 Conversion on external trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 11.8 DMA request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 11.9 Dual ADC mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22611.9.1Injected simultaneous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22811.9.2Regular simultaneous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22811.9.3Fast interleaved mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22911.9.4Slow interleaved mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22911.9.5Alternate trigger mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23011.9.6Independent mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23111.9.7Combined regular/injected simultaneous mode . . . . . . . . . . . . . . . . . . 23111.9.8Combined regular simultaneous + alternate trigger mode . . . . . . . . . . 23111.9.9Combined injected simultaneous + interleaved . . . . . . . . . . . . . . . . . . 232 11.10 Temperature sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 11.11 ADC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 11.12 ADC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23511.12.1 ADC status register (ADC_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23511.12.2 ADC control register 1 (ADC_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . 23611.12.3 ADC control register 2 (ADC_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . 23811.12.4 ADC sample time register 1 (ADC_SMPR1) . . . . . . . . . . . . . . . . . . . . 24111.12.5 ADC sample time register 2 (ADC_SMPR2) . . . . . . . . . . . . . . . . . . . . 24211.12.6 ADC injected channel data offset register x (ADC_JOFRx)(x=1..4) . . 24211.12.7 ADC watchdog high threshold register (ADC_HTR) . . . . . . . . . . . . . . 24311.12.8 ADC watchdog low threshold register (ADC_LTR) . . . . . . . . . . . . . . . 24311.12.9 ADC regular sequence register 1 (ADC_SQR1) . . . . . . . . . . . . . . . . . 24411.12.10 ADC regular sequence register 2 (ADC_SQR2) . . . . . . . . . . . . . . . . . 24411.12.11 ADC regular sequence register 3 (ADC_SQR3) . . . . . . . . . . . . . . . . . 24511.12.12 ADC injected sequence register (ADC_JSQR) . . . . . . . . . . . . . . . . . . 24611.12.13 ADC injected data register x (ADC_JDRx) (x= 1..4) . . . . . . . . . . . . . . 24611.12.14 ADC regular data register (ADC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . 24711.12.15 ADC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24712 Digital-to-analog converter (DAC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2498/1072Doc ID 13902 Rev 11 9. RM0008 Contents 12.1 DAC introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 12.2 DAC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 12.3 DAC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25112.3.1DAC channel enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25112.3.2DAC output buffer enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25112.3.3DAC data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25112.3.4DAC conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25212.3.5DAC output voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25312.3.6DAC trigger selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25312.3.7DMA request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25412.3.8Noise generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25412.3.9Triangle-wave generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 12.4 Dual DAC channel conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25612.4.1Independent trigger without wave generation . . . . . . . . . . . . . . . . . . . 25612.4.2Independent trigger with same LFSR generation . . . . . . . . . . . . . . . . 25712.4.3Independent trigger with different LFSR generation . . . . . . . . . . . . . . 25712.4.4Independent trigger with same triangle generation . . . . . . . . . . . . . . . 25712.4.5Independent trigger with different triangle generation . . . . . . . . . . . . . 25812.4.6Simultaneous software start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25812.4.7Simultaneous trigger without wave generation . . . . . . . . . . . . . . . . . . 25812.4.8Simultaneous trigger with same LFSR generation . . . . . . . . . . . . . . . 25912.4.9Simultaneous trigger with different LFSR generation . . . . . . . . . . . . . 25912.4.10 Simultaneous trigger with same triangle generation . . . . . . . . . . . . . . 25912.4.11 Simultaneous trigger with different triangle generation . . . . . . . . . . . . 260 12.5 DAC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26012.5.1DAC control register (DAC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26012.5.2DAC software trigger register (DAC_SWTRIGR) . . . . . . . . . . . . . . . . . 26312.5.3DAC channel1 12-bit right-aligned data holding register(DAC_DHR12R1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26412.5.4DAC channel1 12-bit left aligned data holding register(DAC_DHR12L1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26412.5.5DAC channel1 8-bit right aligned data holding register(DAC_DHR8R1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26412.5.6DAC channel2 12-bit right aligned data holding register(DAC_DHR12R2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26512.5.7DAC channel2 12-bit left aligned data holding register(DAC_DHR12L2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265Doc ID 13902 Rev 11 9/1072 10. ContentsRM000812.5.8DAC channel2 8-bit right-aligned data holding register(DAC_DHR8R2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26512.5.9Dual DAC 12-bit right-aligned data holding register(DAC_DHR12RD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26612.5.10 DUAL DAC 12-bit left aligned data holding register(DAC_DHR12LD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26612.5.11 DUAL DAC 8-bit right aligned data holding register(DAC_DHR8RD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26712.5.12 DAC channel1 data output register (DAC_DOR1) . . . . . . . . . . . . . . . . 26712.5.13 DAC channel2 data output register (DAC_DOR2) . . . . . . . . . . . . . . . . 26712.5.14 DAC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26813 Advanced-control timers (TIM1&TIM8) . . . . . . . . . . . . . . . . . . . . . . . . 269 13.1 TIM1&TIM8 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 13.2 TIM1&TIM8 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 13.3 TIM1&TIM8 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27213.3.1Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27213.3.2Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27313.3.3Repetition counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28113.3.4Clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28313.3.5Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28513.3.6Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28713.3.7PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28813.3.8Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28913.3.9Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29013.3.10 PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29113.3.11 Complementary outputs and dead-time insertion . . . . . . . . . . . . . . . . 29413.3.12 Using the break function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29513.3.13 Clearing the OCxREF signal on an external event . . . . . . . . . . . . . . . 29813.3.14 6-step PWM generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29913.3.15 One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30013.3.16 Encoder interface mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30113.3.17 Timer input XOR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30413.3.18 Interfacing with Hall sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30413.3.19 TIMx and external trigger synchronization . . . . . . . . . . . . . . . . . . . . . . 30613.3.20 Timer synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30913.3.21 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 13.4 TIM1&TIM8 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31010/1072Doc ID 13902 Rev 11 11. RM0008 Contents13.4.1TIM1&TIM8 control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . . 31013.4.2TIM1&TIM8 control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . . 31113.4.3TIM1&TIM8 slave mode control register (TIMx_SMCR) . . . . . . . . . . . 31313.4.4TIM1&TIM8 DMA/interrupt enable register (TIMx_DIER) . . . . . . . . . . 31513.4.5TIM1&TIM8 status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . . 31713.4.6TIM1&TIM8 event generation register (TIMx_EGR) . . . . . . . . . . . . . . 31813.4.7TIM1&TIM8 capture/compare mode register 1 (TIMx_CCMR1) . . . . . 32013.4.8TIM1&TIM8 capture/compare mode register 2 (TIMx_CCMR2) . . . . . 32313.4.9TIM1&TIM8 capture/compare enable register (TIMx_CCER) . . . . . . . 32413.4.10 TIM1&TIM8 counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32713.4.11 TIM1&TIM8 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . 32713.4.12 TIM1&TIM8 auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . . . 32713.4.13 TIM1&TIM8 repetition counter register (TIMx_RCR) . . . . . . . . . . . . . . 32813.4.14 TIM1&TIM8 capture/compare register 1 (TIMx_CCR1) . . . . . . . . . . . . 32813.4.15 TIM1&TIM8 capture/compare register 2 (TIMx_CCR2) . . . . . . . . . . . . 32913.4.16 TIM1&TIM8 capture/compare register 3 (TIMx_CCR3) . . . . . . . . . . . . 32913.4.17 TIM1&TIM8 capture/compare register 4 (TIMx_CCR4) . . . . . . . . . . . . 33013.4.18 TIM1&TIM8 break and dead-time register (TIMx_BDTR) . . . . . . . . . . 33013.4.19 TIM1&TIM8 DMA control register (TIMx_DCR) . . . . . . . . . . . . . . . . . . 33213.4.20 TIM1&TIM8 DMA address for full transfer (TIMx_DMAR) . . . . . . . . . . 33313.4.21 TIM1&TIM8 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33314 General-purpose timer (TIM2 to TIM5) . . . . . . . . . . . . . . . . . . . . . . . . . 335 14.1 TIM2 to TIM5 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 14.2 TIMx main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 14.3 TIMx functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33714.3.1Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33714.3.2Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33914.3.3Clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34714.3.4Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35014.3.5Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35214.3.6PWM input mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35314.3.7Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35414.3.8Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35414.3.9PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35514.3.10 One-pulse mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35814.3.11 Clearing the OCxREF signal on an external event . . . . . . . . . . . . . . . 359 Doc ID 13902 Rev 1111/1072 12. ContentsRM000814.3.12 Encoder interface mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36014.3.13 Timer input XOR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36214.3.14 Timers and external trigger synchronization . . . . . . . . . . . . . . . . . . . . 36214.3.15 Timer synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36514.3.16 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 14.4 TIMx2 to TIM5 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37114.4.1TIMx control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 37114.4.2TIMx control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 37214.4.3TIMx slave mode control register (TIMx_SMCR) . . . . . . . . . . . . . . . . . 37314.4.4TIMx DMA/Interrupt enable register (TIMx_DIER) . . . . . . . . . . . . . . . . 37614.4.5TIMx status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37714.4.6TIMx event generation register (TIMx_EGR) . . . . . . . . . . . . . . . . . . . . 37814.4.7TIMx capture/compare mode register 1 (TIMx_CCMR1) . . . . . . . . . . . 37914.4.8Capture/compare mode register 2 (TIMx_CCMR2) . . . . . . . . . . . . . . . 38314.4.9TIMx capture/compare enable register (TIMx_CCER) . . . . . . . . . . . . . 38414.4.10 TIMx counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38514.4.11 TIMx prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38614.4.12 TIMx auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . . . . . . . . 38614.4.13 TIMx capture/compare register 1 (TIMx_CCR1) . . . . . . . . . . . . . . . . . 38614.4.14 TIMx capture/compare register 2 (TIMx_CCR2) . . . . . . . . . . . . . . . . . 38714.4.15 TIMx capture/compare register 3 (TIMx_CCR3) . . . . . . . . . . . . . . . . . 38714.4.16 TIMx capture/compare register 4 (TIMx_CCR4) . . . . . . . . . . . . . . . . . 38814.4.17 TIMx DMA control register (TIMx_DCR) . . . . . . . . . . . . . . . . . . . . . . . 38814.4.18 TIMx DMA address for full transfer (TIMx_DMAR) . . . . . . . . . . . . . . . 38914.4.19 TIMx register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38915 General-purpose timers (TIM9 to TIM14) . . . . . . . . . . . . . . . . . . . . . . . 391 15.1 TIMx introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 15.2 General-purpose timers TIM9 and TIM12 . . . . . . . . . . . . . . . . . . . . . . . 392 15.3 General-purpose timers TIM10/TIM11 and TIM13/TIM14 . . . . . . . . . . . 393 15.4 TIMx functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39415.4.1Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39415.4.2Counter modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39515.4.3Clock selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39815.4.4Capture/compare channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40015.4.5Input capture mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40115.4.6PWM input mode (only for TIM9/12) . . . . . . . . . . . . . . . . . . . . . . . . . . 40212/1072Doc ID 13902 Rev 11 13. RM0008Contents15.4.7Forced output mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40315.4.8Output compare mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40415.4.9PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40515.4.10 One-pulse mode (only for TIM9/12) . . . . . . . . . . . . . . . . . . . . . . . . . . . 40715.4.11 TIM9/12 and external trigger synchronization . . . . . . . . . . . . . . . . . . . 40915.4.12 Timer synchronization (TIM9/12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41115.4.13 Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411 15.5 TIM9 and TIM12 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41215.5.1TIM9/12 control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . . . . . 41215.5.2TIM9/12 control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . . . . . 41315.5.3TIM9/12 slave mode control register (TIMx_SMCR) . . . . . . . . . . . . . . 41415.5.4TIM9/12 Interrupt enable register (TIMx_DIER) . . . . . . . . . . . . . . . . . 41515.5.5TIM9/12 status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 41615.5.6TIM9/12 event generation register (TIMx_EGR) . . . . . . . . . . . . . . . . . 41715.5.7TIM9/12 capture/compare mode register 1 (TIMx_CCMR1) . . . . . . . . 41815.5.8TIM9/12 capture/compare enable register (TIMx_CCER) . . . . . . . . . . 42115.5.9TIM9/12 counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42215.5.10 TIM9/12 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42215.5.11 TIM9/12 auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . . . . . 42215.5.12 TIM9/12 capture/compare register 1 (TIMx_CCR1) . . . . . . . . . . . . . . 42315.5.13 TIM9/12 capture/compare register 2 (TIMx_CCR2) . . . . . . . . . . . . . . 42315.5.14 TIM9/12 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424 15.6 TIM10/11 and TIM13/14 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42415.6.1TIM10/11 and TIM13/14 control register 1 (TIMx_CR1) . . . . . . . . . . . 42415.6.2TIMx control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 42515.6.3TIM10/11 and TIM13/14 DMA/Interrupt enable register (TIMx_DIER) 42615.6.4TIM10/11 and TIM13/14 status register (TIMx_SR) . . . . . . . . . . . . . . 42615.6.5TIM10/11 and TIM13/14 event generation register (TIMx_EGR) . . . . . 42715.6.6TIM10/11 and TIM13/14 capture/compare mode register 1(TIMx_CCMR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42815.6.7TIM10/11 and TIM13/14 capture/compare enable register(TIMx_CCER) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43115.6.8TIM10/11 and TIM13/14 counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . 43215.6.9TIM10/11 and TIM13/14 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . 43215.6.10 TIM10/11 and TIM13/14 auto-reload register (TIMx_ARR) . . . . . . . . . 43215.6.11 TIM10/11 and TIM13/14 capture/compare register 1 (TIMx_CCR1) . . 43315.6.12 TIM10/11/13/14 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433Doc ID 13902 Rev 1113/1072 14. ContentsRM000816 Basic timers (TIM6&TIM7) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 16.1TIM6&TIM7 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 16.2TIM6&TIM7 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435 16.3TIM6&TIM7 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 16.3.1Time-base unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 16.3.2Counting mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438 16.3.3Clock source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 16.3.4Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 16.4TIM6&TIM7 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 16.4.1TIM6&TIM7 control register 1 (TIMx_CR1) . . . . . . . . . . . . . . . . . . . . . 441 16.4.2TIM6&TIM7 control register 2 (TIMx_CR2) . . . . . . . . . . . . . . . . . . . . . 443 16.4.3TIM6&TIM7 DMA/Interrupt enable register (TIMx_DIER) . . . . . . . . . . 443 16.4.4TIM6&TIM7 status register (TIMx_SR) . . . . . . . . . . . . . . . . . . . . . . . . 444 16.4.5TIM6&TIM7 event generation register (TIMx_EGR) . . . . . . . . . . . . . . 444 16.4.6TIM6&TIM7 counter (TIMx_CNT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444 16.4.7TIM6&TIM7 prescaler (TIMx_PSC) . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 16.4.8TIM6&TIM7 auto-reload register (TIMx_ARR) . . . . . . . . . . . . . . . . . . . 445 16.4.9TIM6&TIM7 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44617 Real-time clock (RTC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 17.1RTC introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 17.2RTC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 17.3RTC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 17.3.1Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 17.3.2Resetting RTC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 17.3.3Reading RTC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 17.3.4Configuring RTC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450 17.3.5RTC flag assertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450 17.4RTC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451 17.4.1RTC control register high (RTC_CRH) . . . . . . . . . . . . . . . . . . . . . . . . 452 17.4.2RTC control register low (RTC_CRL) . . . . . . . . . . . . . . . . . . . . . . . . . . 452 17.4.3RTC prescaler load register (RTC_PRLH / RTC_PRLL) . . . . . . . . . . . 454 17.4.4RTC prescaler divider register (RTC_DIVH / RTC_DIVL) . . . . . . . . . . 454 17.4.5RTC counter register (RTC_CNTH / RTC_CNTL) . . . . . . . . . . . . . . . . 455 17.4.6RTC alarm register high (RTC_ALRH / RTC_ALRL) . . . . . . . . . . . . . . 456 17.4.7RTC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45714/1072 Doc ID 13902 Rev 11 15. RM0008 Contents18 Independent watchdog (IWDG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 18.1IWDG introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 18.2IWDG main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 18.3IWDG functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 18.3.1Hardware watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 18.3.2Register access protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 18.3.3Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459 18.4IWDG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 18.4.1Key register (IWDG_KR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460 18.4.2Prescaler register (IWDG_PR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461 18.4.3Reload register (IWDG_RLR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 18.4.4Status register (IWDG_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 18.4.5IWDG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46319 Window watchdog (WWDG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 19.1WWDG introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 19.2WWDG main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 19.3WWDG functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464 19.4How to program the watchdog timeout . . . . . . . . . . . . . . . . . . . . . . . . . . 466 19.5Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466 19.6WWDG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 19.6.1Control register (WWDG_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467 19.6.2Configuration register (WWDG_CFR) . . . . . . . . . . . . . . . . . . . . . . . . . 467 19.6.3Status register (WWDG_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468 19.6.4WWDG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46820 Flexible static memory controller (FSMC) . . . . . . . . . . . . . . . . . . . . . 469 20.1FSMC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469 20.2Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470 20.3AHB interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471 20.3.1Supported memories and transactions . . . . . . . . . . . . . . . . . . . . . . . . 472 20.4External device address mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 20.4.1NOR/PSRAM address mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473 20.4.2NAND/PC Card address mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474 20.5NOR Flash/PSRAM controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 Doc ID 13902 Rev 1115/1072 16. ContentsRM000820.5.1External memory interface signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47620.5.2Supported memories and transactions . . . . . . . . . . . . . . . . . . . . . . . . 47720.5.3General timing rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47920.5.4NOR Flash/PSRAM controller asynchronous transactions . . . . . . . . . 48020.5.5Synchronous burst transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49520.5.6NOR/PSRAM controller registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502 20.6 NAND Flash/PC Card controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50720.6.1External memory interface signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50820.6.2NAND Flash / PC Card supported memories and transactions . . . . . . 51020.6.3Timing diagrams for NAND and PC Card . . . . . . . . . . . . . . . . . . . . . . 51020.6.4NAND Flash operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51120.6.5NAND Flash pre-wait functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51220.6.6Error correction code computation ECC (NAND Flash) . . . . . . . . . . . . 51320.6.7PC Card/CompactFlash operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 51320.6.8NAND Flash/PC Card controller registers . . . . . . . . . . . . . . . . . . . . . . 51620.6.9FSMC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52221 Secure digital input/output interface (SDIO) . . . . . . . . . . . . . . . . . . . . 524 21.1 SDIO main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524 21.2 SDIO bus topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525 21.3 SDIO functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52721.3.1SDIO adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52821.3.2SDIO AHB interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538 21.4 Card functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53921.4.1Card identification mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53921.4.2Card reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53921.4.3Operating voltage range validation . . . . . . . . . . . . . . . . . . . . . . . . . . . 53921.4.4Card identification process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54021.4.5Block write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54121.4.6Block read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54121.4.7Stream access, stream write and stream read (MultiMediaCard only) 54221.4.8Erase: group erase and sector erase . . . . . . . . . . . . . . . . . . . . . . . . . . 54321.4.9Wide bus selection or deselection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54421.4.10 Protection management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54421.4.11 Card status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54721.4.12 SD status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55021.4.13 SD I/O mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55416/1072Doc ID 13902 Rev 11 17. RM0008 Contents21.4.14 Commands and responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555 21.5 Response formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55821.5.1R1 (normal response command) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55921.5.2R1b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55921.5.3R2 (CID, CSD register) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55921.5.4R3 (OCR register) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55921.5.5R4 (Fast I/O) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56021.5.6R4b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56021.5.7R5 (interrupt request) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56121.5.8R6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561 21.6 SDIO I/O card-specific operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56221.6.1SDIO I/O read wait operation by SDIO_D2 signalling . . . . . . . . . . . . . 56221.6.2SDIO read wait operation by stopping SDIO_CK . . . . . . . . . . . . . . . . 56221.6.3SDIO suspend/resume operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56321.6.4SDIO interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 21.7 CE-ATA specific operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56321.7.1Command completion signal disable . . . . . . . . . . . . . . . . . . . . . . . . . . 56321.7.2Command completion signal enable . . . . . . . . . . . . . . . . . . . . . . . . . . 56321.7.3CE-ATA interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56421.7.4Aborting CMD61 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564 21.8 HW flow control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564 21.9 SDIO registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56421.9.1SDIO power control register (SDIO_POWER) . . . . . . . . . . . . . . . . . . . 56521.9.2SDI clock control register (SDIO_CLKCR) . . . . . . . . . . . . . . . . . . . . . . 56521.9.3SDIO argument register (SDIO_ARG) . . . . . . . . . . . . . . . . . . . . . . . . . 56621.9.4SDIO command register (SDIO_CMD) . . . . . . . . . . . . . . . . . . . . . . . . 56721.9.5SDIO command response register (SDIO_RESPCMD) . . . . . . . . . . . 56821.9.6SDIO response 1..4 register (SDIO_RESPx) . . . . . . . . . . . . . . . . . . . 56821.9.7SDIO data timer register (SDIO_DTIMER) . . . . . . . . . . . . . . . . . . . . . 56921.9.8SDIO data length register (SDIO_DLEN) . . . . . . . . . . . . . . . . . . . . . . 56921.9.9SDIO data control register (SDIO_DCTRL) . . . . . . . . . . . . . . . . . . . . . 57021.9.10 SDIO data counter register (SDIO_DCOUNT) . . . . . . . . . . . . . . . . . . 57121.9.11 SDIO status register (SDIO_STA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57221.9.12 SDIO interrupt clear register (SDIO_ICR) . . . . . . . . . . . . . . . . . . . . . . 57321.9.13 SDIO mask register (SDIO_MASK) . . . . . . . . . . . . . . . . . . . . . . . . . . . 57521.9.14 SDIO FIFO counter register (SDIO_FIFOCNT) . . . . . . . . . . . . . . . . . . 577 Doc ID 13902 Rev 11 17/1072 18. Contents RM0008 21.9.15 SDIO data FIFO register (SDIO_FIFO) . . . . . . . . . . . . . . . . . . . . . . . . 578 21.9.16 SDIO register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57822 Universal serial bus full-speed device interface (USB) . . . . . . . . . . . 580 22.1USB introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 22.2USB main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 22.3USB functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580 22.3.1Description of USB blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582 22.4Programming considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583 22.4.1Generic USB device programming . . . . . . . . . . . . . . . . . . . . . . . . . . . 583 22.4.2System and power-on reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584 22.4.3Double-buffered endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589 22.4.4Isochronous transfers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591 22.4.5Suspend/Resume events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592 22.5USB registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594 22.5.1Common registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594 22.5.2Endpoint-specific registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 600 22.5.3Buffer descriptor table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604 22.5.4USB register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60823 Controller area network (bxCAN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610 23.1bxCAN introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610 23.2bxCAN main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 610 23.3bxCAN general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611 23.3.1CAN 2.0B active core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612 23.3.2Control, status and configuration registers . . . . . . . . . . . . . . . . . . . . . 612 23.3.3Tx mailboxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612 23.3.4Acceptance filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 612 23.4bxCAN operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613 23.4.1Initialization mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614 23.4.2Normal mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614 23.4.3Sleep mode (low power) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614 23.5Test mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615 23.5.1Silent mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615 23.5.2Loop back mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616 23.5.3Loop back combined with silent mode . . . . . . . . . . . . . . . . . . . . . . . . . 61618/1072 Doc ID 13902 Rev 11 19. RM0008 Contents 23.6STM32F10xxx in Debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 23.7bxCAN functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 23.7.1 Transmission handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 23.7.2 Time triggered communication mode . . . . . . . . . . . . . . . . . . . . . . . . . 619 23.7.3 Reception handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619 23.7.4 Identifier filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620 23.7.5 Message storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624 23.7.6 Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626 23.7.7 Bit timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626 23.8bxCAN interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628 23.9CAN registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630 23.9.1 Register access protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630 23.9.2 CAN control and status registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630 23.9.3 CAN mailbox registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 640 23.9.4 CAN filter registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647 23.9.5 bxCAN register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65124 Serial peripheral interface (SPI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 24.1SPI introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654 24.2SPI and I2S main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655 24.2.1 SPI features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655 24.2.2 I2S features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656 24.3SPI functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657 24.3.1 General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657 24.3.2 Configuring the SPI in slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 660 24.3.3 Configuring the SPI in master mode . . . . . . . . . . . . . . . . . . . . . . . . . . 661 24.3.4 Configuring the SPI for Simplex communication . . . . . . . . . . . . . . . . . 662 24.3.5 Data transmission and reception procedures . . . . . . . . . . . . . . . . . . . 663 24.3.6 CRC calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669 24.3.7 Status flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670 24.3.8 Disabling the SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671 24.3.9 SPI communication using DMA (direct memory addressing) . . . . . . . 672 24.3.10 Error flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674 24.3.11 SPI interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675 24.4I2S functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675 24.4.1 I2S general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675 Doc ID 13902 Rev 11 19/1072 20. Contents RM0008 24.4.2Supported audio protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677 24.4.3Clock generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684 24.4.4I2S master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687 24.4.5I2S slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689 24.4.6Status flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 691 24.4.7Error flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692 24.4.8I2S interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692 24.4.9DMA features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692 24.5SPI and I2S registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692 24.5.1SPI control register 1 (SPI_CR1) (not used in I2S mode) . . . . . . . . . . 693 24.5.2SPI control register 2 (SPI_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695 24.5.3SPI status register (SPI_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695 24.5.4SPI data register (SPI_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697 24.5.5SPI CRC polynomial register (SPI_CRCPR) (not used in I2S mode) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697 24.5.6SPI Rx CRC register (SPI_RXCRCR) (not used in I2S mode) . . . . . . 698 24.5.7SPI Tx CRC register (SPI_TXCRCR) (not used in I2S mode) . . . . . . . 698 24.5.8SPI_I2S configuration register (SPI_I2SCFGR) . . . . . . . . . . . . . . . . . . 699 24.5.9SPI_I2S prescaler register (SPI_I2SPR) . . . . . . . . . . . . . . . . . . . . . . . 700 24.5.10 SPI register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70125 Inter-integrated circuit (I2C) interface . . . . . . . . . . . . . . . . . . . . . . . . . 702 25.1I2C introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702 25.2I2C main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702 25.3I2C functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 25.3.1Mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703 25.3.2I2C slave mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705 25.3.3I2C master mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707 25.3.4Error conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714 25.3.5SDA/SCL line control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715 25.3.6SMBus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716 25.3.7DMA requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718 25.3.8Packet error checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719 2 25.4I C interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720 25.5I2C debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722 25.6I2C registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722 25.6.1Control register 1 (I2C_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72220/1072Doc ID 13902 Rev 11 21. RM0008 Contents 25.6.2 Control register 2 (I2C_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724 25.6.3 Own address register 1 (I2C_OAR1) . . . . . . . . . . . . . . . . . . . . . . . . . . 725 25.6.4 Own address register 2 (I2C_OAR2) . . . . . . . . . . . . . . . . . . . . . . . . . . 726 25.6.5 Data register (I2C_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726 25.6.6 Status register 1 (I2C_SR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727 25.6.7 Status register 2 (I2C_SR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730 25.6.8 Clock control register (I2C_CCR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731 25.6.9 TRISE register (I2C_TRISE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732 25.6.10 I2C register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73326 Universal synchronous asynchronous receiver transmitter (USART) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734 26.1USART introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734 26.2USART main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735 26.3USART functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736 26.3.1 USART character description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739 26.3.2 Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740 26.3.3 Receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743 26.3.4 Fractional baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747 26.3.5 USART receivers tolerance to clock deviation . . . . . . . . . . . . . . . . . . 748 26.3.6 Multiprocessor communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749 26.3.7 Parity control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 26.3.8 LIN (local interconnection network) mode . . . . . . . . . . . . . . . . . . . . . . 751 26.3.9 USART synchronous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 754 26.3.10 Single-wire half-duplex communication . . . . . . . . . . . . . . . . . . . . . . . . 756 26.3.11 Smartcard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757 26.3.12 IrDA SIR ENDEC block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759 26.3.13 Continuous communication using DMA . . . . . . . . . . . . . . . . . . . . . . . . 761 26.3.14 Hardware flow control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763 26.4USART interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765 26.5USART mode configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766 26.6USART registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766 26.6.1 Status register (USART_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766 26.6.2 Data register (USART_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 768 26.6.3 Baud rate register (USART_BRR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 769 26.6.4 Control register 1 (USART_CR1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 770 26.6.5 Control register 2 (USART_CR2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 772 Doc ID 13902 Rev 11 21/1072 22. ContentsRM000826.6.6Control register 3 (USART_CR3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77326.6.7Guard time and prescaler register (USART_GTPR) . . . . . . . . . . . . . . 77526.6.8USART register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77627 USB on-the-go full-speed (OTG_FS) . . . . . . . . . . . . . . . . . . . . . . . . . . 777 27.1 OTG_FS introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777 27.2 OTG_FS main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77827.2.1General features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77827.2.2Host-mode features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77927.2.3Peripheral-mode features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779 27.3 OTG_FS functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78027.3.1OTG full-speed core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78027.3.2Full-speed OTG PHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 780 27.4 OTG dual role device (DRD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78127.4.1ID line detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78227.4.2HNP dual role device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78227.4.3SRP dual role device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 782 27.5 USB peripheral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78327.5.1SRP-capable peripheral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78327.5.2Peripheral states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78427.5.3Peripheral endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785 27.6 USB host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78727.6.1SRP-capable host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78827.6.2USB host states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78827.6.3Host channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78927.6.4Host scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 791 27.7 SOF trigger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79227.7.1Host SOFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79327.7.2Peripheral SOFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793 27.8 Power options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794 27.9 USB data FIFOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794 27.10 Peripheral FIFO architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79527.10.1 Peripheral Rx FIFO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79527.10.2 Peripheral Tx FIFOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796 27.11 Host FIFO architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79627.11.1 Host Rx FIFO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79622/1072Doc ID 13902 Rev 11 23. RM0008 Contents27.11.2 Host Tx FIFOs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797 27.12 FIFO RAM allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79727.12.1 Device mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79727.12.2 Host mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 798 27.13 USB system performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 798 27.14 OTG_FS interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799 27.15 OTG_FS control and status registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 80127.15.1 CSR memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80127.15.2 OTG_FS global registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80627.15.3 Host-mode registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82727.15.4 Device-mode registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83827.15.5 OTG_FS power and clock gating control register(OTG_FS_PCGCCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86027.15.6 OTG_FS register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861 27.16 OTG_FS programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86727.16.1 Core initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86727.16.2 Host initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86927.16.3 Device initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86927.16.4 Host programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87027.16.5 Device programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88627.16.6 Operational model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88827.16.7 Worst case response time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90527.16.8 OTG programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90628 Ethernet (ETH): media access control (MAC) with DMA controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 912 28.1 Ethernet introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 912 28.2 Ethernet main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91228.2.1 MAC core features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91328.2.2 DMA features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91428.2.3 PTP features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914 28.3 Ethernet pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 915 28.4 Ethernet functional description: SMI, MII and RMII . . . . . . . . . . . . . . . . 91628.4.1 Station management interface: SMI . . . . . . . . . . . . . . . . . . . . . . . . . . . 91628.4.2 Media-independent interface: MII . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91928.4.3 Reduced media-independent interface: RMII . . . . . . . . . . . . . . . . . . . 92228.4.4 MII/RMII selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 923 Doc ID 13902 Rev 1123/1072 24. Contents RM0008 28.5Ethernet functional description: MAC 802.3 . . . . . . . . . . . . . . . . . . . . . . 924 28.5.1MAC 802.3 frame format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 924 28.5.2MAC frame transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928 28.5.3MAC frame reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 935 28.5.4MAC interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 940 28.5.5MAC filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 940 28.5.6MAC loopback mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 943 28.5.7MAC management counters: MMC . . . . . . . . . . . . . . . . . . . . . . . . . . . 943 28.5.8Power management: PMT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 944 28.5.9Precision time protocol (IEEE1588 PTP) . . . . . . . . . . . . . . . . . . . . . . . 947 28.6Ethernet functional description: DMA controller operation . . . . . . . . . . . 953 28.6.1Initialization of a transfer using DMA . . . . . . . . . . . . . . . . . . . . . . . . . . 954 28.6.2Host bus burst access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954 28.6.3Host data buffer alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 955 28.6.4Buffer size calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 955 28.6.5DMA arbiter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956 28.6.6Error response to DMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956 28.6.7Tx DMA configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956 28.6.8Rx DMA configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 970 28.6.9DMA interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 979 28.7Ethernet interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 980 28.8Ethernet register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 981 28.8.1MAC register description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 981 28.8.2MMC register description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 998 28.8.3IEEE 1588 time stamp registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003 28.8.4DMA register description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1007 28.8.5Ethernet register maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102129 Device electronic signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024 29.1Memory size registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024 29.1.1Flash size register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024 29.2Unique device ID register (96 bits) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102530 Debug support (DBG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1027 30.1Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1027 30.2Reference ARM documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102924/1072 Doc ID 13902 Rev 11 25. RM0008Contents 30.3 SWJ debug port (serial wire and JTAG) . . . . . . . . . . . . . . . . . . . . . . . . 102930.3.1Mechanism to select the JTAG-DP or the SW-DP . . . . . . . . . . . . . . . 1029 30.4 Pinout and debug port pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103030.4.1SWJ debug port pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103030.4.2Flexible SWJ-DP pin assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103030.4.3Internal pull-up and pull-down on JTAG pins . . . . . . . . . . . . . . . . . . . 103130.4.4Using serial wire and releasing the unused debug pins as GPIOs . . 1032 30.5 STM32F10xxx JTAG TAP connection . . . . . . . . . . . . . . . . . . . . . . . . . 1032 30.6 ID codes and locking mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103330.6.1MCU device ID code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103330.6.2Boundary scan TAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103530.6.3Cortex-M3 TAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103530.6.4Cortex-M3 JEDEC-106 ID code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1035 30.7 JTAG debug port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1035 30.8 SW debug port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103730.8.1SW protocol introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103730.8.2SW protocol sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103730.8.3SW-DP state machine (Reset, idle states, ID code) . . . . . . . . . . . . . 103830.8.4DP and AP read/write accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103930.8.5SW-DP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103930.8.6SW-AP registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1040 30.9 AHB-AP (AHB access port) - valid for both JTAG-DP or SW-DP . . . . . 1040 30.10 Core debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1041 30.11 Capability of the debugger host to connect under system reset . . . . . 1042 30.12 FPB (Flash patch breakpoint) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1042 30.13 DWT (data watchpoint trigger) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1043 30.14 ITM (instrumentation trace macrocell) . . . . . . . . . . . . . . . . . . . . . . . . . 104330.14.1 General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104330.14.2 Time stamp packets, synchronization and overflow packets . . . . . . . 1043 30.15 ETM (Embedded Trace Macrocell) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104530.15.1 General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104530.15.2 Signal protocol, packet types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104530.15.3 Main ETM registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104530.15.4 Configuration example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1046 30.16 MCU debug component (DBGMCU) . . . . . . . . . . . . . . . . . . . . . . . . . . 1046Doc ID 13902 Rev 11 25/1072 26. Contents RM000830.16.1 Debug support for low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . 104630.16.2 Debug support for timers, watchdog, bxCAN and I2C . . . . . . . . . . . . 104730.16.3 Debug MCU configuration register . . . . . . . . . . . . . . . . . . . . . . . . . . . 1047 30.17 TPIU (trace port interface unit) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104930.17.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104930.17.2 TRACE pin assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105030.17.3 TPUI formatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105230.17.4 TPUI frame synchronization packets . . . . . . . . . . . . . . . . . . . . . . . . . 105230.17.5 Transmission of the synchronization frame packet . . . . . . . . . . . . . . 105230.17.6 Synchronous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105330.17.7 Asynchronous mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105330.17.8 TRACECLKIN connection inside the STM32F10xxx . . . . . . . . . . . . . 105330.17.9 TPIU registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105330.17.10 Example of configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1054 30.18 DBG register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105531 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105626/1072Doc ID 13902 Rev 11 27. RM0008 List of tablesList of tablesTable 1.Register boundary addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Table 2.Flash module organization (low-density devices) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Table 3.Flash module organization (medium-density devices) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Table 4.Flash module organization (high-density devices) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Table 5.Flash module organization (connectivity line devices) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Table 6.XL