Stm32f10xxx Manual
Stm32f10xxx Manual
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- and high-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 the STM32F10xxx Flash programming manual.
For information on the ARM Cortex™-M3 core, please refer to the Cortex™-M3 Technical
Reference Manual.
Related documents
Available from www.arm.com:
■ Cortex™-M3 Technical Reference Manual, available from:
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0337e/DDI0337E_cortex_m3_r1p1_trm.pdf
Available from www.st.com:
■ STM32F101xx STM32F103xx datasheets
■ STM32F10xxx Flash programming manual
Contents
1 Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
1.1 List of abbreviations for registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
1.2 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
1.3 Peripheral availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
List of tables
List of figures
Figure 101. Counter timing diagram with prescaler division change from 1 to 4 . . . . . . . . . . . . . . . . . 323
Figure 102. Counter timing diagram, internal clock divided by 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Figure 103. Counter timing diagram, internal clock divided by 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Figure 104. Counter timing diagram, internal clock divided by 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Figure 105. Counter timing diagram, internal clock divided by N. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Figure 106. Counter timing diagram, Update event when ARPE=0 (TIMx_ARR not preloaded). . . . . 325
Figure 107. Counter timing diagram, Update event when ARPE=1 (TIMx_ARR preloaded). . . . . . . . 326
Figure 108. Counter timing diagram, internal clock divided by 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Figure 109. Counter timing diagram, internal clock divided by 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Figure 110. Counter timing diagram, internal clock divided by 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Figure 111. Counter timing diagram, internal clock divided by N. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Figure 112. Counter timing diagram, Update event when repetition counter is not used . . . . . . . . . . 328
Figure 113. Counter timing diagram, internal clock divided by 1, TIMx_ARR=0x6 . . . . . . . . . . . . . . . 329
Figure 114. Counter timing diagram, internal clock divided by 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Figure 115. Counter timing diagram, internal clock divided by 4, TIMx_ARR=0x36 . . . . . . . . . . . . . . 330
Figure 116. Counter timing diagram, internal clock divided by N. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Figure 117. Counter timing diagram, Update event with ARPE=1 (counter underflow). . . . . . . . . . . . 330
Figure 118. Counter timing diagram, Update event with ARPE=1 (counter overflow) . . . . . . . . . . . . . 331
Figure 119. Control circuit in normal mode, internal clock divided by 1 . . . . . . . . . . . . . . . . . . . . . . . . 332
Figure 120. TI2 external clock connection example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Figure 121. Control circuit in external clock mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Figure 122. External trigger input block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Figure 123. Control circuit in external clock mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Figure 124. Capture/compare channel (example: channel 1 input stage) . . . . . . . . . . . . . . . . . . . . . . 334
Figure 125. Capture/compare channel 1 main circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Figure 126. Output stage of capture/compare channel (channel 1). . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Figure 127. PWM input mode timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Figure 128. Output compare mode, toggle on OC1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Figure 129. Edge-aligned PWM waveforms (ARR=8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Figure 130. Center-aligned PWM waveforms (ARR=8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Figure 131. Example of one pulse mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Figure 132. Clearing TIMx OCxREF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
Figure 133. Example of counter operation in encoder interface mode. . . . . . . . . . . . . . . . . . . . . . . . . 345
Figure 134. Example of encoder interface mode with IC1FP1 polarity inverted. . . . . . . . . . . . . . . . . . 346
Figure 135. Control circuit in reset mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Figure 136. Control circuit in gated mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Figure 137. Control circuit in trigger mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Figure 138. Control circuit in external clock mode 2 + trigger mode . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Figure 139. Master/Slave timer example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Figure 140. Gating timer 2 with OC1REF of timer 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Figure 141. Gating timer 2 with Enable of timer 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Figure 142. Triggering timer 2 with update of timer 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Figure 143. Triggering timer 2 with Enable of timer 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Figure 144. Triggering timer 1 and 2 with timer 1 TI1 input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Figure 145. Basic timer block diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
Figure 146. Counter timing diagram with prescaler division change from 1 to 2 . . . . . . . . . . . . . . . . . 377
Figure 147. Counter timing diagram with prescaler division change from 1 to 4 . . . . . . . . . . . . . . . . . 377
Figure 148. Counter timing diagram, internal clock divided by 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Figure 149. Counter timing diagram, internal clock divided by 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Figure 150. Counter timing diagram, internal clock divided by 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Figure 151. Counter timing diagram, internal clock divided by N. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Figure 152. Counter timing diagram, update event when ARPE = 0 (TIMx_ARR not
preloaded). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
Figure 153. Counter timing diagram, update event when ARPE=1 (TIMx_ARR
preloaded). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
Figure 154. Control circuit in normal mode, internal clock divided by 1 . . . . . . . . . . . . . . . . . . . . . . . . 381
Figure 155. RTC simplified block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
Figure 156. RTC second and alarm waveform example with PR=0003, ALARM=00004 . . . . . . . . . . 391
Figure 157. RTC Overflow waveform example with PR=0003. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Figure 158. Independent watchdog block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Figure 159. Watchdog block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Figure 160. Window watchdog timing diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Figure 161. FSMC memory banks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Figure 162. Mode1 read accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Figure 163. ModeA read accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
Figure 164. ModeA write accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
Figure 165. Mode2/B read accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
Figure 166. Mode2 write accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
Figure 167. ModeB write accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
Figure 168. ModeC read accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Figure 169. ModeC write accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Figure 170. ModeD read accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Figure 171. Muxed read accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Figure 172. Muxed write accesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Figure 173. Synchronous multiplexed read mode - NOR, PSRAM (CRAM) . . . . . . . . . . . . . . . . . . . . 432
Figure 174. Synchronous multiplexed write mode - PSRAM (CRAM) . . . . . . . . . . . . . . . . . . . . . . . . . 434
Figure 175. NAND/PC Card controller timing for common memory access . . . . . . . . . . . . . . . . . . . . 445
Figure 176. Access to non ‘CE don’t care’ NAND-Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Figure 177. SDIO “no response” and “no data” operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Figure 178. SDIO (multiple) block read operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Figure 179. SDIO (multiple) block write operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
Figure 180. SDIO sequential read operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
Figure 181. SDIO sequential write operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
Figure 182. SDIO block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Figure 183. SDIO adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Figure 184. Control unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461
Figure 185. SDIO adapter command path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
Figure 186. Command path state machine (CPSM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Figure 187. SDIO command transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Figure 188. Data path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Figure 189. Data path state machine (DPSM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Figure 190. USB peripheral block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
Figure 191. Packet buffer areas with examples of buffer description table locations . . . . . . . . . . . . . 517
Figure 192. CAN network topology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Figure 193. Dual CAN block diagram (connectivity devices) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
Figure 194. bxCAN operating modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Figure 195. bxCAN in silent mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Figure 196. bxCAN in loop back mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Figure 197. bxCAN in combined mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Figure 198. Transmit mailbox states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
Figure 199. Receive FIFO states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
Figure 200. Filter bank scale configuration - register organization . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Figure 201. Example of filter numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
Figure 202. Filtering mechanism - example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Figure 307. System time update using the Fine correction method. . . . . . . . . . . . . . . . . . . . . . . . . . . 875
Figure 308. PTP trigger output to TIM2 ITR1 connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 877
Figure 309. PPS output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 878
Figure 310. Descriptor ring and chain structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879
Figure 311. TxDMA operation in Default mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
Figure 312. TxDMA operation in OSF mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 885
Figure 313. Transmit descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 886
Figure 314. Transmit descriptor field format with IEEE1588 time stamp enabled . . . . . . . . . . . . . . . . 891
Figure 315. Receive DMA operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 896
Figure 316. Rx DMA descriptor structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 898
Figure 317. Receive descriptor fields format with IEEE1588 time stamp enabled. . . . . . . . . . . . . . . . 903
Figure 318. Interrupt scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 905
Figure 319. Ethernet MAC remote wakeup frame filter register (ETH_MACRWUFFR). . . . . . . . . . . . 915
Figure 320. Block diagram of STM32F10xxx-level and Cortex-M3-level debug support . . . . . . . . . . . 953
Figure 321. SWJ debug port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 954
Figure 322. JTAG TAP connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 958
Figure 323. TPIU block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 975
1 Documentation conventions
1.2 Glossary
● Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
● Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.
● High-density devices are STM32F101xx and STM32F103xx microcontrollers where
the Flash memory density ranges between 256 and 512 Kbytes.
● Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
SRAM
Bus matrix
DMA1 DMA
FSMC
SDIO
Ch.1
AHB system bus Bridge 2
Ch.2
Bridge 1 APB 1
APB2
DMA
Ch.2
ai14800c
SRAM
Bus matrix
DMA1 DMA
Reset & clock
control (RCC)
Ch.1
AHB system bus Bridge 2
Ch.2
DMA
Bridge 1 APB 1
APB2
Ch.7
ADC1 GPIOC DAC SPI3/I2S
ADC2 GPIOD PWR SPI2/I2S
DMA request USART1 GPIOE BKP IWDG
SPI1 EXTI CAN1 WWDG
TIM1 AFIO CAN2 RTC
GPIOA I2C2 TIM7
DMA2 GPIOB I2C1 TIM6
UART5 TIM5
UART4 TIM4
DMA
USART3 TIM3
Ch.1 USART2 TIM2
Ch.2
DMA request
Ch.5
Ethernet MAC
USB OTG FS
ai15810
ICode bus
This bus connects the Instruction bus of the Cortex™-M3 core to the Flash memory
instruction interface. Prefetching is performed on this bus.
DCode bus
This bus connects the DCode bus (literal load and debug access) of the Cortex™-M3 core
to the Flash memory Data interface.
System bus
This bus connects the system bus of the Cortex™-M3 core (peripherals bus) to a BusMatrix
which manages the arbitration between the core and the DMA.
DMA bus
This bus connects the AHB master interface of the DMA to the BusMatrix which manages
the access of CPU DCode and DMA to SRAM, Flash memory and peripherals.
BusMatrix
The BusMatrix manages the access arbitration between the core system bus and the DMA
master bus. The arbitration uses a Round Robin algorithm. In connectivity line devices, the
BusMatrix is composed of five masters (CPU DCode, System bus, Ethernet DMA, DMA1
and DMA2 bus) and three slaves (FLITF, SRAM and AHB2APB bridges). In other devices,
the BusMatrix is composed of four masters (CPU DCode, System bus, DMA1 bus and
DMA2 bus) and four slaves (FLITF, SRAM, FSMC and AHB2APB bridges).
AHB peripherals are connected on system bus through a BusMatrix to allow DMA access.
0x5000 0000 - 0x5000 03FF USB OTG FS Section 26.14.6 on page 778
0x4003 0000 - 0x4FFF FFFF Reserved AHB
0x4002 8000 - 0x4002 9FFF Ethernet Section 27.8.5 on page 946
0x4002 3400 - 0x4002 7FFF Reserved
0x4002 3000 - 0x4002 33FF CRC Section 3.4.4 on page 52
0x4002 2000 - 0x4002 23FF Flash memory interface
0x4002 1400 - 0x4002 1FFF Reserved
0x4002 1000 - 0x4002 13FF Reset and clock control RCC Section 6.3.11 on page 102
AHB
0x4002 0800 - 0x4002 0FFF Reserved
0x4002 0400 - 0x4002 07FF DMA2 Section 10.4.7 on page 196
0x4002 0000 - 0x4002 03FF DMA1 Section 10.4.7 on page 196
0x4001 8400 - 0x4001 7FFF Reserved
0x4001 8000 - 0x4001 83FF SDIO Section 20.9.16 on page 510
0x4001 4000 - 0x4001 7FFF Reserved
0x4001 3C00 - 0x4001 3FFF ADC3 Section 11.12.15 on page 231
0x4001 3800 - 0x4001 3BFF USART1 Section 25.6.8 on page 693
0x4001 3400 - 0x4001 37FF TIM8 timer Section 13.4.21 on page 317
0x4001 3000 - 0x4001 33FF SPI1 Section 23.5 on page 614
0x4001 2C00 - 0x4001 2FFF TIM1 timer Section 13.4.21 on page 317
0x4001 2800 - 0x4001 2BFF ADC2 Section 11.12.15 on page 231
0x4001 2400 - 0x4001 27FF ADC1 Section 11.12.15 on page 231
0x4001 2000 - 0x4001 23FF GPIO Port G APB2 Section 8.5 on page 167
0x4001 1C00 - 0x4001 1FFF GPIO Port F Section 8.5 on page 167
0x4001 1800 - 0x4001 1BFF GPIO Port E Section 8.5 on page 167
0x4001 1400 - 0x4001 17FF GPIO Port D Section 8.5 on page 167
0x4001 1000 - 0x4001 13FF GPIO Port C Section 8.5 on page 167
0x4001 0C00 - 0x4001 0FFF GPIO Port B Section 8.5 on page 167
0x4001 0800 - 0x4001 0BFF GPIO Port A Section 8.5 on page 167
0x4001 0400 - 0x4001 07FF EXTI Section 9.3.7 on page 181
0x4001 0000 - 0x4001 03FF AFIO Section 8.5 on page 167
Note: For further information on the Flash memory interface registers, please refer to the
STM32F10xxx Flash programming manual.
Note: 1 These options should be used in accordance with the Flash memory access time. The wait
states represent the ratio of the SYSCLK (system clock) period to the Flash memory access
time:
zero wait state, if 0 < SYSCLK 24 MHz
one wait state, if 24 MHz < SYSCLK 48 MHz
two wait states, if 48 MHz < SYSCLK 72 MHz
2 Half cycle configuration is not available in combination with a prescaler on the AHB. The
system clock (SYSCLK) should be equal to the HCLK clock. This feature can therefore be
used only with a low-frequency clock of 8 MHz or less. It can be generated from the HSI or
the HSE but not from the PLL.
3 The prefetch buffer must be kept on when using a prescaler different from 1 on the AHB
clock.
4 The prefetch buffer must be switched on/off only when SYSCLK is lower than 24 MHz. The
prefetch buffer is usually switched on/off during the initialization routine, while the
microcontroller is running on the internal 8 MHz RC (HSI) oscillator.
5 Using DMA: DMA accesses Flash memory on the DCode bus and has priority over ICode
instructions. The DMA provides one free cycle after each transfer. Some instructions can be
performed together with DMA transfer.
The values on the BOOT pins are latched on the 4th rising edge of SYSCLK after a Reset. It
is up to the user to set the BOOT1 and BOOT0 pins after Reset to select the required boot
mode.
The BOOT pins are also re-sampled when exiting from Standby mode. Consequently they
must be kept in the required Boot mode configuration in Standby mode. After this startup
delay has elapsed, the CPU fetches the top-of-stack value from address 0x0000 0000, then
starts code execution from the boot memory starting from 0x0000 0004.
Due to its fixed memory map, the code area starts from address 0x0000 0000 (accessed
through the ICode/DCode buses) while the data area (SRAM) starts from address
0x2000 0000 (accessed through the system bus). The Cortex-M3 CPU always fetches the
reset vector on the ICode bus, which implies to have the boot space available only in the
code area (typically, Flash memory). STM32F10xxx microcontrollers implement a special
mechanism to be able to boot also from SRAM and not only from main Flash memory and
System memory.
Depending on the selected boot mode main Flash memory, System memory or SRAM is
accessible as follows:
● Boot from main Flash memory: the main Flash memory is aliased in the boot memory
space (0x0000 0000), but still accessible from its original memory space (0x800 0000).
In other words, the Flash memory contents can be accessed starting from address
0x0000 0000 or 0x800 0000.
● Boot from System memory: the System memory is aliased in the boot memory space
(0x0000 0000), but still accessible from its original memory space (0x1FFF B000 in
connectivity line devices, 0x1FFF F000 in other devices).
● Boot from the embedded SRAM: SRAM is accessible only at address 0x2000 0000.
Note: When booting from SRAM, in the application initialization code, you have to relocate the
vector table in SRAM using the NVIC exception table and offset register.
AHB bus
DR [31:16]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DR [15:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
IDR[7:0]
Reserved
rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RESET
Reserved
w
VDDA domain
(VSSA) VREF-
(from 2.4 V up to VDDA)VREF+ A/D converter
Temp. sensor
(VDD) VDDA Reset block
PLL
(VSS) VSSA
I/O Ring
VSS Core
Standby circuitry Memories
VDD (Wakeup logic, digital
IWDG) peripherals
Voltage Regulator
Backup domain
LSE crystal 32K osc
VBAT
BKP registers
RCC BDCR register
RTC
Note: 1 VDDA and VSSA must be connected to VDD and VSS, respectively.
On 64-pin packages
The VREF+ and VREF- pins are not available, they are internally connected to the ADC
voltage supply (VDDA) and ground (VSSA).
Note: Due to the fact that the switch only sinks a limited amount of current (3 mA), the use of
GPIOs PC13 to PC15 in output mode is restricted: the speed has to be limited to 2 MHz with
a maximum load of 30 pF and these IOs must not be used as a current source (e.g. to drive
an LED).
When the backup domain is supplied by VBAT (analog switch connected to VBAT because
VDD is not present), the following functions are available:
● PC14 and PC15 can be used as LSE pins only
● PC13 can be used as TAMPER pin, RTC Alarm or Second output (refer to section
Section 5.4.2: RTC clock calibration register (BKP_RTCCR) on page 68).
VDD/VDDA
POR
40 mV
hysteresis
PDR
Temporization
tRSTTEMPO
Reset
100 mV
PVD threshold hysteresis
PVD output
Table 9. Sleep-now
Sleep-now mode Description
In Stop mode, the following features can be selected by programming individual control bits:
● Independent watchdog (IWDG): the IWDG is started by writing to its Key register or by
hardware option. Once started it cannot be stopped except by a Reset. See
Section 17.3 in Section 17: Independent watchdog (IWDG).
● real-time clock (RTC): this is configured by the RTCEN bit in the Backup domain control
register (RCC_BDCR)
● Internal RC oscillator (LSI RC): this is configured by the LSION bit in the Control/status
register (RCC_CSR).
● External 32.768 kHz oscillator (LSE OSC): this is configured by the LSEON bit in the
Backup domain control register (RCC_BDCR).
The ADC or DAC can also consume power during the Stop mode, unless they are disabled
before entering it. To disable them, the ADON bit in the ADC_CR2 register and the ENx bit
in the DAC_CR register must both be written to 0.
Exiting Stop mode
Refer to Table 11 for more details on how to exit Stop mode.
When exiting Stop mode by issuing an interrupt or a wakeup event, the HSI RC oscillator is
selected as system clock.
When the voltage regulator operates in low-power mode, an additional startup delay is
incurred when waking up from Stop mode. By keeping the internal regulator ON during Stop
mode, the consumption is higher although the startup time is reduced.
Note: To enter Stop mode, all EXTI Line pending bits (in Pending register
(EXTI_PR)) and RTC Alarm flag must be reset. Otherwise, the Stop mode
entry procedure is ignored and program execution continues.
If WFI was used for entry:
Any EXTI Line configured in Interrupt mode (the corresponding EXTI
Interrupt vector must be enabled in the NVIC). Refer to Table 53: Vector
Mode exit table for other STM32F10xxx devices on page 172.
If WFE was used for entry:
Any EXTI Line configured in event mode. Refer to Section 9.2.3: Wakeup
event management on page 175
Wakeup latency HSI RC wakeup time + regulator wakeup time from Low-power mode
switched off. SRAM and register contents are lost except for registers in the Backup domain
and Standby circuitry (see Figure 4).
Debug mode
By default, the debug connection is lost if the application puts the MCU in Stop or Standby
mode while the debug features are used. This is due to the fact that the Cortex™-M3 core is
no longer clocked.
However, by setting some configuration bits in the DBGMCU_CR register, the software can
be debugged even when using the low-power modes extensively. For more details, refer to
Section 29.16.1: Debug support for low-power modes.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
9
8
7
6
5
4
3
2
1
0
CWUF
PDDS
PVDE
CSBF
LPDS
DBP
PWR_CR PLS[2:0]
0x000 Reserved
Reset value 0 0 0 0 0 0 0 0 0
EWUP
PVDO
WUF
SBF
PWR_CSR
0x004 Reserved Reserved
Reset value 0 0 0 0
Note: Setting the TPAL and TPE bits at the same time is always safe, however resetting both at
the same time can generate a spurious Tamper event. For this reason it is recommended to
change the TPAL bit only when the TPE bit is reset.
Offset Register
9
8
7
6
5
4
3
2
1
0
0x00 Reserved
BKP_DR1 D[15:0]
0x04 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR2 D[15:0]
0x08 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR3 D[15:0]
0x0C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR4 D[15:0]
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR5 D[15:0]
0x14 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR6 D[15:0]
0x18 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
BKP_DR7 D[15:0]
0x1C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR8 D[15:0]
0x20 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR9 D[15:0]
0x24 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR10 D[15:0]
0x28 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ASOS
ASOE
CCO
BKP_RTCCR CAL[6:0]
0x2 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0
TPAL
TPE
BKP_CR
0x30 Reserved
Reset value 0 0
TPIE
CTE
TEF
CTI
TIF
BKP_CSR
0x34 Reserved Reserved
Reset value 0 0 0 0 0
0x38 Reserved
0x3C Reserved
BKP_DR11 D[15:0]
0x40 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR12 D[15:0]
0x44 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR13 D[15:0]
0x48 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR14 D[15:0]
0x4C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR15 D[15:0]
0x50 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR16 D[15:0]
0x54 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR17 D[15:0]
0x58 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR18 D[15:0]
0x5C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
BKP_DR20 D[15:0]
0x64 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR21 D[15:0]
0x68 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR22 D[15:0]
0x6C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR23 D[15:0]
0x70 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR24 D[15:0]
0x74 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR25 D[15:0]
0x78 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR26 D[15:0]
0x7C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR27 D[15:0]
0x80 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR28 D[15:0]
0x84 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR30 D[15:0]
0x8C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR31 D[15:0]
0x90 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR32 D[15:0]
0x94 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR33 D[15:0]
0x98 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR34 D[15:0]
0x9C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR35 D[15:0]
0xA0 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR36 D[15:0]
0xA4 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
BKP_DR37 D[15:0]
0xA8 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR38 D[15:0]
0xAC Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR40 D[15:0]
0xB4 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
BKP_DR42 D[15:0]
0xBC Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6.1 Reset
There are three types of reset, defined as system Reset, power Reset and backup domain
Reset.
Software reset
The SYSRESETREQ bit in Cortex™-M3 Application Interrupt and Reset Control Register
must be set to force a software reset on the device. Refer to the Cortex™-M3 technical
reference manual for more details.
RPU
External System reset
reset Filter
NRST
WWDG reset
Pulse
IWDG reset
generator
Power reset
(min 20 µs)
Software reset
Low-power management reset
ai16095
6.2 Clocks
Three different clock sources can be used to drive the system clock (SYSCLK):
● HSI oscillator clock
● HSE oscillator clock
● PLL clock
The devices have the following two secondary clock sources:
● 40 kHz low speed internal RC (LSI RC) which drives the independent watchdog and
optionally the RTC used for Auto-wakeup from Stop/Standby mode.
● 32.768 kHz low speed external crystal (LSE crystal) which optionally drives the real-
time clock (RTCCLK)
Each clock source can be switched on or off independently when it is not used, to optimize
power consumption.
I2S3CLK
to I2S3
Peripheral clock
enable I2S2CLK
to I2S2
Peripheral clock
SDIOCLK
enable to SDIO
8 MHz Peripheral clock
HSI RC HSI enable
FSMCCLK
to FSMC
Peripheral clock
/2 enable
HCLK
72 MHz max to AHB bus, core,
Clock memory and DMA
Enable
/8 to Cortex System timer
PLLSRC SW
PLLMUL FCLK Cortex
HSI free running clock
..., x16 SYSCLK AHB APB1
36 MHz max PCLK1
x2, x3, x4 PLLCLK 72 MHz
Prescaler Prescaler
to APB1
PLL max /1, 2..512 /1, 2, 4, 8, 16 peripherals
Peripheral Clock
HSE
Enable
TIM2,3,4,5,6,7
If (APB1 prescaler =1) x1 to TIM2,3,4,5,6 and 7
CSS else x2 TIMXCLK
Peripheral Clock
Enable
PLLXTPRE APB2
72 MHz max PCLK2
Prescaler
OSC_OUT /1, 2, 4, 8, 16 peripherals to APB2
4-16 MHz Peripheral Clock
HSE OSC Enable
OSC_IN /2
TIM1 & 8 timers to TIM1 and TIM8
If (APB2 prescaler =1) x1
else x2 TIMxCLK
Peripheral Clock
/128 Enable
ADC to ADC1, 2 or 3
OSC32_IN to RTC
LSE OSC LSE Prescaler
ADCCLK 14 MHz max
32.768 kHz RTCCLK /2, 4, 6, 8
OSC32_OUT
HCLK/2
RTCSEL[1:0] /2
To SDIO AHB interface
Peripheral clock
to Independent Watchdog (IWDG) enable
LSI RC LSI
40 kHz IWDGCLK
1. When the HSI is used as a PLL clock input, the maximum system clock frequency that can be achieved is
64 MHz.
2. For full details about the internal and external clock source characteristics, please refer to the “Electrical
characteristics” section in your device datasheet.
Several prescalers allow the configuration of the AHB frequency, the high speed APB
(APB2) and the low speed APB (APB1) domains. The maximum frequency of the AHB and
the APB2 domains is 72 MHz. The maximum allowed frequency of the APB1 domain is
36 MHz. The SDIO AHB interface is clocked with a fixed frequency equal to HCLK/2.
The RCC feeds the Cortex System Timer (SysTick) external clock with the AHB clock
(HCLK) divided by 8. The SysTick can work either with this clock or with the Cortex clock
(HCLK), configurable in the SysTick Control and Status Register. The ADCs are clocked by
the clock of the High Speed domain (APB2) divided by 2, 4, 6 or 8.
The timer clock frequencies are automatically fixed by hardware. There are two cases:
1. if the APB prescaler is 1, the timer clock frequencies are set to the same frequency as
that of the APB domain to which the timers are connected.
2. otherwise, they are set to twice (×2) the frequency of the APB domain to which the
timers are connected.
FCLK acts as Cortex™-M3 free running clock. For more details refer to the ARM Cortex™-
M3 Technical Reference Manual.
OSC_OUT
External clock
(HiZ)
External
source
OSC_IN OSC_OUT
Crystal/Ceramic
resonators
CL1 CL2
Load
capacitors
Calibration
RC oscillator frequencies can vary from one chip to another due to manufacturing process
variations, this is why each device is factory calibrated by ST for 1% accuracy at TA=25°C.
After reset, the factory calibration value is loaded in the HSICAL[7:0] bits in the Clock control
register (RCC_CR).
If the application is subject to voltage or temperature variations this may affect the RC
oscillator speed. You can trim the HSI frequency in the application using the HSITRIM[4:0]
bits in the Clock control register (RCC_CR).
The HSIRDY flag in the Clock control register (RCC_CR) indicates if the HSI RC is stable or
not. At startup, the HSI RC output clock is not released until this bit is set by hardware.
The HSI RC can be switched on and off using the HSION bit in the Clock control register
(RCC_CR).
The HSI signal can also be used as a backup source (Auxiliary clock) if the HSE crystal
oscillator fails. Refer to Section 6.2.7: Clock security system (CSS) on page 81.
6.2.3 PLL
The internal PLL can be used to multiply the HSI RC output or HSE crystal output clock
frequency. Refer to Figure 8 and Clock control register (RCC_CR).
The PLL configuration (selection of HSI oscillator divided by 2 or HSE oscillator for PLL
input clock, and multiplication factor) must be done before enabling the PLL. Once the PLL
enabled, these parameters cannot be changed.
An interrupt can be generated when the PLL is ready if enabled in the Clock interrupt
register (RCC_CIR).
If the USB interface is used in the application, the PLL must be programmed to output 48 or
72 MHz. This is needed to provide a 48 MHz USBCLK.
LSI calibration
The frequency dispersion of the Low Speed Internal RC (LSI) oscillator can be calibrated to
have accurate RTC time base and/or IWDG timeout (when LSI is used as clock source for
these peripherals) with an acceptable accuracy.
This calibration is performed by measuring the LSI clock frequency with respect to TIM5
input clock (TIM5CLK). According to this measurement done at the precision of the HSE
oscillator, the software can adjust the programmable 20-bit prescaler of the RTC to get an
accurate time base or can compute accurate IWDG timeout.
The LSE clock is in the Backup domain, whereas the HSE and LSI clocks are not.
Consequently:
● If LSE is selected as RTC clock:
– The RTC continues to work even if the VDD supply is switched off, provided the
VBAT supply is maintained.
● If LSI is selected as Auto-Wakeup unit (AWU) clock:
– The AWU state is not guaranteed if the VDD supply is powered off. Refer to
Section 6.2.5: LSI clock on page 80 for more details on LSI calibration.
● If the HSE clock divided by 128 is used as the RTC clock:
– The RTC state is not guaranteed if the VDD supply is powered off or if the internal
voltage regulator is powered off (removing power from the 1.8 V domain).
– The DPB bit (Disable backup domain write protection) in the Power controller
register must be set to 1 (refer to Section 4.4.1: Power control register
(PWR_CR)).
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HSI
HSICAL[7:0] HSITRIM[4:0] HSION
RDY
Res.
r r r r r r r r rw rw rw rw rw r rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw r r rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PLL HSE HSI LSE LSI PLL HSE HSI LSE LSI
CSSF
RDYIE RDYIE RDYIE RDYIE RDYIE RDYF RDYF RDYF RDYF RDYF
Reserved Reserved
rw rw rw rw rw r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ADC3 USART1 TIM8 SPI1 TIM1 ADC2 ADC1 IOPG IOPF IOPE IOPD IOPC IOPB IOPA AFIO
Res.
RST RST RST RST RST RST RST RST RST RST RST RST RST RST RST
rw rw rw rw rw rw rw rw rw rw rw rw rw rw Res. rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ADC3 USAR TIM8 SPI1 TIM1 ADC2 ADC1 IOPG IOPF IOPE IOPD IOPC IOPB IOPA AFIO
EN T1EN EN EN EN EN EN EN EN EN EN EN EN EN EN
Res.
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
DAC PWR BKP CAN USB I2C2 I2C1 UART5E UART4 USART USART
Reserved Res. Res. Res.
EN EN EN EN EN EN EN N EN 3EN 2EN
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw Res. rw Res. rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
BDRST
Reserved
rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
LSI
LSION
RDY
Reserved
r rw
Offset Register
9
8
7
6
5
4
3
2
1
0
PLL RDY
HSERDY
HSEBYP
HSIRDY
PLL ON
CSSON
HSEON
HSION
Reserved
RCC_CR HSICAL[7:0] HSITRIM[4:0]
0x000 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1
PLLXTPRE
USBPRE
PLLSRC
ADC
Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
HSERDYIE
LSERDYIE
HSERDYC
PLLRDYIE
HSERDYF
LSERDYC
HSIRDYIE
PLLRDYC
LSERDYF
LSIRDYIE
HSIRDYC
PLLRDYF
HSIRDYF
LSIRDYC
LSIRDYF
Reserved
Reserved
Reserved
CSSC
CSSF
RCC_CIR
0x008 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
USART1RST
ADC3RST
ADC2RST
ADC1RST
IOPGRST
IOPDRST
IOPCRST
IOPERST
IOPBRST
IOPFRST
AFIORST
Reserved
TIM8RST
TIM1RST
IOPARST
SPI1RST
RCC_APB2RSTR
0x00C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
USART3RST
USART2RST
WWDGRST
UART5RST
UART4RST
PWRRST
TIM4RST
TIM3RST
TIM2RST
SPI3RST
SPI2RST
CANRST
I2C2RST
I2C1RST
USBRST
DACRST
BKPRST
TM7RST
TM6RST
TM5RST
Reserved
Reserved
Reserved
Reserved
RCC_APB1RSTR Reser
0x010 Reserved
ved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x01C
Offset
RM0008
Table 15.
RCC_CSR
Register
Reset value
Reset value
Reset value
Reset value
Reset value
RCC_BDCR
RCC_AHBENR
RCC_APB1ENR
RCC_APB2ENR
0
LPWRSTF 31
Reserved
0
WWDGRSTF 30
0
0
IWDGRSTF DACEN 29
0
0
SFTRSTF PWREN 28
1
0
PORRSTF BKPEN 27
1
PINRSTF Reserved 26
0
Reserved CANEN 25
0
RMVF Reserved 24
0 USBEN
Reserved
23
Reserved
I2C2EN 22
0
I2C1EN 21
0
UART5EN
Reserved
20
0
UART4EN 19
0
USART3EN 18
0
USART2EN 17
BDRST Reserved 16
RCC register map and reset values (continued)
0
0
0
SPI2EN USART1EN 14
0
TIM8EN 13
Reserved
0
SPI1EN 12
Reserved
0
0
WWDGEN TIM1EN
Reserved
11
0
0
ADC2EN SDIOEN
Refer to Table 1 on page 41 for the register boundary addresses.
10
0
0
ADC1EN Reserved 9
SEL
[1:0]
RTC
0
0
0
IOPGEN FSMCEN 8
0
IOPFEN Reserved
Reserved
7
0
0
IOPEEN CRCEN 6
0
0
4
0
0
103/995
Low-, medium- and high-density reset and clock control (RCC)
0
Connectivity line devices: reset and clock control (RCC) RM0008
7.1 Reset
There are three types of reset, defined as system Reset, power Reset and backup domain
Reset.
Software reset
The SYSRESETREQ bit in Cortex™-M3 Application Interrupt and Reset Control Register
must be set to force a software reset on the device. Refer to the Cortex™-M3 technical
reference manual for more details.
RPU
External System reset
reset Filter
NRST
WWDG reset
Pulse
IWDG reset
generator
Power reset
(min 20 µs)
Software reset
Low-power management reset
ai16095
7.2 Clocks
Three different clock sources can be used to drive the system clock (SYSCLK):
● HSI oscillator clock
● HSE oscillator clock
● PLL clock
The devices have the following two secondary clock sources:
● 40 kHz low speed internal RC (LSI RC) which drives the independent watchdog and
optionally the RTC used for Auto-wakeup from Stop/Standby mode.
● 32.768 kHz low speed external crystal (LSE crystal) which optionally drives the real-
time clock (RTCCLK)
Each clock source can be switched on or off independently when it is not used, to optimize
power consumption.
LSI
OSC32_IN 32.768 kHz to RTC
LSE LSE
RTCCLK
OSC32_OUT OSC
/128
CSS
RTCSEL[1:0]
HSE
MCO[3:0]
HCLK to AHB bus, core memory and DMA
HSE
HSI /2 to Cortex System timer
MCO PLLCLK/2 FCLK Cortex free running clock
PLL2CLK 36 MHz max
PLL3CLK/2 APB1 prescaler PCLK1
PLL3CLK /1, 2, 4, 8, 16 Peripheral clock enable to APB1 peripherals
XT1
to TIM2,3,4,5,
TIM2,3,4,5,6,7 6&7
If(APB1 prescaler =1) x1
SYSCLK AHB prescaler
72 MHz max. else x2 TIMxCLK
/1,/2 ../512
(see note1) Peripheral clock enable
72 MHz max
APB2 prescaler PCLK2
/1, 2, 4, 8, 16 Peripheral clock enable to APB2 peripherals
Ethernet
PHY
TIM1
to TIM1
If(APB2 prescaler =1) x1
else x2 TIMxCLK
ETH_MII_TX_CLK MACTXCLK Peripheral clock enable
MII_RMII_SEL
/2, /20
in AFIO_MAPR
to Ethernet MAC
ETH_MII_RX_CLK MACRXCLK ADC prescaler ADCCLK to ADC1,2
/2, 4, 6, 8 14 MHz max
MACRMIICLK
ai15699c
1. When the HSI is used as a PLL clock input, the maximum system clock frequency that can be achieved is
36 MHz.
2. For full details about the internal and external clock source characteristics, please refer to the “Electrical
characteristics” section in your device datasheet.
The advanced clock controller features 3 PLLs to provide a high degree of flexibility to the
application in the choice of the external crystal or oscillator to run the core and peripherals
at the highest frequency and guarantee the appropriate frequency for the Ethernet and USB
OTG FS.
A single 25 MHz crystal can clock the entire system and all peripherals including the
Ethernet and USB OTG FS peripherals. In order to achieve high-quality audio performance,
an audio crystal can be used. In this case, the I2S master clock can generate all standard
sampling frequencies from 8 kHz to 96 kHz with less than 0.5% accuracy.
For more details about clock configuration for applications requiring Ethernet, USB OTG FS
and/or I2S (audio), please refer to "Appendix A Applicative block diagrams" in your
connectivity line device datasheet.
Several prescalers allow the configuration of the AHB frequency, the high speed APB
(APB2) and the low speed APB (APB1) domains. The maximum frequency of the AHB and
the APB2 domains is 72 MHz. The maximum allowed frequency of the APB1 domain is
36 MHz.
All peripheral clocks are derived from the system clock (SYSCLK) except:
● The Flash memory programming interface clock which is always the HSI clock
● The USB OTG FS 48MHz clock which is derived from the PLL VCO clock
● The I2S2 and I2S3 clocks which can also be derived from the PLL3 VCO clock
(selection by software)
● The Ethernet MAC clocks (TX, RX and RMII) which are provided from the external
PHY. For further information on Ethernet configuration, please refer to Section 27.4.4:
MII/RMII selection.
The RCC feeds the Cortex System Timer (SysTick) external clock with the AHB clock
(HCLK) divided by 8. The SysTick can work either with this clock or with the Cortex clock
(HCLK), configurable in the SysTick Control and Status Register. The ADCs are clocked by
the clock of the High Speed domain (APB2) divided by 2, 4, 6 or 8.
The timer clock frequencies are automatically fixed by hardware. There are two cases:
1. if the APB prescaler is 1, the timer clock frequencies are set to the same frequency as
that of the APB domain to which the timers are connected.
2. otherwise, they are set to twice (×2) the frequency of the APB domain to which the
timers are connected.
FCLK acts as Cortex™-M3 free running clock. For more details refer to the ARM Cortex™-
M3 Technical Reference Manual.
OSC_OUT
External clock
(HiZ)
External
source
OSC_IN OSC_OUT
Crystal/ceramic
resonators
CL1 CL2
Load
capacitors
Calibration
RC oscillator frequencies can vary from one chip to another due to manufacturing process
variations, this is why each device is factory calibrated by ST for 1% accuracy at TA= 25 °C.
After reset, the factory calibration value is loaded in the HSICAL[7:0] bits in the Clock control
register (RCC_CR).
If the application is subject to voltage or temperature variations this may affect the RC
oscillator speed. You can trim the HSI frequency in the application using the HSITRIM[4:0]
bits in the Clock control register (RCC_CR).
The HSIRDY flag in the Clock control register (RCC_CR) indicates if the HSI RC is stable or
not. At startup, the HSI RC output clock is not released until this bit is set by hardware.
The HSI RC can be switched on and off using the HSION bit in the Clock control register
(RCC_CR).
The HSI signal can also be used as a backup source (Auxiliary clock) if the HSE crystal
oscillator fails. Refer to Section 7.2.7: Clock security system (CSS) on page 112.
7.2.3 PLLs
The main PLL provides a frequency multiplier starting from one of the following clock
sources:
● HSI clock divided by 2
● HSE or PLL2 clock through a configurable divider
Refer to Figure 11 and Clock control register (RCC_CR).
PLL2 and PLL3 are clocked by HSE through a specific configurable divider. Refer to
Figure 11 and Clock configuration register2 (RCC_CFGR2)
The configuration of each PLL (selection of clock source, predivision factor and
multiplication factor) must be done before enabling the PLL. Each PLL should be enabled
after its input clock becomes stable (ready flag). Once the PLL is enabled, these parameters
can not be changed.
When changing the entry clock source of the main PLL, the original clock source must be
switched off only after the selection of the new clock source (done through bit PLLSRC in
the Clock configuration register (RCC_CFGR)).
An interrupt can be generated when the PLL is ready if enabled in the Clock interrupt
register (RCC_CIR).
LSI calibration
The frequency dispersion of the Low Speed Internal RC (LSI) oscillator can be calibrated to
have accurate RTC time base and/or IWDG timeout (when LSI is used as clock source for
these peripherals) with an acceptable accuracy.
This calibration is performed by measuring the LSI clock frequency with respect to TIM5
input clock (TIM5CLK). According to this measurement done at the precision of the HSE
oscillator, the software can adjust the programmable 20-bit prescaler of the RTC to get an
accurate time base or can compute accurate IWDG timeout.
Use the following procedure to calibrate the LSI:
1. Enable TIM5 timer and configure channel4 in input capture mode
2. Set the TIM5CH4_IREMAP bit in the AFIO_MAPR register to connect the LSI clock
internally to TIM5 channel4 input capture for calibration purpose.
3. Measure the frequency of LSI clock using the TIM5 Capture/compare 4 event or
interrupt.
4. Use the measured LSI frequency to update the 20-bit prescaler of the RTC depending
on the desired time base and/or to compute the IWDG timeout.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw r r rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PLL3 PLL2 PLL HSE HSI LSE LSI PLL3 PLL2 PLL HSE HSI LSE LSI
CSSF
RDYIE RDYIE RDYIE RDYIE RDYIE RDYIE RDYIE RDYF RDYF RDYF RDYF RDYF RDYF RDYF
Res.
rw rw rw rw rw rw rw r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
USART1 SPI1 TIM1 ADC2 ADC1 IOPE IOPD IOPC IOPB IOPA AFIO
Res. RST Res. RST RST RST RST Reserved RST RST RST RST RST Res. RST
rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
ETH
MACR
Reserved XEN
rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ETHM
ETHM OTGF FLITFE SRAM DMA2 DMA1
ACTX CRCEN
ACEN SEN N EN EN EN
EN Res. Reserved Res. Res.
rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
USAR SPI1 TIM1 ADC2 ADC1 IOPE IOPD IOPC IOPB IOPA AFIO
T1EN EN EN EN EN EN EN EN EN EN EN
Res. Res. Reserved Res.
rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
DAC PWR BKP CAN2 CAN1 I2C2 I2C1 UART5E UART4 USART USART
Reserved EN EN EN EN EN EN EN N EN 3EN 2EN
Reserved Res.
rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
BDRST
Reserved
rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
LSI
LSION
RDY
Reserved
r rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ETHMAC OTGFS
RST RST
Res. Res. Reserved
rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Offset Register
9
8
7
6
5
4
3
2
1
0
PLL3 RDY
PLL2 RDY
PLL3 ON
PLL2 ON
PLL RDY
HSERDY
HSEBYP
HSIRDY
CSSON
HSEON
PLLON
HSION
Reserved
RCC_CR Reser HSICAL[7:0] HSITRIM[4:0]
0x000 Reserved
ved
Reset value 0 0 0 0 0 0 0 0 0 0 x x x x x x x x 1 0 0 0 0 1 1
OTGFSPRE
PLLXTPRE
PLLSRC
ADC
Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PLL3RDYIE
PLL2RDYIE
PLL3RDYC
PLL2RDYC
HSERDYIE
PLL3RDYF
PLL2RDYF
LSERDYIE
HSERDYC
PLLRDYIE
HSERDYF
LSERDYC
HSIRDYIE
PLLRDYC
LSERDYF
LSIRDYIE
HSIRDYC
PLLRDYF
HSIRDYF
Reserved
LSIRDYC
LSIRDYF
CSSC
CSSF
RCC_CIR
0x008 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
USART1RST
ADC2RST
ADC1RST
IOPDRST
IOPCRST
IOPERST
IOPBRST
AFIORST
Reserved
Reserved
Reserved
TIM1RST
IOPARST
SPI1RST
Reserved
RCC_APB2RSTR
0x00C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0
USART3RST
USART2RST
WWDGRST
UART5RST
UART4RST
CAN2RST
CAN1RST
PWRRST
TIM4RST
TIM3RST
TIM2RST
SPI3RST
SPI2RST
I2C2RST
I2C1RST
DACRST
BKPRST
TM7RST
TM6RST
TM5RST
Reserved
Reserved
Reserved
RCC_APB1RSTR Reser
0x010 Reserved
ved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
ETHMACRXEN
ETHMACTXEN
ETHMACEN
OTGFSEN
Reserved
Reserved
Reserved
SRAMEN
DM2AEN
DM1AEN
FLITFEN
CRCEN
RCC_AHBENR
0x014 Reserved Reserved
Reset value 0 0 0 0 0 1 1 0 0
USART1EN
Reserved
Reserved
ADC2EN
ADC1EN
IOPDEN
IOPCEN
IOPEEN
IOPBEN
AFIOEN
TIM1EN
IOPAEN
SPI1EN
Reserved
Reserved
0x018 RCC_APB2ENR
Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0
USART3EN
USART2EN
WWDGEN
UART5EN
UART4EN
CAN2EN
CAN1EN
PWREN
TIM7EN
TIM6EN
TIM5EN
TIM4EN
TIM3EN
TIM2EN
SPI3EN
SPI2EN
I2C2EN
I2C1EN
DACEN
BKPEN
Reserved
Reserved
Reserved
RCC_APB1ENR Reser
0x01C Reserved
ved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
LSERDY
LSEBYP
RTCEN
BDRST
LSEON
RTC
RCC_BDCR SEL
0x020 Reserved Reserved Reserved
[1:0]
Reset value 0 0 0 0 0 0 0
WWDGRSTF
IWDGRSTF
LPWRSTF
PORRSTF
SFTRSTF
PINRSTF
LSIRDY
Reserved
LSION
RMVF
RCC_CSR
0x024 Reserved
Reset value 0 0 0 0 1 1 0 0 0
ETHMACRST
OTGFSRST
Reserved
RCC_AHBSTR
0x028 Reserved Reserved
Reset value 0 0
PREDIV1SRC
I2S3SRC
I2S2SRC
PLL3MUL PLL2MUL
RCC_CFGR2 PREDIV2[3:0] PREDIV1[3:0]
0x02C Reserved [3:0] [3:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Read VDD
TTL Schmitt
Bit set/reset registers
Protection
trigger on/off diode
ai14781
on/off
Read
VDD_FT(1)
TTL Schmitt
Bit set/reset registers
trigger on/off
Write
ai14782
1. VDD_FT is a potential specific to five-volt tolerant I/Os and different from VDD.
00 Reserved
01 Max. output speed 10 MHz
10 Max. output speed 2 MHz
11 Max. output speed 50 MHz
or for reset only GPIOx_BRR) to select the bits you want to modify. The unselected bits will
not be modified.
VDD
on/off
Input data register
on
Read
VDD or VDD_FT(1)
Bit set/reset registers
TTL Schmitt
trigger protection
on/off diode
Write
Output data register
output driver
protection
diode
VSS
Read/write
ai14783
1. VDD_FT is a potential specific to five-volt tolerant I/Os and different from VDD.
ai14784
1. VDD_FT is a potential specific to five-volt tolerant I/Os and different from VDD.
TTL Schmitt
Protection
Bit set/reset registers
trigger
diode
Input driver I/O pin
Write
Output data register
ai14785
1. VDD_FT is a potential specific to five-volt tolerant I/Os and different from VDD.
Analog Input
To on-chip
peripheral
Input data register
Read off
0 VDD or VDD_FT(1)
Bit set/reset registers
TTL Schmitt
Protection
trigger
diode
Write
Output data register
Protection
diode
VSS
Read/write
From on-chip
peripheral
ai14786
As soon as the USB is enabled, these pins are connected to the USB
USB_DM / USB_DP
internal transceiver automatically.
FSMC_A[25:0]
Alternate function push-pull
FSMC_D[15:0]
FSMC_NOE
Alternate function push-pull
FSMC_NWE
FSMC_NE[4:1]
FSMC_NCE[3:2]
Alternate function push-pull
FSMC_NCE4_1
FSMC_NCE4_2
FSMC_NWAIT
Input floating/ Input pull-up
FSMC_CD
FSMC_NIOS16,
FSMC_INTR Input floating
FSMC_INT[3:2]
FSMC_NL
Alternate function push-pull
FSMC_NBL[1:0]
FSMC_NIORD, FSMC_NIOWR
Alternate function push-pull
FSMC_NREG
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
CNF7[1:0] MODE7[1:0] CNF6[1:0] MODE6[1:0] CNF5[1:0] MODE5[1:0] CNF4[1:0] MODE4[1:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CNF3[1:0] MODE3[1:0] CNF2[1:0] MODE2[1:0] CNF1[1:0] MODE1[1:0] CNF0[1:0] MODE0[1:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
CNF15[1:0] MODE15[1:0] CNF14[1:0] MODE14[1:0] CNF13[1:0] MODE13[1:0] CNF12[1:0] MODE12[1:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CNF11[1:0] MODE11[1:0] CNF10[1:0] MODE10[1:0] CNF9[1:0] MODE9[1:0] CNF8[1:0] MODE8[1:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
IDR15 IDR14 IDR13 IDR12 IDR11 IDR10 IDR9 IDR8 IDR7 IDR6 IDR5 IDR4 IDR3 IDR2 IDR1 IDR0
r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ODR15 ODR14 ODR13 ODR12 ODR11 ODR10 ODR9 ODR8 ODR7 ODR6 ODR5 ODR4 ODR3 ODR2 ODR1 ODR0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
BR15 BR14 BR13 BR12 BR11 BR10 BR9 BR8 BR7 BR6 BR5 BR4 BR3 BR2 BR1 BR0
w w w w w w w w w w w w w w w w
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
BS15 BS14 BS13 BS12 BS11 BS10 BS9 BS8 BS7 BS6 BS5 BS4 BS3 BS2 BS1 BS0
w w w w w w w w w w w w w w w w
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
BR15 BR14 BR13 BR12 BR11 BR10 BR9 BR8 BR7 BR6 BR5 BR4 BR3 BR2 BR1 BR0
w w w w w w w w w w w w w w w w
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
LCKK
Reserved
rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
LCK15 LCK14 LCK13 LCK12 LCK11 LCK10 LCK9 LCK8 LCK7 LCK6 LCK5 LCK4 LCK3 LCK2 LCK1 LCK0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
To optimize the number of free GPIOs during debugging, this mapping can be configured in
different ways by programming the SWJ_CFG[1:0] bits in the AF remap and debug I/O
configuration register (AFIO_MAPR). Refer to Table 33
Table 34. ADC1 external trigger injected conversion alternate function remapping(1)
Alternate function ADC1_ETRGINJ_REMAP = 0 ADC1_ETRGINJ_REMAP = 1
Table 35. ADC1 external trigger regular conversion alternate function remapping(1)
Alternate function ADC1_ETRGREG_REMAP = 0 ADC1_ETRGREG_REMAP = 1
Table 36. ADC2 external trigger injected conversion alternate function remapping(1)
Alternate function ADC2_ETRGINJ_REMAP = 0 ADC2_ETRGINJ_REMAP = 1
Table 37. ADC2 external trigger regular conversion alternate function remapping(1)
Alternate function ADC2_ETRGREG_REG = 0 ADC2_ETRGREG_REG = 1
Memory map and bit definitions for low-, medium- and high-density devices:
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
ADC2_ ADC2_ ADC1_ ADC1_
TIM5CH
SWJ_ ETRGR ETRGIN ETRGR ETRGIN
4_IREM
Reserved CFG[2:0] Reserved EG_RE J_REM EG_RE J_REM
AP
MAP AP MAP AP
w w w rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
USART USART
PD01_ CAN_REMAP TIM4_ TIM3_REMAP TIM2_REMAP TIM1_REMAP USART3_ I2C1_ SPI1_
2_ 1_
REMAP [1:0] REMAP [1:0] [1:0] [1:0] REMAP[1:0] REMAP REMAP
REMAP REMAP
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Bit 31 Reserved
Bit 30 PTP_PPS_REMAP: Ethernet PTP PPS remapping
This bit is set and cleared by software. It enables the Ethernet MAC PPS_PTS to be output
on the PB5 pin.
0: PTP_PPS not output on PB5 pin.
1: PTP_PPS is output on PB5 pin.
Note: This bit is available only in connectivity line devices and is reserved otherwise.
Bit 29 TIM2ITR1_IREMAP: TIM2 internal trigger 1 remapping
This bit is set and cleared by software. It controls the TIM2_ITR1 internal mapping.
0: Connect TIM2_ITR1 internally to the Ethernet PTP output for calibration purposes.
1: Connect USB OTG SOF (Start of Frame) output to TIM2_ITR1 for calibration purposes.
Note: This bit is available only in connectivity line devices and is reserved otherwise.
Bit 28 SPI3_REMAP: SPI3 remapping
This bit is set and cleared by software. It controls the mapping of SPI3 NSS, SCK, MISO,
MOSI alternate functions on the GPIO ports.
0: No remap (NSS/PA15, SCK/PB3, MISO/PB4, MOSI/PB5)
1: Remap (NSS/PA4, SCK/PC10, MISO/PC11, MOSI/PC12)
Note: This bit is available only in connectivity line devices and is reserved otherwise.
Bit 27 Reserved
Bits 26:24 SWJ_CFG[2:0]: Serial wire JTAG configuration
These bits are write-only (when read, the value is undefined). They are used to configure the
SWJ and trace alternate function I/Os. The SWJ (Serial Wire JTAG) supports JTAG or SWD
access to the Cortex debug port. The default state after reset is SWJ ON without trace. This
allows JTAG or SW mode to be enabled by sending a specific sequence on the JTMS /
JTCK pin.
000: Full SWJ (JTAG-DP + SW-DP): Reset State
001: Full SWJ (JTAG-DP + SW-DP) but without JNTRST
010: JTAG-DP Disabled and SW-DP Enabled
100: JTAG-DP Disabled and SW-DP Disabled
Other combinations: no effect
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
EXTI3[3:0] EXTI2[3:0] EXTI1[3:0] EXTI0[3:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
EXTI7[3:0] EXTI6[3:0] EXTI5[3:0] EXTI4[3:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
9
8
7
6
5
4
3
2
1
0
CNF7 MODE7 CNF6 MODE6 CNF5 MODE5 CNF4 MODE4 CNF3 MODE3 CNF2 MODE2 CNF1 MODE1 CNF0 MODE0
GPIOx_CRL
0x00 [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0]
Reset value 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0
CNF MODE1 CNF MODE1 CNF MODE1 CNF MODE1 CNF MODE1 CNF MODE1 CNF CNF
MODE9 MODE8
GPIOx_CRH 15 5 14 4 13 3 12 2 11 1 10 0 9 8
0x04 [1:0] [1:0]
[1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0] [1:0]
Reset value 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0
GPIOx_IDR IDR[15:0]l
0x08 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
GPIOx_ODR ODR[15:0]
0x0C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
GPIOx_BRR BR[15:0]
0x14 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
LCKK
GPIOx_LCKR LCK[15:0]
0x18 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Offset Register
9
8
7
6
5
4
3
2
1
0
EVOE
AFIO_EVCR PORT[2:0] PIN[3:0]
0x00 Reserved
Reset value 0 0 0 0 0 0 0
ADC2_ETRGREG_REMAP
ADC1_ETRGREG_REMAP
ADC2_ETRGINJ_REMAP
ADC1_ETRGINJ_REMAP
USART3_REMAP[1]
USART3_REMAP[0]
TIM5CH4_IREMAP
TIM3_REMPAP[1]
TIM3_REMPAP[0]
TIM2_REMPAP[1]
TIM2_REMPAP[0]
TIM1_REMPAP[1]
TIM1_REMPAP[0]
USART2_REMAP
USART1_REMAP
CAN1_REMAP[1]
CAN1_REMAP[0]
TIM4_REMPAP
PD01_REMAP
SPI1_REMAP
I2C1_REMAP
SWJ_CFG[2]
SWJ_CFG[1]
SWJ_CFG[0]
AFIO_MAPR
low-, medium-
0x04 and high-density Reserved Reserved
devices
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
USART3_REMAP[1]
USART3_REMAP[0]
TIM2ITR1_IREMAP
TIM5CH4_IREMAP
PTP_PPS_REMAP
TIM3_REMPAP[1]
TIM3_REMPAP[0]
TIM2_REMPAP[1]
TIM2_REMPAP[0]
TIM1_REMPAP[1]
TIM1_REMPAP[0]
USART2_REMAP
USART1_REMAP
CAN1_REMAP[1]
CAN1_REMAP[0]
TIM4_REMPAP
CAN2_REMAP
PD01_REMAP
MII_RMII_SEL
SPI3_REMAP
SPI1_REMAP
I2C1_REMAP
ETH_REMAP
SWJ_CFG[2]
SWJ_CFG[1]
SWJ_CFG[0]
AFIO_MAPR
Reserved
Reserved
Reserved
connectivity line
0x04
devices
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
AFIO_EXTICR3 EXTI11[3:0] EXTI10[3:0] EXTI9[3:0] EXTI8[3:0]
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Priority
Type of
Acronym Description Address
priority
- - - Reserved 0x0000_0000
-3 fixed Reset Reset 0x0000_0004
Non maskable interrupt. The RCC
-2 fixed NMI Clock Security System (CSS) is 0x0000_0008
linked to the NMI vector.
Position
Priority
Type of
Acronym Description Address
priority
Position
Priority
Type of
Acronym Description Address
priority
Position
Priority
Type of
Acronym Description Address
priority
Priority
Type of
Acronym Description Address
priority
- - - Reserved 0x0000_0000
-3 fixed Reset Reset 0x0000_0004
Non maskable interrupt. The RCC
-2 fixed NMI Clock Security System (CSS) is 0x0000_0008
linked to the NMI vector.
-1 fixed HardFault All class of fault 0x0000_000C
0 settable MemManage Memory management 0x0000_0010
1 settable BusFault Pre-fetch fault, memory access fault 0x0000_0014
2 settable UsageFault Undefined instruction or illegal state 0x0000_0018
0x0000_001C -
- - - Reserved
0x0000_002B
System service call via SWI
3 settable SVCall 0x0000_002C
instruction
4 settable Debug Monitor Debug Monitor 0x0000_0030
- - - Reserved 0x0000_0034
5 settable PendSV Pendable request for system service 0x0000_0038
6 settable SysTick System tick timer 0x0000_003C
0 7 settable WWDG Window watchdog interrupt 0x0000_0040
PVD through EXTI Line detection
1 8 settable PVD 0x0000_0044
interrupt
2 9 settable TAMPER Tamper interrupt 0x0000_0048
Position
Priority
Type of
Acronym Description Address
priority
Position
Priority
Type of
Acronym Description Address
priority
20 20 20 20 20
To NVIC Interrupt 20 20 20 20 20
Controller
.
20
Event
mask
register
ai15801
In connectivity line devices, Ethernet wakeup events also have the WFE wakeup capability.
To use an external line as a wakeup event, refer to Section 9.2.4: Functional description.
PA0
PB0
PC0
EXTI0
PD0
PE0
PF0
PG0
PA1
PB1
PC1
EXTI1
PD1
PE1
PF1
PG1
PA15
PB15
PC15
EXTI15
PD15
PE15
PF15
PG15
1. To configure the AFIO_EXTICRx for the mapping of external interrupt/event lines onto GPIOs, the AFIO
clock should first be enabled. Refer to Section 6.3.7: APB2 peripheral clock enable register
(RCC_APB2ENR) for low-, medium- and high-density devices and, to Section 7.3.7: APB2 peripheral clock
enable register (RCC_APB2ENR) for connectivity line devices.
The four other EXTI lines are connected as follows:
● EXTI line 16 is connected to the PVD output
● EXTI line 17 is connected to the RTC Alarm event
● EXTI line 18 is connected to the USB Wakeup event
● EXTI line 19 is connected to the Ethernet Wakeup event (available only in connectivity
line devices)
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
MR19 MR18 MR17 MR16
Reserved
rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MR15 MR14 MR13 MR12 MR11 MR10 MR9 MR8 MR7 MR6 MR5 MR4 MR3 MR2 MR1 MR0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
MR19 MR18 MR17 MR16
Reserved
rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MR15 MR14 MR13 MR12 MR11 MR10 MR9 MR8 MR7 MR6 MR5 MR4 MR3 MR2 MR1 MR0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
TR19 TR18 TR17 TR16
Reserved
rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TR15 TR14 TR13 TR12 TR11 TR10 TR9 TR8 TR7 TR6 TR5 TR4 TR3 TR2 TR1 TR0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: The external wakeup lines are edge triggered, no glitches must be generated on these lines.
If a rising edge on external interrupt line occurs during writing of EXTI_RTSR register, the
pending bit will not be set.
Rising and Falling edge triggers can be set for the same interrupt line. In this configuration,
both generate a trigger condition.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
TR19 TR18 TR17 TR16
Reserved
rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TR15 TR14 TR13 TR12 TR11 TR10 TR9 TR8 TR7 TR6 TR5 TR4 TR3 TR2 TR1 TR0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: The external wakeup lines are edge triggered, no glitches must be generated on these lines.
If a falling edge on external interrupt line occurs during writing of EXTI_FTSR register, the
pending bit will not be set.
Rising and Falling edge triggers can be set for the same interrupt line. In this configuration,
both generate a trigger condition.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
SWIER SWIER SWIER SWIER
Reserved 19 18 17 16
rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER SWIER
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
PR19 PR18 PR17 PR16
Reserved
rc_w1 rc_w1 rc_w1 rc_w1
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PR15 PR14 PR13 PR12 PR11 PR10 PR9 PR8 PR7 PR6 PR5 PR4 PR3 PR2 PR1 PR0
rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1 rc_w1
Table 54. External interrupt/event controller register map and reset values
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
EXTI_IMR MR[19:0]
0x00 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EXTI_EMR MR[19:0]
0x04 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EXTI_RTSR TR[19:0]
0x08 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EXTI_FTSR TR[19:0]
0x0C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EXTI_SWIER SWIER[19:0]
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EXTI_PR PR[19:0]
0x14 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bus matrix
DMA1 Ch.1 DMA
Reset & clock
Ch.2 control (RCC)
Ch.7 Bridge 2
Bridge 1 APB2
APB1
Arbiter DMA
Arbiter
AHB Slave
Ethernet MAC
USB OTG FS
ai15811
1. The DMA2 controller is available only in high-density and connectifity line devices.
2. SPI/I2S3, UART4, TIM5, TIM6, TIM7 and DAC DMA requests are available only in high-density and
connectivity line devices.
3. ADC3, SDIO and TIM8 DMA requests are available only in high-density devices.
release the Acknowledge. If there are more requests, the peripheral can initiate the next
transaction.
In summary, each DMA transfer consists of three operations:
● The loading of data from the peripheral data register or a location in memory
addressed through an internal current peripheral/memory address register. The start
address used for the first transfer is the base peripheral/memory address programmed
in the DMA_CPARx or DMA_CMARx register
● The storage of the data loaded to the peripheral data register or a location in memory
addressed through an internal current peripheral/memory address register. The start
address used for the first transfer is the base peripheral/memory address programmed
in the DMA_CPARx or DMA_CMARx register
● The post-decrementing of the DMA_CNDTRx register, which contains the number of
transactions that have still to be performed.
10.3.2 Arbiter
The arbiter manages the channel requests based on their priority and launches the
peripheral/memory access sequences.
The priorities are managed in two stages:
● Software: each channel priority can be configured in the DMA_CCRx register. There
are four levels:
– Very high priority
– High priority
– Medium priority
– Low priority
● Hardware: if 2 requests have the same software priority level, the channel with the
lowest number will get priority versus the channel with the highest number. For
example, channel 2 gets priority over channel 4.
Note: In high-density and connectivity line devices, the DMA1 controller has priority over the
DMA2 controller.
Pointer incrementation
Peripheral and memory pointers can optionally be automatically post-incremented after
each transaction depending on the PINC and MINC bits in the DMA_CCRx register. If
incremented mode is enabled, the address of the next transfer will be the address of the
previous one incremented by 1, 2 or 4 depending on the chosen data size. The first transfer
address is the one programmed in the DMA_CPARx/DMA_CMARx registers. During
transfer operations, these registers keep the initially programmed value. The current transfer
addresses (in the current internal peripheral/memory address register) are not accessible by
software.
If the channel is configured in noncircular mode, no DMA request is served after the last
transfer (that is once the number of data items to be transferred has reached zero). In order
to reload a new number of data items to be transferred into the DMA_CNDTRx register, the
DMA channel must be disabled.
Note: If a DMA channel is disabled, the DMA registers are not reset. The DMA channel registers
(DMA_CCRx, DMA_CPARx and DMA_CMARx) retain the initial values programmed during
the channel configuration phase.
In circular mode, after the last transfer, the DMA_CNDTRx register is automatically reloaded
with the initially programmed value. The current internal address registers are reloaded with
the base address vaules from the DMA_CPARx/DMA_CMARx registers.
Circular mode
Circular mode is available to handle circular buffers and continuous data flows (e.g. ADC
scan mode). This feature can be enabled using the CIRC bit in the DMA_CCRx register.
When circular mode is activated, the number of data to be transferred is automatically
reloaded with the initial value programmed during the channel configuration phase, and the
DMA requests continue to be served.
Memory-to-memory mode
The DMA channels can also work without being triggered by a request from a peripheral.
This mode is called Memory to Memory mode.
If the MEM2MEM bit in the DMA_CCRx register is set, then the channel initiates transfers as
soon as it is enabled by software by setting the Enable bit (EN) in the DMA_CCRx register.
The transfer stops once the DMA_CNDTRx register reaches zero. Memory to Memory
mode may not be used at the same time as Circular mode.
Table 55. Programmable data width & endian behavior (when bits PINC = MINC = 1)
Number
Source of data Destination
Destination Source content:
port items to Transfer operations content:
port width address / data
width transfer address / data
(NDT)
@0x0 / B0 1: READ B0[7:0] @0x0 then WRITE 00B0[15:0] @0x0 @0x0 / 00B0
@0x1 / B1 2: READ B1[7:0] @0x1 then WRITE 00B1[15:0] @0x2 @0x2 / 00B1
8 16 4
@0x2 / B2 3: READ B3[7:0] @0x2 then WRITE 00B2[15:0] @0x4 @0x4 / 00B2
@0x3 / B3 4: READ B4[7:0] @0x3 then WRITE 00B3[15:0] @0x6 @0x6 / 00B3
@0x0 / B0 1: READ B0[7:0] @0x0 then WRITE 000000B0[31:0] @0x0 @0x0 / 000000B0
@0x1 / B1 2: READ B1[7:0] @0x1 then WRITE 000000B1[31:0] @0x4 @0x4 / 000000B1
8 32 4
@0x2 / B2 3: READ B3[7:0] @0x2 then WRITE 000000B2[31:0] @0x8 @0x8 / 000000B2
@0x3 / B3 4: READ B4[7:0] @0x3 then WRITE 000000B3[31:0] @0xC @0xC / 000000B3
@0x0 / B1B0 1: READ B1B0[15:0] @0x0 then WRITE B0[7:0] @0x0 @0x0 / B0
@0x2 / B3B2 2: READ B3B2[15:0] @0x2 then WRITE B2[7:0] @0x1 @0x1 / B2
16 8 4
@0x4 / B5B4 3: READ B5B4[15:0] @0x4 then WRITE B4[7:0] @0x2 @0x2 / B4
@0x6 / B7B6 4: READ B7B6[15:0] @0x6 then WRITE B6[7:0] @0x3 @0x3 / B6
@0x0 / B1B0 1: READ B1B0[15:0] @0x0 then WRITE B1B0[15:0] @0x0 @0x0 / B1B0
@0x2 / B3B2 2: READ B3B2[15:0] @0x2 then WRITE B3B2[15:0] @0x2 @0x2 / B3B2
16 16 4
@0x4 / B5B4 3: READ B5B4[15:0] @0x4 then WRITE B5B4[15:0] @0x4 @0x4 / B5B4
@0x6 / B7B6 4: READ B7B6[15:0] @0x6 then WRITE B7B6[15:0] @0x6 @0x6 / B7B6
@0x0 / B1B0 1: READ B1B0[15:0] @0x0 then WRITE 0000B1B0[31:0] @0x0 @0x0 / 0000B1B0
@0x2 / B3B2 2: READ B3B2[15:0] @0x2 then WRITE 0000B3B2[31:0] @0x4 @0x4 / 0000B3B2
16 32 4
@0x4 / B5B4 3: READ B5B4[15:0] @0x4 then WRITE 0000B5B4[31:0] @0x8 @0x8 / 0000B5B4
@0x6 / B7B6 4: READ B7B6[15:0] @0x6 then WRITE 0000B7B6[31:0] @0xC @0xC / 0000B7B6
@0x0 / B3B2B1B0 1: READ B3B2B1B0[31:0] @0x0 then WRITE B0[7:0] @0x0 @0x0 / B0
@0x4 / B7B6B5B4 2: READ B7B6B5B4[31:0] @0x4 then WRITE B4[7:0] @0x1 @0x1 / B4
32 8 4
@0x8 / BBBAB9B8 3: READ BBBAB9B8[31:0] @0x8 then WRITE B8[7:0] @0x2 @0x2 / B8
@0xC / BFBEBDBC 4: READ BFBEBDBC[31:0] @0xC then WRITE BC[7:0] @0x3 @0x3 / BC
@0x0 / B3B2B1B0 1: READ B3B2B1B0[31:0] @0x0 then WRITE B1B0[7:0] @0x0 @0x0 / B1B0
@0x4 / B7B6B5B4 2: READ B7B6B5B4[31:0] @0x4 then WRITE B5B4[7:0] @0x1 @0x2 / B5B4
32 16 4
@0x8 / BBBAB9B8 3: READ BBBAB9B8[31:0] @0x8 then WRITE B9B8[7:0] @0x2 @0x4 / B9B8
@0xC / BFBEBDBC 4: READ BFBEBDBC[31:0] @0xC then WRITE BDBC[7:0] @0x3 @0x6 / BDBC
@0x0 / B3B2B1B0 1: READ B3B2B1B0[31:0] @0x0 then WRITE B3B2B1B0[31:0] @0x0 @0x0 / B3B2B1B0
@0x4 / B7B6B5B4 2: READ B7B6B5B4[31:0] @0x4 then WRITE B7B6B5B4[31:0] @0x4 @0x4 / B7B6B5B4
32 32 4
@0x8 / BBBAB9B8 3: READ BBBAB9B8[31:0] @0x8 then WRITE BBBAB9B8[31:0] @0x8 @0x8 / BBBAB9B8
@0xC / BFBEBDBC 4: READ BFBEBDBC[31:0] @0xC then WRITE BFBEBDBC[31:0] @0xC @0xC / BFBEBDBC
Addressing an AHB peripheral that does not support byte or halfword write
operations
When the DMA initiates an AHB byte or halfword write operation, the data are duplicated on
the unused lanes of the HWDATA[31:0] bus. So when the used AHB slave peripheral does
not support byte or halfword write operations (when HSIZE is not used by the peripheral)
and does not generate any error, the DMA writes the 32 HWDATA bits as shown in the two
examples below:
● To write the halfword “0xABCD”, the DMA sets the HWDATA bus to “0xABCDABCD”
with HSIZE = HalfWord
● To write the byte “0xAB”, the DMA sets the HWDATA bus to “0xABABABAB” with
HSIZE = Byte
Assuming that the AHB/APB bridge is an AHB 32-bit slave peripheral that does not take the
HSIZE data into account, it will transform any AHB byte or halfword operation into a 32-bit
APB operation in the following manner:
● an AHB byte write operation of the data “0xB0” to 0x0 (or to 0x1, 0x2 or 0x3) will be
converted to an APB word write operation of the data “0xB0B0B0B0” to 0x0
● an AHB halfword write operation of the data “0xB1B0” to 0x0 (or to 0x2) will be
converted to an APB word write operation of the data “0xB1B0B1B0” to 0x0
For instance, if you want to write the APB backup registers (16-bit registers aligned to a 32-
bit address boundary), you must configure the memory source size (MSIZE) to “16-bit” and
the peripheral destination size (PSIZE) to “32-bit”.
10.3.6 Interrupts
An interrupt can be produced on a Half-transfer, Transfer complete or Transfer error for each
DMA channel. Separate interrupt enable bits are available for flexibility.
Note: In high-density devices, DMA2 Channel4 and DMA2 Channel5 interrupts are mapped onto
the same interrupt vector. In connectivity line devices, DMA2 Channel4 and DMA2
Channel5 interrupts have separate interrupt vectors. All other DMA1 and DMA2 Channel
interrupts have their own interrupt vector.
Channel 1 EN bit
USART3_TX
TIM1_CH1 HW request 2
Channel 2
TIM2_UP
TIM3_CH3 SW trigger (MEM2MEM bit)
SPI1_RX
Channel 2 EN bit
USART3_RX
TIM1_CH2 HW request 3
Channel 3
TIM3_CH4
TIM3_UP
SW trigger (MEM2MEM bit)
SPI1_TX
internal
USART1_TX Channel 3 EN bit
TIM1_CH4 DMA1
TIM1_TRIG HW request 4 request
Channel 4
TIM1_COM
TIM4_CH2
SW trigger (MEM2MEM bit)
SPI/I2S2_RX
I2C2_TX
Channel 4 EN bit
USART1_RX
TIM1_UP
HW request 5
SPI/I2S2_TX Channel 5
TIM2_CH1
TIM4_CH3 SW trigger (MEM2MEM bit)
I2C2_RX
Channel 5 EN bit
USART2_RX
TIM1_CH3 HW REQUEST 6
Channel 6
TIM3_CH1
TIM3_TRIG SW TRIGGER (MEM2MEM bit)
I2C1_TX
Channel 6 EN bit
USART2_TX HW request 7
TIM2_CH2 Channel 7
TIM2_CH4 Low priority
SW trigger (MEM2MEM bit)
TIM4_UP
I2C1_RX
Channel 7 EN bit
ADC1 ADC1
2
SPI/I S SPI1_RX SPI1_TX SPI/I2S2_RX SPI/I2S2_TX
USART USART3_TX USART3_RX USART1_TX USART1_RX USART2_RX USART2_TX
I2C I2C2_TX I2C2_RX I2C1_TX I2C1_RX
TIM1_CH4
TIM1 TIM1_CH1 TIM1_CH2 TIM1_TRIG TIM1_UP TIM1_CH3
TIM1_COM
TIM2_CH2
TIM2 TIM2_CH3 TIM2_UP TIM2_CH1
TIM2_CH4
TIM3_CH4 TIM3_CH1
TIM3 TIM3_CH3
TIM3_UP TIM3_TRIG
TIM4 TIM4_CH1 TIM4_CH2 TIM4_CH3 TIM4_UP
DMA2 controller
The 5 requests from the peripherals (TIMx[5,6,7,8], ADC3, SPI/I2S3, UART4,
DAC_Channel[1,2]and SDIO) are simply logically ORed before entering to the DMA2, this
means that only one request must be enabled at a time. Refer to Figure 24: DMA2 request
mapping.
The peripheral DMA requests can be independently activated/de-activated by programming
the DMA control bit in the registers of the corresponding peripheral.
Note: The DMA2 controller and its relative requests are available only in high-density and
connectivity line devices.
TIM8_CH1 HW request 3
Channel 3
UART4_RX
TIM6_UP/DAC_Channel1
SW trigger (MEM2MEM bit)
internal
Channel 3 EN bit
DMA2
TIM5_CH2 HW request 4 request
SDIO Channel 4
TIM7_UP/DAC_Channel2
SW trigger (MEM2MEM bit)
Channel 4 EN bit
ADC3
HW request 5
TIM8_CH2 Channel 5
TIM5_CH1 LOW PRIORITY
UART4_TX SW trigger (MEM2MEM bit)
Channel 5 EN bit
ADC3(1) ADC3
SPI/I2S3 SPI/I2S3_RX SPI/I2S3_TX
UART4 UART4_RX UART4_TX
(1)
SDIO SDIO
TIM5_CH4 TIM5_CH3
TIM5 TIM5_CH2 TIM5_CH1
TIM5_TRIG TIM5_UP
TIM6/ TIM6_UP/
DAC_Channel1 DAC_Channel1
TIM7/ TIM7_UP/
DAC_Channel2 DAC_Channel2
TIM8_CH4
TIM8_CH3
TIM8(1) TIM8_TRIG TIM8_CH1 TIM8_CH2
TIM8_UP
TIM8_COM
1. ADC3, SDIO and TIM8 DMA requests are available only in high-density devices.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
TEIF7 HTIF7 TCIF7 GIF7 TEIF6 HTIF6 TCIF6 GIF6 TEIF5 HTIF5 TCIF5 GIF5
Reserved
r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TEIF4 HTIF4 TCIF4 GIF4 TEIF3 HTIF3 TCIF3 GIF3 TEIF2 HTIF2 TCIF2 GIF2 TEIF1 HTIF1 TCIF1 GIF1
r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
CTEIF CHTIF CTCIF CGIF CTEIF CHTIF CTCIF CGIF CTEIF CHTIF CTCIF CGIF
7 7 7 7 6 6 6 6 5 5 5 5
Reserved
w w w w w w w w w w w w
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CTEIF CHTIF CTCIF CGIF CTEIF CHTIF CTCIF CGIF CTEIF CHTIF CTCIF CGIF CTEIF CHTIF CTCIF CGIF
4 4 4 4 3 3 3 3 2 2 2 2 1 1 1 1
w w w w w w w w w w w w w w w w
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MEM2
PL[1:0] MSIZE[1:0] PSIZE[1:0] MINC PINC CIRC DIR TEIE HTIE TCIE EN
MEM
Res.
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NDT
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PA
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MA
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
HTIF7
HTIF6
HTIF5
HTIF4
HTIF3
HTIF2
HTIF1
TCIF7
TCIF6
TCIF5
TCIF4
TCIF3
TCIF2
TCIF1
TEIF7
TEIF6
TEIF5
TEIF4
TEIF3
TEIF2
TEIF1
GIF7
GIF6
GIF5
GIF4
GIF3
GIF2
GIF1
DMA_ISR
0x000 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CTCIF7
CTCIF6
CTCIF5
CTCIF4
CTCIF3
CTCIF2
CTCIF1
CHTIF7
CHTIF6
CHTIF5
CHTIF4
CHTIF3
CHTIF2
CHTIF1
CTEIF7
CTEIF6
CTEIF5
CTEIF4
CTEIF3
CTEIF2
CTEIF1
CGIF7
CGIF6
CGIF5
CGIF4
CGIF3
CGIF2
CGIF1
DMA_IFCR
0x004 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
MEM2MEM
M PSIZ
MINC
CIRC
PINC
HTIE
TCIE
PL
TEIE
DIR
EN
DMA_CCR1 SIZE E
0x008 Reserved [1:0]
[1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CNDTR1 NDT[15:0]
0x00C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CPAR1 PA[31:0]
0x010
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CMAR1 MA[31:0]
0x014
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x018 Reserved
MEM2MEM
M PSIZ
MINC
CIRC
PINC
HTIE
TCIE
PL
TEIE
DIR
EN
DMA_CCR2 SIZE E
0x01C Reserved [1:0]
[1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CNDTR2 NDT[15:0]
0x020 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CPAR2 PA[31:0]
0x024
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CMAR2 MA[31:0]
0x028
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x02C Reserved
MEM2MEM
M PSIZ
MINC
CIRC
PINC
HTIE
TCIE
PL
TEIE
DIR
DMA_CCR3 SIZE E EN
0x030 Reserved [1:0]
[1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CNDTR3 NDT[15:0]
0x034 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CPAR3 PA[31:0]
0x038
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CMAR3 MA[31:0]
0x03C
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x040 Reserved
MEM2MEM
M PSIZ
MINC
CIRC
PINC
HTIE
TCIE
PL
TEIE
DIR
EN
DMA_CCR4 SIZE E
0x044 Reserved [1:0]
[1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CNDTR4 NDT[15:0]
0x048 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
DMA_CPAR4 PA[31:0]
0x04C
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CMAR4 MA[31:0]
0x050
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x054 Reserved
MEM2MEM
M PSIZ
MINC
CIRC
PINC
HTIE
TCIE
PL
TEIE
DIR
EN
DMA_CCR5 SIZE E
0x058 Reserved [1:0]
[1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CNDTR5 NDT[15:0]
0x05C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CPAR5 PA[31:0]
0x060
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CMAR5 MA[31:0]
0x064
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x068 Reserved
MEM2MEM
M PSIZ
MINC
CIRC
PINC
HTIE
TCIE
PL
TEIE
DIR
EN
DMA_CCR6 SIZE E
0x06C Reserved [1:0]
[1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CNDTR6 NDT[15:0]
0x070 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CPAR6 PA[31:0]
0x074
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CMAR6 MA[31:0]
0x078
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x07C Reserved
MEM2MEM
M PSIZ
MINC
CIRC
PINC
HTIE
TCIE
PL
TEIE
DIR
EN
DMA_CCR7 SIZE E
0x080 Reserved [1:0]
[1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CNDTR7 NDT[15:0]
0x084 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CPAR7 PA[31:0]
0x088
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA_CMAR7 MA[31:0]
0x08C
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x090 Reserved
Interrupt
Flags enable bits
End of conversion
EOC EOCIE
End of injected conversion ADC Interrupt to NVIC
JEOC JEOCIE
Analog watchdog event
AWD AWDIE
Analog watchdog
Compare Result
High Threshold (12 bits)
Low Threshold (12 bits)
Address/data bus
Injected data registers
VREF+ (4 x 16 bits)
VREF-
Regular data register
VDDA (16 bits)
VSSA
Analog DMA request
MUX
ADCx_IN0
ADCx_IN1
GPIO up to 4 Injected
ADCCLK
Ports channels Analog to digital
up to 16 converter
Regular
ADCx_IN15 channels
Temp. sensor
VREFINT
TIM1_TRGO
TIM1_CH4 JEXTRIG
TIM2_TRGO bit
TIM2_CH1
Start trigger
TIM3_CH4
TIM4_TRGO (injected group)
EXTI_15
TIM8_CH4(2)
JEXTSEL[2:0] bits
EXTRIG TIM1_TRGO
ADCx-ETRGINJ_REMAP bit JEXTRIG
bit TIM1_CH4
bit
TIM4_CH3
TIM8_CH2 Start trigger
TIM8_CH4 (injected group)
EXTSEL[2:0] bits TIM5_TRGO
TIM1_CH1 TIM5_CH4
TIM1_CH2 Start trigger
TIM1_CH3 EXTSEL[2:0] bits
(regular group)
TIM2_CH2
TIM3_TRGO TIM3_CH1
TIM2_CH3 EXTRIG
TIM4_CH4 bit
TIM1_CH3
TIM8_CH1 Start trigger
EXTI_11 TIM8_TRGO (regular group)
(2)
TIM8_TRGO TIM5_CH1
TIM5_CH3
ADCx_ETRGREG_REMAP bit
Triggers for ADC3(1)
ai14802d
1. ADC3 has regular and injected conversion triggers different from those of ADC1 and ADC2.
2. TIM8_CH4 and TIM8_TRGO with their corresponding remap bits exist only in High-density products.
Input, analog reference The higher/positive reference voltage for the ADC,
VREF+
positive 2.4 V VREF+ VDDA
Analog power supply equal to VDD and
VDDA Input, analog supply
2.4 V VDDA VDD (3.6 V)
Input, analog reference The lower/negative reference voltage for the ADC,
VREF-
negative VREF- = VSSA
Input, analog supply
VSSA Ground for analog power supply equal to VSS
ground
ADCx_IN[15:0] Analog input signals 16 analog input channels
ADC_CLK
SET ADON
None x 0 0
All injected channels 0 0 1
All regular channels 0 1 0
All regular and injected channels 0 1 1
Single(1) injected channel 1 0 1
Single(1) regular channel 1 1 0
Single (1) regular or injected channel 1 1 1
1. Selected by AWDCH[4:0] bits
Auto-injection
If the JAUTO bit is set, then the injected group channels are automatically converted after
the regular group channels. This can be used to convert a sequence of up to 20 conversions
programmed in the ADC_SQRx and ADC_JSQR registers.
In this mode, external trigger on injected channels must be disabled.
If the CONT bit is also set in addition to the JAUTO bit, regular channels followed by injected
channels are continuously converted.
For ADC clock prescalers ranging from 4 to 8, a delay of 1 ADC clock period is automatically
inserted when switching from regular to injected sequence (respectively injected to regular).
When the ADC clock prescaler is set to 2, the delay is 2 ADC clock periods.
Note: It is not possible to use both auto-injected and discontinuous modes simultaneously.
ADC clock
Inj. event
Reset ADC
SOC
max latency(1)
1. The maximum latency value can be found in the electrical characteristics of the STM32F101xx and
STM32F103xx datasheets.
Injected group
This mode is enabled by setting the JDISCEN bit in the ADC_CR1 register. It can be used to
convert the sequence selected in the ADC_JSQR register, channel by channel, after an
external trigger event.
When an external trigger occurs, it starts the next channel conversions selected in the
ADC_JSQR registers until all the conversions in the sequence are done. The total sequence
length is defined by the JL[1:0] bits in the ADC_JSQR register.
Example:
n = 1, channels to be converted = 1, 2, 3
1st trigger: channel 1 converted
2nd trigger: channel 2 converted
3rd trigger: channel 3 converted and EOC and JEOC events generated
4th trigger: channel 1
Note: 1 When all injected channels are converted, the next trigger starts the conversion of the first
injected channel. In the example above, the 4th trigger reconverts the 1st injected channel
1.
2 It is not possible to use both auto-injected and discontinuous modes simultaneously.
3 The user must avoid setting discontinuous mode for both regular and injected groups
together. Discontinuous mode must be enabled only for one group conversion.
11.4 Calibration
The ADC has an built-in self calibration mode. Calibration significantly reduces accuracy
errors due to internal capacitor bank variations. During calibration, an error-correction code
(digital word) is calculated for each capacitor, and during all subsequent conversions, the
error contribution of each capacitor is removed using this code.
Calibration is started by setting the CAL bit in the ADC_CR2 register. Once calibration is
over, the CAL bit is reset by hardware and normal conversion can be performed. It is
recommended to calibrate the ADC once at power-on. The calibration codes are stored in
the ADC_DR as soon as the calibration phase ends.
Note: 1 It is recommended to perform a calibration after each power-up.
2 Before starting a calibration the ADC must have been in power-off state (ADON bit = ‘0’) for
at least two ADC clock cycles.
CLK
Regular group
0 0 0 0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Regular group
D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0
Table 62. External trigger for regular channels for ADC1 and ADC2
Source Type EXTSEL[2:0]
Table 63. External trigger for injected channels for ADC1 and ADC2
Source Connection type JEXTSEL[2:0]
The software source trigger events can be generated by setting a bit in a register
(SWSTART and JSWSTART in ADC_CR2).
A regular group conversion can be interrupted by an injected trigger.
Regular
channels ADC2 (Slave)
injected
channels
internal triggers
Address/data bus
Regular data register
(16 bits)(2)
ADCx_IN0
Regular
ADCx_IN1 channels
GPIO
Ports
Injected
channels
ADCx_IN15
Temp. sensor
VREFINT Dual mode
control
EXTI_15
Start trigger mux
(injected group)
1. External triggers are present on ADC2 but are not shown for the purposes of this diagram.
2. In some dual ADC modes, the ADC1 data register (ADC1_DR) contains both ADC1 and ADC2 regular converted data over
the entire 32 bits.
Sampling
Conversion
ADC2 CH0 CH1 CH2 CH3
ADC1 CH3 CH2 CH1 CH0
Sampling
Conversion
ADC1 CH0 CH1 CH2 CH3 ... CH15
ADC2 CH15 CH14 CH13 CH12 ... CH0
Sampling
End of conversion on ADC2
Conversion
ADC2 CH0 ... CH0
ADC1 CH0 ... CH0
Trigger
End of conversion on ADC1
7 ADCCLK
cycles
After an EOC interrupt is generated by ADC1 (if enabled through the EOCIE bit) a 32-bit
DMA transfer request is generated (if the DMA bit is set) which transfers to SRAM the
ADC1_DR 32-bit register containing the ADC2 converted data in the upper halfword and the
ADC1 converted data in the lower halfword.
A new ADC2 start is automatically generated after 28 ADC clock cycles
CONT bit can not be set in the mode since it continuously converts the selected regular
channel.
Note: The application must ensure that no external trigger for injected channel occurs when
interleaved mode is enabled.
14 ADCCLK
cycles
28 ADCCLK
cycles
ADC1 ...
ADC2
If the injected discontinuous mode is enabled for both ADC1 and ADC2:
● When the 1st trigger occurs, the first injected channel in ADC1 is converted.
● When the 2nd trigger arrives, the first injected channel in ADC2 are converted
● and so on....
A JEOC interrupt, if enabled, is generated after all injected group channels of ADC1 are
converted.
A JEOC interrupt, if enabled, is generated after all injected group channels of ADC2 are
converted.
If another external trigger occurs after all injected group channels have been converted then
the alternate trigger process restarts.
Figure 38. Alternate trigger: 4 injected channels (each ADC) in discontinuous model
1st trigger 3rd trigger 5th trigger 7th trigger Sampling
JEOC on ADC1 Conversion
ADC1
ADC2
JEOC on ADC2
ADC1 inj
CH0
2nd trig
If a trigger occurs during an injected conversion that has interrupted a regular conversion, it
will be ignored. Figure 40 shows the behavior in this case (2nd trig is ignored).
Figure 41. Interleaved single channel with injected sequence CH11, CH12
Sampling
ADC1 CH0 CH0 CH0 Conversion
ADC2 CH0 CH0 CH0
CH11 CH12
Trigger
CH12 CH11
CH0 CH0
CH0 CH0
TEMPERATURE VSENSE
SENSOR ADCx_IN16
Address/data bus
converted data
ADC1
VREFINT
INTERNAL
ADCx_IN17
POWER
BLOCK
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Res. rw rw Res. rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Res. rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
JEXTT RST
JEXTSEL[2:0] ALIGN Reserved DMA Reserved CAL CONT ADON
RIG CAL
rw rw rw rw rw Res. rw Res. rw rw rw rw
Res. rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SMP
SMP14[2:0] SMP13[2:0] SMP12[2:0] SMP11[2:0] SMP10[2:0]
15_0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Res. rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SMP
SMP4[2:0] SMP3[2:0] SMP2[2:0] SMP1[2:0] SMP0[2:0]
5_0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved JOFFSETx[11:0]
Res. rw rw rw rw rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HT[11:0]
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved LT[11:0]
Res rw rw rw rw rw rw rw rw rw rw rw rw
Res. rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SQ10_
SQ9[4:0] SQ8[4:0] SQ7[4:0]
0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
JL[1:0] JSQ4[4:1]
Reserved
rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
JDATA[15:0]
r r r r r r r r r r r r r r r r
ADC2DATA[15:0]
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DATA[15:0]
r r r r r r r r r r r r r r r r
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
JSTRT
JEOC
STRT
AWD
EOC
ADC_SR
0x00 Reserved
Reset value 0 0 0 0 0
AWD SGL
JDISCEN
JAWDEN
JEOC IE
DISCEN
AWDEN
AWDIE
JAUTO
EOCIE
Reserved
SCAN
DUALMOD DISC
ADC_CR1 AWDCH[4:0]
0x04 Reserved [3:0] NUM [2:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
JSWSTART
JEXTTRIG
SWSTART
TSVREFE
EXTTRIG
RSTCAL
ALIGN
Reserved
Reserved
ADON
CONT
EXTSEL JEXTSEL
DMA
CAL
ADC_CR2
0x08 Reserved [2:0] [2:0] Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ADC_JOFR1 JOFFSET1[11:0]
0x14 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
ADC_JOFR2 JOFFSET2[11:0]
0x18 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
ADC_JOFR3 JOFFSET3[11:0]
0x1C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
ADC_JOFR4 JOFFSET4[11:0]
0x20 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
ADC_HTR HT[11:0]
0x24 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
ADC_LTR LT[11:0]
0x28 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
ADC_JDR1 JDATA[15:0]
0x3C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ADC_JDR2 JDATA[15:0]
0x40 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ADC_JDR3 JDATA[15:0]
0x44 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ADC_JDR4 JDATA[15:0]
0x48 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Trigger selectorx
TIM2_T RGO
TIM4_T RGO DMAENx
TIM5_T RGO
TIM6_T RGO
TIM7_T RGO
TIM8_T RGO(1)
EXTI_9
DM A req ue stx
Control logicx TENx
12-bit
DHRx
LFSRx trianglex MAMPx[3:0] bits
WAVENx[1:0] bits
12-bit
DORx
12-bit
VDDA
Digital-to-analog DAC_ OU Tx
VSSA
converterx
VR EF+
ai14708c
Input, analog reference The higher/positive reference voltage for the DAC,
VREF+
positive 2.4 V VREF+ VDDA (3.3 V)
VDDA Input, analog supply Analog power supply
Input, analog supply
VSSA Ground for analog power supply
ground
DAC_OUTx Analog output signal DAC channelx analog output
Note: Once the DAC channelx is enabled, the corresponding GPIO pin (PA4 or PA5) is
automatically connected to the analog converter output (DAC_OUTx). In order to avoid
parasitic consumption, the PA4 or PA5 pin should first be configured to analog (AIN).
ai14710
ai14709
Figure 46. Timing diagram for conversion with trigger disabled TEN = 0
APB1_CLK
DHR 0x1AC
Output voltage
DOR 0x1AC available on DAC_OUT pin
tSETTLING
ai14711b
Each time a DAC interface detects a rising edge on the selected timer TRGO output, or on
the selected external interrupt line 9, the last data stored into the DAC_DHRx register is
transferred into the DAC_DORx register. The DAC_DORx register is updated three APB1
cycles after the trigger occurs.
If the software trigger is selected, the conversion starts once the SWTRIG bit is set.
SWTRIG is reset by hardware once the DAC_DORx register has been loaded with the
DAC_DHRx register contents.
Note: 1 TSELx[2:0] bit cannot be changed when the ENx bit is set.
2 When software trigger is selected, it takes only one APB1 clock cycle for DAC_DHRx-to-
DAC_DORx register transfer.
XOR
X6 X4 X X0
12
X
11 10 9 8 7 6 5 4 3 2 1 0
12
NOR
ai14713b
The LFSR value, that may be masked partially or totally by means of the MAMPx[3:0] bits in
the DAC_CR register, is added up to the DAC_DHRx contents without overflow and this
value is then stored into the DAC_DORx register.
If LFSR is 0x0000, a ‘1’ is injected into it (antilock-up mechanism).
It is possible to reset LFSR wave generation by resetting the WAVEx[1:0] bits.
Figure 48. DAC conversion (SW trigger enabled) with LFSR wave generation
APB1_CLK
DHR 0x00
SWTRIG
ai14714
Note: DAC trigger must be enabled for noise generation, by setting the TENx bit in the DAC_CR
register.
CR
TA
EM
EN
EN
EM
TAT
CR
IO
)N
AIC
Figure 50. DAC conversion (SW trigger enabled) with triangle wave generation
APB1_CLK
DHR 0xABE
SWTRIG
ai14714
Note: 1 DAC trigger must be enabled for noise generation, by setting the TENx bit in the DAC_CR
register.
2 MAMPx[3:0] bits must be configured before enabling the DAC, otherwise they cannot be
changed.
DAC_DOR1 (three APB1 clock cycles later). The DAC channel1 triangle counter is then
updated.
When a DAC channel2 trigger arrives, the DAC channel2 triangle counter, with the same
triangle amplitude, is added to the DHR2 register and the sum is transferred into
DAC_DOR2 (three APB1 clock cycles later). The DAC channel2 triangle counter is then
updated.
added to the DHR2 register and the sum is transferred into DAC_DOR2 (three APB1 clock
cycles later). The DAC channel2 triangle counter is then updated.
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DACC2DOR[11:0]
Reserved
r r r r r r r r r r r r
9
8
7
6
5
4
3
2
1
0
DMAEN2
DMAEN1
BOFF2
BOFF1
TEN2
TEN1
WAVE WAVE TSEL1
EN2
EN1
DAC_CR MAMP2[3:0] TSEL2[2:0] MAMP1[3:0]
0x00 Reserved 2[2:0] Reserved 1[2:0] [2:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SWTRIG2
SWTRIG1
DAC_SWTRIG
0x04 R Reserved
Reset value 0 0
DAC_DHR12R
DACC1DHR[11:0]
0x08 1 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
DAC_DHR12L
DACC1DHR[11:0]
0x0C 1 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
DAC_DHR8R1 DACC1DHR[7:0]
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0
DAC_DHR12R
DACC2DHR[11:0]
0x14 2 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
DAC_DHR12L
DACC2DHR[11:0]
0x18 2 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
DAC_DHR8R2 DACC2DHR[7:0]
0x1C Reserved
DAC_DHR12R
DACC2DHR[11:0] DACC1DHR[11:0]
0x20 D Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DAC_DHR12L
DACC2DHR[11:0] DACC1DHR[11:0]
0x24 D Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DAC_DHR8RD DACC2DHR[7:0] DACC1DHR[7:0]
0x28 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DAC_DOR1 DACC1DOR[11:0]
0x2C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
DAC_DOR2 DACC2DOR[11:0]
0x30 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
TI1F_ED
TI1FP1 Encoder
TI2FP2 Interface
REP Register
UI
U AutoReload Register
Repetition
counter U
Stop, Clear or Up/Down
ETRF
BRK BI
TIMx_BKIN Polarity Selection
Notes:
Reg Preload registers transferred
to active registers on U event
according to control bit
event
Prescaler description
The prescaler can divide the counter clock frequency by any factor between 1 and 65536. It
is based on a 16-bit counter controlled through a 16-bit register (in the TIMx_PSC register).
It can be changed on the fly as this control register is buffered. The new prescaler ratio is
taken into account at the next update event.
Figure 53 and Figure 54 give some examples of the counter behavior when the prescaler
ratio is changed on the fly:
Figure 52. Counter timing diagram with prescaler division change from 1 to 2
CK_PSC
CEN
Counter register F7 F8 F9 FA FB FC 00 01 02 03
Prescaler buffer 0 1
Prescaler counter 0 0 1 0 1 0 1 0 1
Figure 53. Counter timing diagram with prescaler division change from 1 to 4
CK_PSC
CEN
Counter register F7 F8 F9 FA FB FC 00 01
Prescaler buffer 0 3
Prescaler counter 0 0 1 2 3 0 1 2 3
preload registers. Then no update event occurs until the UDIS bit has been written to 0.
However, the counter restarts from 0, as well as the counter of the prescaler (but the
prescale rate does not change). In addition, if the URS bit (update request selection) in
TIMx_CR1 register is set, setting the UG bit generates an update event UEV but without
setting the UIF flag (thus no interrupt or DMA request is sent). This is to avoid generating
both update and capture interrupts when clearing the counter on the capture event.
When an update event occurs, all the registers are updated and the update flag (UIF bit in
TIMx_SR register) is set (depending on the URS bit):
● The repetition counter is reloaded with the content of TIMx_RCR register,
● The auto-reload shadow register is updated with the preload value (TIMx_ARR),
● The buffer of the prescaler is reloaded with the preload value (content of the TIMx_PSC
register).
The following figures show some examples of the counter behavior for different clock
frequencies when TIMx_ARR=0x36.
CK_PSC
CNT_EN
Counter register 31 32 33 34 35 36 00 01 02 03 04 05 06 07
Counter overflow
CK_PSC
CNT_EN
Counter overflow
CK_PSC
CNT_EN
Counter overflow
CK_PSC
Counter register 1F 20 00
Counter overflow
Figure 58. Counter timing diagram, update event when ARPE=0 (TIMx_ARR not
preloaded)
CK_PSC
CEN
Counter register 31 32 33 34 35 36 00 01 02 03 04 05 06 07
Counter overflow
Auto-reload register FF 36
Figure 59. Counter timing diagram, update event when ARPE=1 (TIMx_ARR
preloaded)
CK_PSC
CEN
Counter register F0 F1 F2 F3 F4 F5 00 01 02 03 04 05 06 07
Counter overflow
Downcounting mode
In downcounting mode, the counter counts from the auto-reload value (content of the
TIMx_ARR register) down to 0, then restarts from the auto-reload value and generates a
counter underflow event.
If the repetition counter is used, the update event (UEV) is generated after downcounting is
repeated for the number of times programmed in the repetition counter register
(TIMx_RCR). Else the update event is generated at each counter underflow.
Setting the UG bit in the TIMx_EGR register (by software or by using the slave mode
controller) also generates an update event.
The UEV update event can be disabled by software by setting the UDIS bit in TIMx_CR1
register. This is to avoid updating the shadow registers while writing new values in the
preload registers. Then no update event occurs until UDIS bit has been written to 0.
However, the counter restarts from the current auto-reload value, whereas the counter of the
prescaler restarts from 0 (but the prescale rate doesn’t change).
In addition, if the URS bit (update request selection) in TIMx_CR1 register is set, setting the
UG bit generates an update event UEV but without setting the UIF flag (thus no interrupt or
DMA request is sent). This is to avoid generating both update and capture interrupts when
clearing the counter on the capture event.
When an update event occurs, all the registers are updated and the update flag (UIF bit in
TIMx_SR register) is set (depending on the URS bit):
● The repetition counter is reloaded with the content of TIMx_RCR register
● The buffer of the prescaler is reloaded with the preload value (content of the TIMx_PSC
register)
● The auto-reload active register is updated with the preload value (content of the
TIMx_ARR register). Note that the auto-reload is updated before the counter is
reloaded, so that the next period is the expected one
The following figures show some examples of the counter behavior for different clock
frequencies when TIMx_ARR=0x36.
CK_PSC
CNT_EN
Counter register 05 04 03 02 01 00 36 35 34 33 32 31 30 2F
CK_PSC
CNT_EN
Counter underflow
CK_PSC
CNT_EN
Counter underflow
CK_PSC
Counter register 20 1F 00 36
Counter underflow
Figure 64. Counter timing diagram, update event when repetition counter is not
used
CK_PSC
CEN
Counter register 05 04 03 02 01 00 36 35 34 33 32 31 30 2F
Counter underflow
Auto-reload register FF 36
In addition, if the URS bit (update request selection) in TIMx_CR1 register is set, setting the
UG bit generates an UEV update event but without setting the UIF flag (thus no interrupt or
DMA request is sent). This is to avoid generating both update and capture interrupts when
clearing the counter on the capture event.
When an update event occurs, all the registers are updated and the update flag (UIF bit in
TIMx_SR register) is set (depending on the URS bit):
● The repetition counter is reloaded with the content of TIMx_RCR register
● The buffer of the prescaler is reloaded with the preload value (content of the TIMx_PSC
register)
● The auto-reload active register is updated with the preload value (content of the
TIMx_ARR register). Note that if the update source is a counter overflow, the auto-
reload is updated before the counter is reloaded, so that the next period is the expected
one (the counter is loaded with the new value).
The following figures show some examples of the counter behavior for different clock
frequencies.
Figure 65. Counter timing diagram, internal clock divided by 1, TIMx_ARR = 0x6
CK_PSC
CNT_EN
Counter register 04 03 02 01 00 01 02 03 04 05 06 05 04 03
Counter underflow
Counter overflow
1. Here, center-aligned mode 1 is used (for more details refer to Section 13.4: TIM1&TIM8 registers on page 294).
CK_PSC
CNT_EN
Counter underflow
CK_PSC
CNT_EN
Counter overflow
CK_PSC
Counter register 20 1F 01 00
Counter underflow
Figure 69. Counter timing diagram, update event with ARPE=1 (counter underflow)
CK_PSC
CEN
Counter register 06 05 04 03 02 01 00 01 02 03 04 05 06 07
Counter underflow
Figure 70. Counter timing diagram, Update event with ARPE=1 (counter overflow)
CK_PSC
CEN
Counter register F7 F8 F9 FA FB FC 36 35 34 33 32 31 30 2F
Counter overflow
Figure 71. Update rate examples depending on mode and TIMx_RCR register
settings
Upcounting Downcounting
Counter
TIMx_CNT
TIMx_RCR = 0 UEV
TIMx_RCR = 1 UEV
TIMx_RCR = 2 UEV
TIMx_RCR = 3 UEV
TIMx_RCR = 3
and
re-synchronization
UEV
(by SW) (by SW) (by SW)
UEV Update Event: Preload registers transferred to active registers and update interrupt generated
Update Event if the repetition counter underflow occurs when the counter is equal to
to the auto-reload value.
Internal clock
CEN=CNT_EN
UG
CNT_INIT
Counter register 31 32 33 34 35 36 00 01 02 03 04 05 06 07
TI2F or
or
TI1F or encoder
ITRx 0xx mode
TI1_ED 100
TI1FP1 101 TRGI external clock
TI2F_Rising
mode 1 CK_PSC
0
TI2 Filter Edge TI2FP2 110
Detector TI2F_Falling ETRF external clock
1 ETRF 111 mode 2
ICF[3:0] CC2P CK_INT internal clock
TIMx_CCMR1 TIMx_CCER mode
(internal clock)
ECE SMS[2:0]
TIMx_SMCR
For example, to configure the upcounter to count in response to a rising edge on the TI2
input, use the following procedure:
1. Configure channel 2 to detect rising edges on the TI2 input by writing CC2S = ‘01’ in
the TIMx_CCMR1 register.
2. Configure the input filter duration by writing the IC2F[3:0] bits in the TIMx_CCMR1
register (if no filter is needed, keep IC2F=0000).
3. Select rising edge polarity by writing CC2P=0 in the TIMx_CCER register.
4. Configure the timer in external clock mode 1 by writing SMS=111 in the TIMx_SMCR
register.
5. Select TI2 as the trigger input source by writing TS=110 in the TIMx_SMCR register.
6. Enable the counter by writing CEN=1 in the TIMx_CR1 register.
Note: The capture prescaler is not used for triggering, so you don’t need to configure it.
When a rising edge occurs on TI2, the counter counts once and the TIF flag is set.
The delay between the rising edge on TI2 and the actual clock of the counter is due to the
resynchronization circuit on TI2 input.
TI2
CNT_EN
Counter register 34 35 36
TIF
Write TIF=0
TI2F or
or
TI1F or encoder
mode
For example, to configure the upcounter to count each 2 rising edges on ETR, use the
following procedure:
1. As no filter is needed in this example, write ETF[3:0]=0000 in the TIMx_SMCR register.
2. Set the prescaler by writing ETPS[1:0]=01 in the TIMx_SMCR register
3. Select rising edge detection on the ETR pin by writing ETP=0 in the TIMx_SMCR
register
4. Enable external clock mode 2 by writing ECE=1 in the TIMx_SMCR register.
5. Enable the counter by writing CEN=1 in the TIMx_CR1 register.
The counter counts once each 2 ETR rising edges.
The delay between the rising edge on ETR and the actual clock of the counter is due to the
resynchronization circuit on the ETRP signal.
fCK_INT
CNT_EN
ETR
ETRP
ETRF
Counter register 34 35 36
TI1F_ED
to the slave mode controller
TI1F_Rising 0
TI1 TI1F
filter Edge TI1FP1
01
fDTS downcounter Detector TI1F_Falling
1
TI2FP1 IC1 divider IC1PS
10
/1, /2, /4, /8
ICF[3:0] CC1P TRC
11
TIMx_CCMR1 TIMx_CCER (from slave mode
controller)
TI2F_rising 0
(from channel 2)
CC1S[1:0] ICPS[1:0] CC1E
TI2F_falling
1
(from channel 2) TIMx_CCMR1 TIMx_CCER
The output stage generates an intermediate waveform which is then used for reference:
OCxRef (active high). The polarity acts at the end of the chain.
APB Bus
MCU-peripheral interface
(if 16-bit)
8 8
high
low
S write CCR1H
read CCR1H S write_in_progress
read_in_progress
Capture/compare preload register write CCR1L
read CCR1L R
R CC1S[1]
output
capture_transfer compare_transfer mode
CC1S[0]
CC1S[1] input
mode OC1PE
Capture/compare shadow register OC1PE
CC1S[0] UEV
TIM1_CCMR1
comparator (from time
IC1PS capture base unit)
CC1E CNT>CCR1
Counter
CNT=CCR1
CC1G
TIM1_EGR
ETR 0
Output OC1
‘0’ enable
x0 1 circuit
10
OC1_DT CC1P
CNT>CCR1 11
Output mode OC1REF Dead-time TIM1_CCER
CNT=CCR1 controller generator
OC1N_DT
11
10 0 OC1N
Output
‘0’ 0x enable
1 circuit
OC1CE OC1M[2:0] DTG[7:0] CC1NE CC1E CC1NP MOE OSSI OSSR TIM1_BDTR
TIM1_CCMR1 TIM1_BDTR TIM1_CCER TIM1_CCER
CC4P
CNT > CCR4
Output mode OC4 REF TIM1_CCER
CNT = CCR4 controller
CC4E TIM1_CCER
The capture/compare block is made of one preload register and one shadow register. Write
and read always access the preload register.
In capture mode, captures are actually done in the shadow register, which is copied into the
preload register.
In compare mode, the content of the preload register is copied into the shadow register
which is compared to the counter.
The following example shows how to capture the counter value in TIMx_CCR1 when TI1
input rises. To do this, use the following procedure:
● Select the active input: TIMx_CCR1 must be linked to the TI1 input, so write the CC1S
bits to 01 in the TIMx_CCMR1 register. As soon as CC1S becomes different from 00,
the channel is configured in input and the TIMx_CCR1 register becomes read-only.
● Program the input filter duration you need with respect to the signal you connect to the
timer (when the input is one of the TIx (ICxF bits in the TIMx_CCMRx register). Let’s
imagine that, when toggling, the input signal is not stable during at must 5 internal clock
cycles. We must program a filter duration longer than these 5 clock cycles. We can
validate a transition on TI1 when 8 consecutive samples with the new level have been
detected (sampled at fDTS frequency). Then write IC1F bits to 0011 in the
TIMx_CCMR1 register.
● Select the edge of the active transition on the TI1 channel by writing CC1P bit to 0 in
the TIMx_CCER register (rising edge in this case).
● Program the input prescaler. In our example, we wish the capture to be performed at
each valid transition, so the prescaler is disabled (write IC1PS bits to ‘00’ in the
TIMx_CCMR1 register).
● Enable capture from the counter into the capture register by setting the CC1E bit in the
TIMx_CCER register.
● If needed, enable the related interrupt request by setting the CC1IE bit in the
TIMx_DIER register, and/or the DMA request by setting the CC1DE bit in the
TIMx_DIER register.
When an input capture occurs:
● The TIMx_CCR1 register gets the value of the counter on the active transition.
● CC1IF flag is set (interrupt flag). CC1OF is also set if at least two consecutive captures
occurred whereas the flag was not cleared.
● An interrupt is generated depending on the CC1IE bit.
● A DMA request is generated depending on the CC1DE bit.
In order to handle the overcapture, it is recommended to read the data before the
overcapture flag. This is to avoid missing an overcapture which could happen after reading
the flag and before reading the data.
Note: IC interrupt and/or DMA requests can be generated by software by setting the
corresponding CCxG bit in the TIMx_EGR register.
For example, you can measure the period (in TIMx_CCR1 register) and the duty cycle (in
TIMx_CCR2 register) of the PWM applied on TI1 using the following procedure (depending
on CK_INT frequency and prescaler value):
● Select the active input for TIMx_CCR1: write the CC1S bits to 01 in the TIMx_CCMR1
register (TI1 selected).
● Select the active polarity for TI1FP1 (used both for capture in TIMx_CCR1 and counter
clear): write the CC1P bit to ‘0’ (active on rising edge).
● Select the active input for TIMx_CCR2: write the CC2S bits to 10 in the TIMx_CCMR1
register (TI1 selected).
● Select the active polarity for TI1FP2 (used for capture in TIMx_CCR2): write the CC2P
bit to ‘1’ (active on falling edge).
● Select the valid trigger input: write the TS bits to 101 in the TIMx_SMCR register
(TI1FP1 selected).
● Configure the slave mode controller in reset mode: write the SMS bits to 100 in the
TIMx_SMCR register.
● Enable the captures: write the CC1E and CC2E bits to ‘1’ in the TIMx_CCER register.
TI1
TIMx_CCR1 0004
TIMx_CCR2 0002
1. The PWM input mode can be used only with the TIMx_CH1/TIMx_CH2 signals due to the fact that only
TI1FP1 and TI2FP2 are connected to the slave mode controller.
Anyway, the comparison between the TIMx_CCRx shadow register and the counter is still
performed and allows the flag to be set. Interrupt and DMA requests can be sent
accordingly. This is described in the output compare mode section below.
oc1ref=OC1
Counter register 0 1 2 3 4 5 6 7 8 0 1
OCXREF
CCRx=4
CCxIF
OCXREF
CCRx=8
CCxIF
OCXREF ‘1’
CCRx>8
CCxIF
OCXREF ‘0’
CCRx=0
CCxIF
● Downcounting configuration
Downcounting is active when DIR bit in TIMx_CR1 register is high. Refer to the
Downcounting mode on page 260
In PWM mode 1, the reference signal OCxRef is low as long as
TIMx_CNT > TIMx_CCRx else it becomes high. If the compare value in TIMx_CCRx is
greater than the auto-reload value in TIMx_ARR, then OCxREF is held at ‘1’. 0% PWM
is not possible in this mode.
Counter register 0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0 1
OCxREF
CCRx = 4
CCxIF CMS=01
CMS=10
CMS=11
OCxREF
CCRx = 7
CMS=10 or 11
CCxIF
'1'
OCxREF
CCRx = 8
CCxIF CMS=01
CMS=10
CMS=11
'1'
OCxREF
CCRx > 8
CCxIF CMS=01
CMS=10
CMS=11
'0'
OCxREF
CCRx = 0
CCxIF CMS=01
CMS=10
CMS=11
ai14681
OCxREF
OCx
delay
OCxN
delay
Figure 86. Dead-time waveforms with delay greater than the negative pulse.
OCxREF
OCx
delay
OCxN
Figure 87. Dead-time waveforms with delay greater than the positive pulse.
OCxREF
OCx
OCxN
delay
The dead-time delay is the same for each of the channels and is programmable with the
DTG bits in the TIMx_BDTR register. Refer to Section 13.4.18: TIM1&TIM8 break and dead-
time register (TIMx_BDTR) on page 314 for delay calculation.
must insert a delay (dummy instruction) before reading it correctly. This is because you write
the asynchronous signal and read the synchronous signal.
When a break occurs (selected level on the break input):
● The MOE bit is cleared asynchronously, putting the outputs in inactive state, idle state
or in reset state (selected by the OSSI bit). This feature functions even if the MCU
oscillator is off.
● Each output channel is driven with the level programmed in the OISx bit in the
TIMx_CR2 register as soon as MOE=0. If OSSI=0 then the timer releases the enable
output else the enable output remains high.
● When complementary outputs are used:
– The outputs are first put in reset state inactive state (depending on the polarity).
This is done asynchronously so that it works even if no clock is provided to the
timer.
– If the timer clock is still present, then the dead-time generator is reactivated in
order to drive the outputs with the level programmed in the OISx and OISxN bits
after a dead-time. Even in this case, OCx and OCxN cannot be driven to their
active level together. Note that because of the resynchronization on MOE, the
dead-time duration is a bit longer than usual (around 2 ck_tim clock cycles).
– If OSSI=0 then the timer releases the enable outputs else the enable outputs
remain or become high as soon as one of the CCxE or CCxNE bits is high.
● The break status flag (BIF bit in the TIMx_SR register) is set. An interrupt can be
generated if the BIE bit in the TIMx_DIER register is set. A DMA request can be sent if
the BDE bit in the TIMx_DIER register is set.
● If the AOE bit in the TIMx_BDTR register is set, the MOE bit is automatically set again
at the next update event UEV. This can be used to perform a regulation, for instance.
Else, MOE remains low until you write it to ‘1’ again. In this case, it can be used for
security and you can connect the break input to an alarm from power drivers, thermal
sensors or any security components.
Note: The break inputs is acting on level. Thus, the MOE cannot be set while the break input is
active (neither automatically nor by software). In the meantime, the status flag BIF cannot be
cleared.
The break can be generated by the BRK input which has a programmable polarity and an
enable bit BKE in the TIMx_BDTR Register.
In addition to the break input and the output management, a write protection has been
implemented inside the break circuit to safeguard the application. It allows you to freeze the
configuration of several parameters (dead-time duration, OCx/OCxN polarities and state
when disabled, OCxM configurations, break enable and polarity). You can choose from 3
levels of protection selected by the LOCK bits in the TIMx_BDTR register. Refer to
Section 13.4.18: TIM1&TIM8 break and dead-time register (TIMx_BDTR) on page 314. The
LOCK bits can be written only once after an MCU reset.
The Figure 88 shows an example of behavior of the outputs in response to a break.
OCxREF
OCx
(OCxN not implemented, CCxP=0, OISx=1)
OCx
(OCxN not implemented, CCxP=0, OISx=0)
OCx
(OCxN not implemented, CCxP=1, OISx=1)
OCx
(OCxN not implemented, CCxP=1, OISx=0)
OCx
OCx
OCx
OCxN delay
(CCxE=1, CCxP=0, OISx=0, CCxNE=0, CCxNP=0, OISxN=1)
OCx
OCxN delay
(CCxE=1, CCxP=0, OISx=1, CCxNE=0, CCxNP=0, OISxN=0)
OCx
OCxN
(CCxE=1, CCxP=0, CCxNE=0, CCxNP=0, OISx=OISxN=0 or OISx=OISxN=1)
(CCRx)
counter (CNT)
ETRF
OCxREF
(OCxCE=’0’)
OCxREF
(OCxCE=’1’)
OCREF_CLR OCREF_CLR
becomes high still high
OCxREF
Write COM to 1
COM event
CCxE=1 write OCxM to 100 CCxE=1
CCxNE=0 CCxNE=0
OCxM=100 (forced inactive) OCxM=100
OCx
Example 1
OCxN
Write CCxNE to 1
and OCxM to 101 CCxE=0
CCxE=1 CCxNE=1
CCxNE=0 OCxM=101
OCx OCxM=100 (forced inactive)
Example 2
OCxN
write CCxNE to 0
CCxE=1
and OCxM to 100 CCxE=1
CCxNE=0 CCxNE=0
OCxM=100 (forced inactive) OCxM=100
OCx
Example 3
OCxN
ai14910
TI2
OC1REF
OC1
TIM1_ARR
Counter
TIM1_CCR1
0
tDELAY t
tPULSE
For example you may want to generate a positive pulse on OC1 with a length of tPULSE and
after a delay of tDELAY as soon as a positive edge is detected on the TI2 input pin.
Let’s use TI2FP2 as trigger 1:
● Map TI2FP2 to TI2 by writing CC2S=’01’ in the TIMx_CCMR1 register.
● TI2FP2 must detect a rising edge, write CC2P=’0’ in the TIMx_CCER register.
● Configure TI2FP2 as trigger for the slave mode controller (TRGI) by writing TS=’110’ in
the TIMx_SMCR register.
● TI2FP2 is used to start the counter by writing SMS to ‘110’ in the TIMx_SMCR register
(trigger mode).
The OPM waveform is defined by writing the compare registers (taking into account the
clock frequency and the counter prescaler).
● The tDELAY is defined by the value written in the TIMx_CCR1 register.
● The tPULSE is defined by the difference between the auto-reload value and the compare
value (TIMx_ARR - TIMx_CCR1).
● Let’s say you want to build a waveform with a transition from ‘0’ to ‘1’ when a compare
match occurs and a transition from ‘1’ to ‘0’ when the counter reaches the auto-reload
value. To do this you enable PWM mode 2 by writing OC1M=111 in the TIMx_CCMR1
register. You can optionally enable the preload registers by writing OC1PE=’1’ in the
TIMx_CCMR1 register and ARPE in the TIMx_CR1 register. In this case you have to
write the compare value in the TIMx_CCR1 register, the auto-reload value in the
TIMx_ARR register, generate an update by setting the UG bit and wait for external
trigger event on TI2. CC1P is written to ‘0’ in this example.
In our example, the DIR and CMS bits in the TIMx_CR1 register should be low.
You only want 1 pulse, so you write ‘1’ in the OPM bit in the TIMx_CR1 register to stop the
counter at the next update event (when the counter rolls over from the auto-reload value
back to 0).
Particular case: OCx fast enable:
In One-pulse mode, the edge detection on TIx input set the CEN bit which enables the
counter. Then the comparison between the counter and the compare value makes the
output toggle. But several clock cycles are needed for these operations and it limits the
minimum delay tDELAY min we can get.
If you want to output a waveform with the minimum delay, you can set the OCxFE bit in the
TIMx_CCMRx register. Then OCxRef (and OCx) are forced in response to the stimulus,
without taking in account the comparison. Its new level is the same as if a compare match
had occurred. OCxFE acts only if the channel is configured in PWM1 or PWM2 mode.
repetition counter, trigger output features continue to work as normal. Encoder mode and
External clock mode 2 are not compatible and must not be selected together.
In this mode, the counter is modified automatically following the speed and the direction of
the incremental encoder and its content, therefore, always represents the encoder’s
position. The count direction correspond to the rotation direction of the connected sensor.
The table summarizes the possible combinations, assuming TI1 and TI2 don’t switch at the
same time.
An external incremental encoder can be connected directly to the MCU without external
interface logic. However, comparators are normally be used to convert the encoder’s
differential outputs to digital signals. This greatly increases noise immunity. The third
encoder output which indicate the mechanical zero position, may be connected to an
external interrupt input and trigger a counter reset.
The Figure 92 gives an example of counter operation, showing count signal generation and
direction control. It also shows how input jitter is compensated where both edges are
selected. This might occur if the sensor is positioned near to one of the switching points. For
this example we assume that the configuration is the following:
● CC1S=’01’ (TIMx_CCMR1 register, TI1FP1 mapped on TI1).
● CC2S=’01’ (TIMx_CCMR2 register, TI1FP2 mapped on TI2).
● CC1P=’0’ (TIMx_CCER register, TI1FP1 non-inverted, TI1FP1=TI1).
● CC2P=’0’ (TIMx_CCER register, TI1FP2 non-inverted, TI1FP2= TI2).
● SMS=’011’ (TIMx_SMCR register, both inputs are active on both rising and falling
edges).
● CEN=’1’ (TIMx_CR1 register, Counter enabled).
TI1
TI2
Counter
up down up
Figure 93 gives an example of counter behavior when TI1FP1 polarity is inverted (same
configuration as above except CC1P=’1’).
Figure 93. Example of encoder interface mode with TI1FP1 polarity inverted.
forward jitter backward jitter forward
TI1
TI2
Counter
down up down
The timer, when configured in Encoder Interface mode provides information on the sensor’s
current position. You can obtain dynamic information (speed, acceleration, deceleration) by
measuring the period between two encoder events using a second timer configured in
capture mode. The output of the encoder which indicates the mechanical zero can be used
for this purpose. Depending on the time between two events, the counter can also be read
at regular times. You can do this by latching the counter value into a third input capture
register if available (then the capture signal must be periodic and can be generated by
another timer). when available, it is also possible to read its value through a DMA request
generated by a real-time clock.
written after a COM event for the next step (this can be done in an interrupt subroutine
generated by the rising edge of OC2REF).
The Figure 94 describes this example.
TIH1
TIH2
TIH3
Interfacing Timer
counter (CNT)
(CCR2)
TRGO=OC2REF
advanced-control timers (TIM1&TIM8)
COM
OC1
OC1N
OC2
OC2N
OC3
OC3N
TI1
UG
Counter register 30 31 32 33 34 35 36 00 01 02 03 00 01 02 03
TIF
TI1
cnt_en
Counter register 30 31 32 33 34 35 36 37 38
TIF
Write TIF=0
TI2
cnt_en
Counter register 34 35 36 37 38
TIF
TI1
CEN/CNT_EN
ETR
Counter register 34 35 36
TIF
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OC2 OC2 OC2 OC1 OC1 OC1
OC2M[2:0] OC1M[2:0]
CE PE FE CC2S[1:0] CE PE FE CC1S[1:0]
IC2F[3:0] IC2PSC[1:0] IC1F[3:0] IC1PSC[1:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Table 73. Output control bits for complementary OCx and OCxN channels with
break feature
Control bits Output states(1)
MOE OSSI OSSR CCxE CCxNE
OCx output state OCxN output state
bit bit bit bit bit
Output Disabled (not Output Disabled (not driven by
0 0 0 driven by the timer) the timer)
OCx=0, OCx_EN=0 OCxN=0, OCxN_EN=0
Output Disabled (not OCxREF + Polarity
0 0 1 driven by the timer) OCxN=OCxREF xor CCxNP,
OCx=0, OCx_EN=0 OCxN_EN=1
Note: The state of the external I/O pins connected to the complementary OCx and OCxN
channels depends on the OCx and OCxN channel state and the GPIO and AFIO registers.
Note: As the bits AOE, BKP, BKE, OSSI, OSSR and DTG[7:0] can be write-locked depending on
the LOCK configuration, it can be necessary to configure all of them during the first write
access to the TIMx_BDTR register.
Offset Register
9
8
7
6
5
4
3
2
1
0
ARPE
UDIS
OPM
CKD CMS
CEN
URS
DIR
TIMx_CR1
0x00 Reserved [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0
OIS3N
OIS2N
OIS1N
Reserved
CCDS
CCUS
CCPC
OIS4
OIS3
OIS2
OIS1
TI1S
TIMx_CR2 MMS[2:0]
0x04 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CC3IE Reserved
MSM
ETPS
ECE
ETP
COMIE
CC4IE
CC2IE
CC1IE
UDE
TDE
UIE
BIE
TIE
TIMx_DIER
0x0C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CC4OF
CC3OF
CC2OF
CC1OF
COMIF
Reserved
CC4IF
CC3IF
CC2IF
CC1IF
UIF
BIF
TIF
TIMx_SR
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
CC4G
CC3G
CC2G
CC1G
COM
UG
BG
TG
TIMx_EGR
0x14 Reserved
Reset value 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
TIMx_CCMR1
OC2CE
OC1CE
OC2PE
OC1PE
OC2FE
OC1FE
OC2M CC2S OC1M CC1S
Output Compare
Reserved [2:0] [1:0] [2:0] [1:0]
mode
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x18
TIMx_CCMR1 IC2 IC1
CC2S CC1S
Input Capture IC2F[3:0] PSC IC1F[3:0] PSC
Reserved [1:0] [1:0]
mode [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_CCMR2
OC3CE
OC4PE
OC3PE
OC4FE
OC3FE
O24CE
OC4M CC4S OC3M CC3S
Output Compare
Reserved [2:0] [1:0] [2:0] [1:0]
mode
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x1C
TIMx_CCMR2 IC4 IC3
CC4S CC3S
Input Capture IC4F[3:0] PSC IC3F[3:0] PSC
Reserved [1:0] [1:0]
mode [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CC3NP
CC3NE
CC2NP
CC2NE
CC1NP
CC1NE
CC4P
CC4E
CC3P
CC3E
CC2P
CC2E
CC1P
CC1E
TIMx_CCER
0x20 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_CNT CNT[15:0]
0x24 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_PSC PSC[15:0]
0x28 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_ARR ARR[15:0]
0x2C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_RCR REP[7:0]
0x30 Reserved
Reset value 0 0 0 0 0 0 0 0
TIMx_CCR1 CCR1[15:0]
0x34 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_CCR2 CCR2[15:0]
0x38 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_CCR3 CCR3[15:0]
0x3C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_CCR4 CCR4[15:0]
0x40 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OSSR
OSSI
MOE
LOCK
AOE
BKP
BKE
TIMx_BDTR DT[7:0]
0x44 Reserved [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_DMAR DMAB[15:0]
0x4C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TI1FP1 Encoder
TI2FP2 Interface
U Autoreload register UI
Notes:
Reg Preload registers transferred
to active registers on U event
according to control bit
event
The auto-reload register is preloaded. Writing to or reading from the auto-reload register
accesses the preload register. The content of the preload register are transferred into the
shadow register permanently or at each update event (UEV), depending on the auto-reload
preload enable bit (ARPE) in TIMx_CR1 register. The update event is sent when the counter
reaches the overflow (or underflow when downcounting) and if the UDIS bit equals 0 in the
TIMx_CR1 register. It can also be generated by software. The generation of the update
event is described in detail for each configuration.
The counter is clocked by the prescaler output CK_CNT, which is enabled only when the
counter enable bit (CEN) in TIMx_CR1 register is set (refer also to the slave mode controller
description to get more details on counter enabling).
Note that the actual counter enable signal CNT_EN is set 1 clock cycle after CEN.
Prescaler description
The prescaler can divide the counter clock frequency by any factor between 1 and 65536. It
is based on a 16-bit counter controlled through a 16-bit register (in the TIMx_PSC register).
It can be changed on the fly as this control register is buffered. The new prescaler ratio is
taken into account at the next update event.
Figure 100 and Figure 101 give some examples of the counter behavior when the prescaler
ratio is changed on the fly:
Figure 100. Counter timing diagram with prescaler division change from 1 to 2
CK_PSC
CNT_EN
Counter register F7 F8 F9 FA FB FC 00 01 02 03
Prescaler buffer 0 1
Prescaler counter 0 0 1 0 1 0 1 0 1
Figure 101. Counter timing diagram with prescaler division change from 1 to 4
CK_PSC
CNT_EN
Counter register F7 F8 F9 FA FB FC 00 01
Prescaler buffer 0 3
Prescaler counter 0 0 1 2 3 0 1 2 3
CK_INT
CNT_EN
Counter register 31 32 33 34 35 36 00 01 02 03 04 05 06 07
Counter overflow
CK_INT
CNT_EN
Counter overflow
CK_INT
CNT_EN
Counter overflow
CK_INT
Counter register 1F 20 00
Counter overflow
Figure 106. Counter timing diagram, Update event when ARPE=0 (TIMx_ARR not
preloaded)
CK_INT
CNT_EN
Counter register 31 32 33 34 35 36 00 01 02 03 04 05 06 07
Counter overflow
Auto-reload register FF 36
Figure 107. Counter timing diagram, Update event when ARPE=1 (TIMx_ARR
preloaded)
CK_PSC
CNT_EN
Counter register F0 F1 F2 F3 F4 F5 00 01 02 03 04 05 06 07
Counter overflow
Downcounting mode
In downcounting mode, the counter counts from the auto-reload value (content of the
TIMx_ARR register) down to 0, then restarts from the auto-reload value and generates a
counter underflow event.
An Update event can be generate at each counter underflow or by setting the UG bit in the
TIMx_EGR register (by software or by using the slave mode controller)
The UEV update event can be disabled by software by setting the UDIS bit in TIMx_CR1
register. This is to avoid updating the shadow registers while writing new values in the
preload registers. Then no update event occurs until UDIS bit has been written to 0.
However, the counter restarts from the current auto-reload value, whereas the counter of the
prescaler restarts from 0 (but the prescale rate doesn’t change).
In addition, if the URS bit (update request selection) in TIMx_CR1 register is set, setting the
UG bit generates an update event UEV but without setting the UIF flag (thus no interrupt or
DMA request is sent). This is to avoid generating both update and capture interrupts when
clearing the counter on the capture event.
When an update event occurs, all the registers are updated and the update flag (UIF bit in
TIMx_SR register) is set (depending on the URS bit):
● The buffer of the prescaler is reloaded with the preload value (content of the TIMx_PSC
register).
● The auto-reload active register is updated with the preload value (content of the
TIMx_ARR register). Note that the auto-reload is updated before the counter is
reloaded, so that the next period is the expected one.
The following figures show some examples of the counter behavior for different clock
frequencies when TIMx_ARR=0x36.
CK_INT
CNT_EN
Counter register 05 04 03 02 01 00 36 35 34 33 32 31 30 2F
CK_INT
CNT_EN
Counter underflow
CK_INT
CNT_EN
Counter underflow
CK_INT
Counter register 20 1F 00 36
Counter underflow
Figure 112. Counter timing diagram, Update event when repetition counter is not
used
CK_INT
CNT_EN
Counter register 05 04 03 02 01 00 36 35 34 33 32 31 30 2F
Counter underflow
Auto-reload register FF 36
In addition, if the URS bit (update request selection) in TIMx_CR1 register is set, setting the
UG bit generates an update event UEV but without setting the UIF flag (thus no interrupt or
DMA request is sent). This is to avoid generating both update and capture interrupt when
clearing the counter on the capture event.
When an update event occurs, all the registers are updated and the update flag (UIF bit in
TIMx_SR register) is set (depending on the URS bit):
● The buffer of the prescaler is reloaded with the preload value (content of the TIMx_PSC
register).
● The auto-reload active register is updated with the preload value (content of the
TIMx_ARR register). Note that if the update source is a counter overflow, the auto-
reload is updated before the counter is reloaded, so that the next period is the expected
one (the counter is loaded with the new value).
The following figures show some examples of the counter behavior for different clock
frequencies.
CK_INT
CNT_EN
Counter register 04 03 02 01 00 01 02 03 04 05 06 05 04 03
Counter underflow
Counter overflow
1. Here, center-aligned mode 1 is used (for more details refer to Section 14.4.1: TIMx control register 1 (TIMx_CR1) on
page 355).
CK_INT
CNT_EN
Counter underflow
CK_INT
CNT_EN
CK_INT
Counter register 20 1F 01 00
Counter underflow
Figure 117. Counter timing diagram, Update event with ARPE=1 (counter underflow)
CK_INT
CNT_EN
Counter register 06 05 04 03 02 01 00 01 02 03 04 05 06 07
Counter underflow
Figure 118. Counter timing diagram, Update event with ARPE=1 (counter overflow)
CK_INT
CNT_EN
Counter register F7 F8 F9 FA FB FC 36 35 34 33 32 31 30 2F
Counter overflow
CK_INT
CEN=CNT_EN
UG
CNT_INIT
COUNTER REGISTER 31 32 33 34 35 36 00 01 02 03 04 05 06 07
TI2F or
or
TI1F or encoder
ITRx 001 mode
TI1F_ED
100
TI1FP1 101 TRGI external clock
TI2F_Rising
mode 1 CK_PSC
0
TI2 Filter Edge TI2FP2 110
Detector TI2F_Falling ETRF external clock
1 ETRF 111 mode 2
ICF[3:0] CC2P CK_INT internal clock
TIMx_CCMR1 TIMx_CCER mode
(internal clock)
ECE SMS[2:0]
TIMx_SMCR
For example, to configure the upcounter to count in response to a rising edge on the TI2
input, use the following procedure:
For example, to configure the upcounter to count in response to a rising edge on the TI2
input, use the following procedure:
1. Configure channel 2 to detect rising edges on the TI2 input by writing CC2S= ‘01’ in the
TIMx_CCMR1 register.
2. Configure the input filter duration by writing the IC2F[3:0] bits in the TIMx_CCMR1
register (if no filter is needed, keep IC2F=0000).
Note: The capture prescaler is not used for triggering, so you don’t need to configure it.
3. Select rising edge polarity by writing CC2P=0 in the TIMx_CCER register.
4. Configure the timer in external clock mode 1 by writing SMS=111 in the TIMx_SMCR
register.
5. Select TI2 as the input source by writing TS=110 in the TIMx_SMCR register.
6. Enable the counter by writing CEN=1 in the TIMx_CR1 register.
When a rising edge occurs on TI2, the counter counts once and the TIF flag is set.
The delay between the rising edge on TI2 and the actual clock of the counter is due to the
resynchronization circuit on TI2 input.
TI2
CNT_EN
Counter register 34 35 36
TIF
Write TIF=0
TI2F or
or
TI1F or encoder
mode
For example, to configure the upcounter to count each 2 rising edges on ETR, use the
following procedure:
1. As no filter is needed in this example, write ETF[3:0]=0000 in the TIMx_SMCR register.
2. Set the prescaler by writing ETPS[1:0]=01 in the TIMx_SMCR register
3. Select rising edge detection on the ETR pin by writing ETP=0 in the TIMx_SMCR
register
4. Enable external clock mode 2 by writing ECE=1 in the TIMx_SMCR register.
5. Enable the counter by writing CEN=1 in the TIMx_CR1 register.
The counter counts once each 2 ETR rising edges.
The delay between the rising edge on ETR and the actual clock of the counter is due to the
resynchronization circuit on the ETRP signal.
fMASTER
CNT_EN
ETR
ETRP
ETRF
Counter register 34 35 36
TI1F_ED
to the slave mode controller
TI1F_Rising 0
TI1 TI1F
filter Edge TI1FP1
01
fDTS downcounter Detector TI1F_Falling
1
TI2FP1 IC1 divider IC1PS
10
/1, /2, /4, /8
ICF[3:0] CC1P TRC
11
TIMx_CCMR1 TIMx_CCER (from slave mode
controller)
TI2F_rising 0
(from channel 2)
CC1S[1:0] ICPS[1:0] CC1E
TI2F_falling
1
(from channel 2) TIMx_CCMR1 TIMx_CCER
The output stage generates an intermediate waveform which is then used for reference:
OCxRef (active high). The polarity acts at the end of the chain.
APB Bus
MCU-peripheral interface
(if 16-bit)
8 8
high
low
S write CCR1H
read CCR1H S write_in_progress
read_in_progress
Capture/Compare Preload Register write CCR1L
read CCR1L R
R CC1S[1]
output
capture_transfer compare_transfer mode
CC1S[0]
CC1S[1] input
mode OC1PE
Capture/Compare Shadow Register OC1PE
CC1S[0] UEV
TIMx_CCMR1
comparator (from time
IC1PS capture base unit)
CC1E CNT>CCR1
Counter
CNT=CCR1
CC1G
TIMx_EGR
CC1P
CNT > CCR1
Output Mode oc1ref TIMx_CCER
CNT = CCR1 Controller
CC1E TIMx_CCER
OC1M[2:0]
TIMx_CCMR1
The capture/compare block is made of one preload register and one shadow register. Write
and read always access the preload register.
In capture mode, captures are actually done in the shadow register, which is copied into the
preload register.
In compare mode, the content of the preload register is copied into the shadow register
which is compared to the counter.
TI1
TIMx_CCR1 0004
TIMx_CCR2 0002
1. The PWM input mode can be used only with the TIMx_CH1/TIMx_CH2 signals due to the fact that only
TI1FP1 and TI2FP2 are connected to the slave mode controller.
To force an output compare signal (ocxref/OCx) to its active level, you just need to write 101
in the OCxM bits in the corresponding TIMx_CCMRx register. Thus ocxref is forced high
(OCxREF is always active high) and OCx get opposite value to CCxP polarity bit.
e.g.: CCxP=0 (OCx active high) => OCx is forced to high level.
ocxref signal can be forced low by writing the OCxM bits to 100 in the TIMx_CCMRx
register.
Anyway, the comparison between the TIMx_CCRx shadow register and the counter is still
performed and allows the flag to be set. Interrupt and DMA requests can be sent
accordingly. This is described in the Output Compare Mode section.
OC1REF=OC1
Counter register 0 1 2 3 4 5 6 7 8 0 1
OCxREF
CCRx=4
CCxIF
OCxREF
CCRx=8
CCxIF
OCxREF ‘1’
CCRx>8
CCxIF
OCxREF ‘0’
CCRx=0
CCxIF
Downcounting configuration
Downcounting is active when DIR bit in TIMx_CR1 register is high. Refer to Downcounting
mode on page 326
In PWM mode 1, the reference signal ocxref is low as long as TIMx_CNT>TIMx_CCRx else
it becomes high. If the compare value in TIMx_CCRx is greater than the auto-reload value in
TIMx_ARR, then ocxref is held at ‘1’. 0% PWM is not possible in this mode.
Counter register 0 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 0 1
OCxREF
CCRx = 4
CCxIF CMS=01
CMS=10
CMS=11
OCxREF
CCRx = 7
CMS=10 or 11
CCxIF
'1'
OCxREF
CCRx = 8
CCxIF CMS=01
CMS=10
CMS=11
'1'
OCxREF
CCRx > 8
CCxIF CMS=01
CMS=10
CMS=11
'0'
OCxREF
CCRx = 0
CCxIF CMS=01
CMS=10
CMS=11
ai14681
OC1REF
OC1
TIM1_ARR
Counter
TIM1_CCR1
0
tDELAY
tPULSE t
For example you may want to generate a positive pulse on OC1 with a length of tPULSE and
after a delay of tDELAY as soon as a positive edge is detected on the TI2 input pin.
Let’s use TI2FP2 as trigger 1:
● Map TI2FP2 on TI2 by writing IC2S=’01’ in the TIMx_CCMR1 register.
● TI2FP2 must detect a rising edge, write CC2P=’0’ in the TIMx_CCER register.
● Configure TI2FP2 as trigger for the slave mode controller (TRGI) by writing TS=’110’ in
the TIMx_SMCR register.
● TI2FP2 is used to start the counter by writing SMS to ‘110’ in the TIMx_SMCR register
(trigger mode).
The OPM waveform is defined by writing the compare registers (taking into account the
clock frequency and the counter prescaler).
● The tDELAY is defined by the value written in the TIMx_CCR1 register.
● The tPULSE is defined by the difference between the auto-reload value and the compare
value (TIMx_ARR - TIMx_CCR1).
● Let’s say you want to build a waveform with a transition from ‘0’ to ‘1’ when a compare
match occurs and a transition from ‘1’ to ‘0’ when the counter reaches the auto-reload
value. To do this you enable PWM mode 2 by writing OC1M=111 in the TIMx_CCMR1
register. You can optionally enable the preload registers by writing OC1PE=’1’ in the
TIMx_CCMR1 register and ARPE in the TIMx_CR1 register. In this case you have to
write the compare value in the TIMx_CCR1 register, the auto-reload value in the
TIMx_ARR register, generate an update by setting the UG bit and wait for external
trigger event on TI2. CC1P is written to ‘0’ in this example.
In our example, the DIR and CMS bits in the TIMx_CR1 register should be low.
You only want 1 pulse, so you write ‘1’ in the OPM bit in the TIMx_CR1 register to stop the
counter at the next update event (when the counter rolls over from the auto-reload value
back to 0).
(CCRx)
counter (CNT)
ETRF
OCxREF
(OCxCE=’0’)
OCxREF
(OCxCE=’1’)
OCREF_CLR OCREF_CLR
becomes high still high
An external incremental encoder can be connected directly to the MCU without external
interface logic. However, comparators are normally be used to convert the encoder’s
differential outputs to digital signals. This greatly increases noise immunity. The third
encoder output which indicate the mechanical zero position, may be connected to an
external interrupt input and trigger a counter reset.
The Figure 133 gives an example of counter operation, showing count signal generation and
direction control. It also shows how input jitter is compensated where both edges are
selected. This might occur if the sensor is positioned near to one of the switching points. For
this example we assume that the configuration is the following:
● CC1S=’01’ (TIMx_CCMR1 register, IC1FP1 mapped on TI1).
● CC2S=’01’ (TIMx_CCMR2 register, IC2FP2 mapped on TI2).
● CC1P=’0’ (TIMx_CCER register, IC1FP1 non-inverted, IC1FP1=TI1).
● CC2P=’0’ (TIMx_CCER register, IC2FP2 non-inverted, IC2FP2=TI2).
● SMS=’011’ (TIMx_SMCR register, both inputs are active on both rising and falling
edges).
● CEN=’1’ (TIMx_CR1 register, Counter is enabled).
TI1
TI2
Counter
up down up
Figure 134 gives an example of counter behavior when IC1FP1 polarity is inverted (same
configuration as above except CC1P=’1’).
Figure 134. Example of encoder interface mode with IC1FP1 polarity inverted.
forward jitter backward jitter forward
TI1
TI2
Counter
down up down
The timer, when configured in Encoder Interface mode provides information on the sensor’s
current position. You can obtain dynamic information (speed, acceleration, deceleration) by
measuring the period between two encoder events using a second timer configured in
capture mode. The output of the encoder which indicates the mechanical zero can be used
for this purpose. Depending on the time between two events, the counter can also be read
at regular times. You can do this by latching the counter value into a third input capture
register if available (then the capture signal must be periodic and can be generated by
another timer). when available, it is also possible to read its value through a DMA request
generated by a Real-Time clock.
● Configure the timer in reset mode by writing SMS=100 in TIMx_SMCR register. Select
TI1 as the input source by writing TS=101 in TIMx_SMCR register.
● Start the counter by writing CEN=1 in the TIMx_CR1 register.
The counter starts counting on the internal clock, then behaves normally until TI1 rising
edge. When TI1 rises, the counter is cleared and restarts from 0. In the meantime, the
trigger flag is set (TIF bit in the TIMx_SR register) and an interrupt request, or a DMA
request can be sent if enabled (depending on the TIE and TDE bits in TIMx_DIER register).
The following figure shows this behavior when the auto-reload register TIMx_ARR=0x36.
The delay between the rising edge on TI1 and the actual reset of the counter is due to the
resynchronization circuit on TI1 input.
TI1
UG
Counter register 30 31 32 33 34 35 36 00 01 02 03 00 01 02 03
TIF
TI1
CNT_EN
Counter register 30 31 32 33 34 35 36 37 38
TIF
Write TIF=0
TI2
CNT_EN
Counter register 34 35 36 37 38
TIF
In the following example, the upcounter is incremented at each rising edge of the ETR signal
as soon as a rising edge of TI1 occurs:
1. Configure the external trigger input circuit by programming the TIMx_SMCR register as
follows:
– ETF = 0000: no filter
– ETPS=00: prescaler disabled
– ETP=0: detection of rising edges on ETR and ECE=1 to enable the external clock
mode 2.
2. Configure the channel 1 as follows, to detect rising edges on TI:
– IC1F=0000: no filter.
– The capture prescaler is not used for triggering and does not need to be
configured.
– CC1S=01in TIMx_CCMR1 register to select only the input capture source
– CC1P=0 in TIMx_CCER register to validate the polarity (and detect rising edge
only).
3. Configure the timer in trigger mode by writing SMS=110 in TIMx_SMCR register. Select
TI1 as the input source by writing TS=101 in TIMx_SMCR register.
A rising edge on TI1 enables the counter and sets the TIF flag. The counter then counts on
ETR rising edges.
The delay between the rising edge of the ETR signal and the actual reset of the counter is
due to the resynchronization circuit on ETRP input.
TI1
CEN/CNT_EN
ETR
Counter register 34 35 36
TIF
TIMER 1 TIMER 2
Input
trigger
selection
For example, you can configure Timer 1 to act as a prescaler for Timer 2. Refer to
Figure 139. To do this:
● Configure Timer 1 in master mode so that it outputs a periodic trigger signal on each
update event UEV. If you write MMS=010 in the TIM1_CR2 register, a rising edge is
output on TRGO1 each time an update event is generated.
● To connect the TRGO1 output of Timer 1 to Timer 2, Timer 2 must be configured in
slave mode using ITR1 as internal trigger. You select this through the TS bits in the
TIM2_SMCR register (writing TS=000).
● Then you put the slave mode controller in external clock mode 1 (write SMS=111 in the
TIM2_SMCR register). This causes Timer 2 to be clocked by the rising edge of the
periodic Timer 1 trigger signal (which correspond to the timer 1 counter overflow).
● Finally both timers must be enabled by setting their respective CEN bits (TIMx_CR1
register).
Note: If OCx is selected on Timer 1 as trigger output (MMS=1xx), its rising edge is used to clock
the counter of timer 2.
CK_INT
TIMER1-OC1REF
TIMER1-CNT FC FD FE FF 00 01
TIMER 2-TIF
Write TIF=0
In the example in Figure 140, the Timer 2 counter and prescaler are not initialized before
being started. So they start counting from their current value. It is possible to start from a
given value by resetting both timers before starting Timer 1. You can then write any value
you want in the timer counters. The timers can easily be reset by software using the UG bit
in the TIMx_EGR registers.
In the next example, we synchronize Timer 1 and Timer 2. Timer 1 is the master and starts
from 0. Timer 2 is the slave and starts from 0xE7. The prescaler ratio is the same for both
timers. Timer 2 stops when Timer 1 is disabled by writing ‘0’ to the CEN bit in the TIM1_CR1
register:
● Configure Timer 1 master mode to send its Output Compare 1 Reference (OC1REF)
signal as trigger output (MMS=100 in the TIM1_CR2 register).
● Configure the Timer 1 OC1REF waveform (TIM1_CCMR1 register).
● Configure Timer 2 to get the input trigger from Timer 1 (TS=000 in the TIM2_SMCR
register).
● Configure Timer 2 in gated mode (SMS=101 in TIM2_SMCR register).
● Reset Timer 1 by writing ‘1’ in UG bit (TIM1_EGR register).
● Reset Timer 2 by writing ‘1’ in UG bit (TIM2_EGR register).
● Initialize Timer 2 to 0xE7 by writing ‘0xE7’ in the timer 2 counter (TIM2_CNTL).
● Enable Timer 2 by writing ‘1’ in the CEN bit (TIM2_CR1 register).
● Start Timer 1 by writing ‘1’ in the CEN bit (TIM1_CR1 register).
● Stop Timer 1 by writing ‘0’ in the CEN bit (TIM1_CR1 register).
CK_INT
TIMER1-CEN=CNT_EN
TIMER1-CNT_INIT
TIMER1-CNT 75 00 01 02
TIMER2-CNT AB 00 E7 E8 E9
TIMER2-CNT_INIT
TIMER2
write CNT
TIMER 2-TIF
Write TIF=0
CK_INT
TIMER1-UEV
TIMER1-CNT FD FE FF 00 01 02
TIMER2-CNT 45 46 47 48
TIMER2-CEN=CNT_EN
TIMER 2-TIF
Write TIF=0
As in the previous example, you can initialize both counters before starting counting.
Figure 143 shows the behavior with the same configuration as in Figure 142 but in trigger
mode instead of gated mode (SMS=110 in the TIM2_SMCR register).
CK_INT
TIMER1-CEN=CNT_EN
TIMER1-CNT_INIT
TIMER1-CNT 75 00 01 02
TIMER2-CNT CD 00 E7 E8 E9 EA
TIMER2-CNT_INIT
TIMER2
write CNT
TIMER 2-TIF
Write TIF=0
counters are aligned, Timer 1 must be configured in Master/Slave mode (slave with respect
to TI1, master with respect to Timer 2):
● Configure Timer 1 master mode to send its Enable as trigger output (MMS=001 in the
TIM1_CR2 register).
● Configure Timer 1 slave mode to get the input trigger from TI1 (TS=100 in the
TIM1_SMCR register).
● Configure Timer 1 in trigger mode (SMS=110 in the TIM1_SMCR register).
● Configure the Timer 1 in Master/Slave mode by writing MSM=’1’ (TIM1_SMCR
register).
● Configure Timer 2 to get the input trigger from Timer 1 (TS=000 in the TIM2_SMCR
register).
● Configure Timer 2 in trigger mode (SMS=110 in the TIM2_SMCR register).
When a rising edge occurs on TI1 (Timer 1), both counters starts counting synchronously on
the internal clock and both TIF flags are set.
Note: In this example both timers are initialized before starting (by setting their respective UG
bits). Both counters starts from 0, but you can easily insert an offset between them by
writing any of the counter registers (TIMx_CNT). You can see that the master/slave mode
insert a delay between CNT_EN and CK_PSC on timer 1.
CK_INT
TIMER 1-TI1
TIMER1-CEN=CNT_EN
TIMER 1-CK_PSC
TIMER1-CNT 00 01 02 03 04 05 06 07 08 09
TIMER1-TIF
TIMER2-CEN=CNT_EN
TIMER 2-CK_PSC
TIMER2-CNT 00 01 02 03 04 05 06 07 08 09
TIMER2-TIF
Note: The state of the external I/O pins connected to the standard OCx channels depends on the
OCx channel state and the GPIO and AFIO registers.
9
8
7
6
5
4
3
2
1
0
ARPE
UDIS
OPM
CKD CMS
CEN
URS
DIR
TIMx_CR1
0x00 Reserved [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0
CCDS
TI1S
TIMx_CR2 MMS[2:0]
0x04 Reserved Reserved
Reset value 0 0 0 0 0
CC3IE Reserved
MSM
ETPS
ECE
ETP
Reserved
CC2IE
CC1IE
UDE
TDE
UIE
TIE
TIMx_DIER
0x0C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0
CC4OF
CC3OF
CC2OF
CC1OF
Reserved
CC4IF
CC3IF
CC2IF
CC1IF
UIF
TIF
TIMx_SR
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0
CC4G
CC3G
CC2G
CC1G
UG
TG
TIMx_EGR
0x14 Reserved
Reset value 0 0 0 0 0 0
TIMx_CCMR1
OC2CE
OC1CE
OC2PE
OC1PE
OC2FE
OC1FE
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
TIMx_CCMR2
OC3CE
OC4PE
OC3PE
OC4FE
OC3FE
O24CE
OC4M CC4S OC3M CC3S
Output Compare
Reserved [2:0] [1:0] [2:0] [1:0]
mode
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x1C
TIMx_CCMR2 IC4 IC3
CC4S CC3S
Input Capture IC4F[3:0] PSC IC3F[3:0] PSC
Reserved [1:0] [1:0]
mode [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Reserved
Reserved
Reserved
CC4P
CC4E
CC3P
CC3E
CC2P
CC2E
CC1P
CC1E
TIMx_CCER
0x20 Reserved
Reset value 0 0 0 0 0 0 0 0
TIMx_CNT CNT[15:0]
0x24 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_PSC PSC[15:0]
0x28 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_ARR ARR[15:0]
0x2C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x30 Reserved
TIMx_CCR1 CCR1[15:0]
0x34 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_CCR2 CCR2[15:0]
0x38 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_CCR3 CCR3[15:0]
0x3C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_CCR4 CCR4[15:0]
0x40 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x44 Reserved
TIMx_DMAR DMAB[15:0]
0x4C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
U
Auto-reload Register UI
Stop, Clear or up
U
CK_PSC PSC CK_CNT CNT
±
Prescaler COUNTER
Prescaler description
The prescaler can divide the counter clock frequency by any factor between 1 and 65536. It
is based on a 16-bit counter controlled through a 16-bit register (in the TIMx_PSC register).
It can be changed on the fly as the TIMx_PSC control register is buffered. The new
prescaler ratio is taken into account at the next update event.
Figure 146 and Figure 147 give some examples of the counter behavior when the prescaler
ratio is changed on the fly.
Figure 146. Counter timing diagram with prescaler division change from 1 to 2
CK_PSC
CNT_EN
Counter register F7 F8 F9 FA FB FC 00 01 02 03
Prescaler buffer 0 1
Prescaler counter 0 0 1 0 1 0 1 0 1
Figure 147. Counter timing diagram with prescaler division change from 1 to 4
CK_PSC
CNT_EN
Counter register F7 F8 F9 FA FB FC 00 01
Prescaler buffer 0 3
Prescaler counter 0 0 1 2 3 0 1 2 3
CK_INT
CNT_EN
Counter register 31 32 33 34 35 36 00 01 02 03 04 05 06 07
Counter overflow
CK_INT
CNT_EN
Counter overflow
CK_INT
CNT_EN
Counter overflow
CK_INT
Counter register 1F 20 00
Counter overflow
Figure 152. Counter timing diagram, update event when ARPE = 0 (TIMx_ARR not
preloaded)
CK_INT
CNT_EN
Counter register 31 32 33 34 35 36 00 01 02 03 04 05 06 07
Counter overflow
Auto-reload register FF 36
Figure 153. Counter timing diagram, update event when ARPE=1 (TIMx_ARR
preloaded)
CK_PSC
CNT_EN
Counter register F0 F1 F2 F3 F4 F5 00 01 02 03 04 05 06 07
Counter overflow
CK_INT
CEN=CNT_EN
UG
CNT_INIT
Counter register 31 32 33 34 35 36 00 01 02 03 04 05 06 07
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
Reserved
ARPE
UDIS
OPM
URS
CEN
TIMx_CR1
0x00 Reserved
Reset value 0 0 0 0 0
Reserved
TIMx_CR2 MMS[2:0]
0x04 Reserved
Reset value 0 0 0
0x08 Reserved
Reserved
UDE
UIE
TIMx_DIER
0x0C Reserved
Reset value 0 0
UIF
TIMx_SR
0x10 Reserved
Reset value 0
UG
TIMx_EGR
0x14 Reserved
Reset value 0
0x18 Reserved
0x1C Reserved
0x20 Reserved
TIMx_CNT CNT[15:0]
0x24 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_PSC PSC[15:0]
0x28 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TIMx_ARR ARR[15:0]
0x2C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16.3.1 Overview
The RTC consists of two main units (see Figure 155 on page 389). The first one (APB1
Interface) is used to interface with the APB1 bus. This unit also contains a set of 16-bit
registers accessible from the APB1 bus in read or write mode (for more information refer to
Section 16.4: RTC registers on page 392). The APB1 interface is clocked by the APB1 bus
clock in order to interface with the APB1 bus.
The other unit (RTC Core) consists of a chain of programmable counters made of two main
blocks. The first block is the RTC prescaler block, which generates the RTC time base
TR_CLK that can be programmed to have a period of up to 1 second. It includes a 20-bit
programmable divider (RTC Prescaler). Every TR_CLK period, the RTC generates an
interrupt (Second Interrupt) if it is enabled in the RTC_CR register. The second block is a
32-bit programmable counter that can be initialized to the current system time. The system
time is incremented at the TR_CLK rate and compared with a programmable date (stored in
the RTC_ALR register) in order to generate an alarm interrupt, if enabled in the RTC_CR
control register.
APB1 bus
PCLK1
RTC_CR
RTC_PRL
RTC_Second
SECF
Reload 32-bit programmable
counter SECIE
TR_CLK RTC_Overflow
RTC_DIV RTC_CNT OWF
rising OWIE
edge RTC_Alarm
= ALRF
RTC prescaler
ALRIE
RTC_ALR not powered in Standby
powered in Standby
NVIC interrupt
powered in Standby controller
RTC_Alarm exit
WKUP pin Standby mode
WKP_STDBY
powered in Standby
ai14969
Configuration procedure:
1. Poll RTOFF, wait until its value goes to ‘1’
2. Set the CNF bit to enter configuration mode
3. Write to one or more RTC registers
4. Clear the CNF bit to exit configuration mode
5. Poll RTOFF, wait until its value goes to ‘1’ to check the end of the write operation.
The write operation only executes when the CNF bit is cleared; it takes at least three
RTCCLK cycles to complete.
Figure 156. RTC second and alarm waveform example with PR=0003, ALARM=00004
RTCCLK
RTC_PR 0002 0001 0000 0003 0002 0001 0000 0003 0002 0001 0000 0003 0002 0001 0000 0003 0002 0001 0000 0003 0002 0001 0000 0003
RTC_Second
RTC_ALARM
1 RTCCLK
RTC_PR 0002 0001 0000 0003 0002 0001 0000 0003 0002 0001 0000 0003 0002 0001 0000 0003 0002 0001 0000 0003 0002 0001 0000 0003
RTC_Second
RTC_Overflow
1 RTCCLK
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
These bits are used to mask interrupt requests. Note that at reset all interrupts are disabled,
so it is possible to write to the RTC registers to ensure that no interrupt requests are pending
after initialization. It is not possible to write to the RTC_CRH register when the peripheral is
completing a previous write operation (flagged by RTOFF=0, see Section 16.3.4 on page
390).
The RTC functions are controlled by this control register. Some bits must be written using a
specific configuration procedure (see Configuration procedure:).
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
The functions of the RTC are controlled by this control register. It is not possible to write to
the RTC_CR register while the peripheral is completing a previous write operation (flagged
by RTOFF=0, see Section 16.3.4 on page 390).
Note: 1 Any flag remains pending until the appropriate RTC_CR request bit is reset by software,
indicating that the interrupt request has been granted.
2 At reset the interrupts are disabled, no interrupt requests are pending and it is possible to
write to the RTC registers.
3 The OWF, ALRF, SECF and RSF bits are not updated when the APB1 clock is not running.
4 The OWF, ALRF, SECF and RSF bits can only be set by hardware and only cleared by
software.
5 If ALRF = 1 and ALRIE = 1, the RTC global interrupt is enabled. If EXTI Line 17 is also
enabled through the EXTI Controller, both the RTC global interrupt and the RTC Alarm
interrupt are enabled.
6 If ALRF = 1, the RTC Alarm interrupt is enabled if EXTI Line 17 is enabled through the EXTI
Controller in interrupt mode. When the EXTI Line 17 is enabled in event mode, a pulse is
generated on this line (no RTC Alarm interrupt generation).
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PRL[19:16]
Reserved
w w w w
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PRL[15:0]
w w w w w w w w w w w w w w w w
Note: If the input clock frequency (fRTCCLK) is 32.768 kHz, write 7FFFh in this register to get a
signal period of 1 second.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RTC_DIV[19:16]
Reserved
r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RTC_DIV[15:0]
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RTC_CNT[31:16]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RTC_CNT[15:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RTC_ALR[31:16]
w w w w w w w w w w w w w w w w
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RTC_ALR[15:0]
w w w w w w w w w w w w w w w w
9
8
7
6
5
4
3
2
1
0 SECIE
ALRIE
OWIE
RTC_CRH
0x000 Reserved
Reset value 0 0 0
RTOFF
SECF
ALRF
OWF
CNF
RSF
RTC_CRL
0x004 Reserved
Reset value 1 0 0 0 0 0
RTC_PRLH PRL[19:16]
0x008 Reserved
Reset value 0 0 0 0
RTC_PRLL PRL[15:0]
0x00C Reserved
Reset value 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RTC_DIVH DIV[31:16]
0x010 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RTC_DIVL DIV[15:0]
0x014 Reserved
Reset value 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RTC_CNTL CNT[15:0]
0x01C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RTC_ALRH ALR[31:16]
0x020 Reserved
Reset value 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
RTC_ALRL ALR[15:0]
0x024 Reserved
Reset value 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Note: The watchdog function is implemented in the VDD voltage domain that is still functional in
Stop and Standby modes.
Table 81. Watchdog timeout period (with 40 kHz input clock)Min/max IWDG timeout
period at 32 kHz (LSI) (1)
Prescaler divider PR[2:0] bits Min timeout (ms) RL[11:0]= 0x000 Max timeout (ms) RL[11:0]= 0xFFF
/4 0 0.1 409.6
/8 1 0.2 819.2
/16 2 0.4 1638.4
/32 3 0.8 3276.8
/64 4 1.6 6553.6
/128 5 3.2 13107.2
/256 6 (or 7) 6.4 26214.4
1. These timings are given for a 40 kHz clock but the microcontroller’s internal RC frequency can vary from 30 to 60 kHz.
Moreover, given an exact RC oscillator frequency, the exact timings still depend on the phasing of the APB interface clock
versus the LSI clock so that there is always a full RC period of uncertainty.
The LSI can be calibrated so as to compute the IWDG timeout with an acceptable accuracy.
For more details refer to LSI calibration on page 80.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RVU PVU
Reserved Reserved
r r
Note: If several reload values or prescaler values are used by application, it is mandatory to wait
until RVU bit is reset before changing the reload value and to wait until PVU bit is reset
before changing the prescaler value. However, after updating the prescaler and/or the
reload value it is not necessary to wait until RVU or PVU is reset before continuing code
execution (even in case of low-power mode entry, the write operation is taken into account
and will complete)
RVU
PVU
IWDG_SR
0x0C Reserved
Reset value 0 0
- W6 W5 W4 W3 W2 W1 W0
comparator
= 1 when
T6:0 > W6:0 CMP
Write WWDG_CR
Watchdog control register (WWDG_CR)
WDGA T6 T5 T4 T3 T2 T1 T0
6-bit downcounter (CNT)
PCLK1
(from RCC clock controller)
WDG prescaler
(WDGTB)
The application program must write in the WWDG_CR register at regular intervals during
normal operation to prevent an MCU reset. This operation must occur only when the counter
value is lower than the window register value. The value to be stored in the WWDG_CR
register must be between 0xFF and 0xC0:
● Enabling the watchdog:
The watchdog is always disabled after a reset. It is enabled by setting the WDGA bit in
the WWDG_CR register, then it cannot be disabled again except by a reset.
● Controlling the downcounter:
This downcounter is free-running: It counts down even if the watchdog is disabled.
When the watchdog is enabled, the T6 bit must be set to prevent generating an
immediate reset.
The T[5:0] bits contain the number of increments which represents the time delay
before the watchdog produces a reset. The timing varies between a minimum and a
maximum value due to the unknown status of the prescaler when writing to the
WWDG_CR register (see Figure 160).
The Configuration register (WWDG_CFR) contains the high limit of the window: To
prevent a reset, the downcounter must be reloaded when its value is lower than the
window register value and greater than 0x3F. Figure 160 describes the window
watchdog process.
Another way to reload the counter is to use the early wakeup interrupt (EWI). This
interrupt is enabled by setting the EWI bit in the WWDG_CFR register. When the
downcounter reaches the value 40h, this interrupt is generated and the corresponding
interrupt service routine (ISR) can be used to reload the counter to prevent WWDG
reset.
This interrupt is cleared by writing '0' to the EWIF bit in the WWDG_SR register.
Note: The T6 bit can be used to generate a software reset (the WDGA bit is set and the T6 bit is
cleared).
W[6:0]
3Fh
time
Refresh not allowed Refresh window
T6 bit
Reset
where:
TWWDG: WWDG timeout
TPCLK1: APB1 clock period measured in ms
Min-max timeout value @36 MHz (PCLK1)
WDGTB Min timeout value Max timeout value
0 113 µs 7.28 ms
1 227 µs 14.56 ms
2 455 µs 29.12 ms
3 910 µs 58.25 ms
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
WDGA T6 T5 T4 T3 T2 T1 T0
Reserved
rs rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
WDG WDG
EWI W6 W5 W4 W3 W2 W1 W0
TB1 TB0
Reserved
rs rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
EWIF
Reserved
rc_w0
Bit 31:1Reserved
Bit 0 EWIF: Early wakeup interrupt flag
This bit is set by hardware when the counter has reached the value 40h. It must be cleared
by software by writing ‘0’. A write of ‘1’ has no effect. This bit is also set if the interrupt is not
enabled.
Offset Register
9
8
7
6
5
4
3
2
1
0
WDGA
WWDG_CR T[6:0]
0x00 Reserved
Reset value 0 1 1 1 1 1 1 1
WDGTB1
WDGTB0
EWI
WWDG_CFR W[6:0]
0x04 Reserved
Reset value 0 0 0 1 1 1 1 1 1 1
EWIF
WWDG_SR
0x08 Reserved
Reset value 0
● Write FIFO, 16 words long, each word 32 bits wide. This makes it possible to write to
slow memories and free the AHB quickly for other transactions. If a new transaction is
started to the FSMC, first the FIFO is drained
The FSMC registers that define the external device type and associated characteristics are
usually set at boot time and do not change until the next reset or power-up. However, it is
possible to change the settings at any time.
This situation occurs when a byte access is requested to a 16-bit wide Flash
memory. Clearly, the device cannot be accessed in byte mode (only 16-bit words
can be read from/written to the Flash memory) therefore:
a) Write transactions are not allowed
b) Read transactions are allowed (the controller reads the entire 16-bit memory word
and uses the needed byte only).
Configuration registers
The FSMC can be configured using a register set. See Section 19.5.6, for a detailed
description of the NOR Flash/PSRAM controller registers. See Section 19.6.7, for a detailed
description of the NAND Flash/PC Card registers.
6000 0000h
Bank 1
NOR / PSRAM
4 × 64 MB
6FF F FFF Fh
7000 0000h
Bank 2
4 × 64 MB
7FF F FFF Fh
NAND Flash
8000 0000h
Bank 3
4 × 64 MB
8FF F FFF Fh
9000 0000h
Bank 4
PC Card
4 × 64 MB
9FF F FFF Fh
ai14719
00 Bank 1 NOR/PSRAM 1
01 Bank 1 NOR/PSRAM 2
10 Bank 1 NOR/PSRAM 3
11 Bank 1 NOR/PSRAM 4
1. HADDR are internal AHB address lines that are translated to external memory.
HADDR[25:0] contain the external memory address. Since HADDR is a byte address
whereas the memory is addressed in words, the address actually issued to the memory
varies according to the memory data width, as shown in the following table.
For NAND Flash memory, the common and attribute memory spaces are subdivided into
three sections (see in Table 87 below) located in the lower 256 Kbytes:
● Data section (first 64 Kbytes in the common/attribute memory space)
● Command section (second 64 Kbytes in the common / attribute memory space)
● Address section (next 128 Kbytes in the common / attribute memory space)
The application software uses the 3 sections to access the NAND Flash memory:
● To send a command to NAND Flash memory: the software must write the command
value to any memory location in the command section.
● To specify the NAND Flash address that must be read or written: the software must
write the address value to any memory location in the address section. Since an
address can be 4 or 5 bytes long (depending on the actual memory size), several
consecutive writes to the address section are needed to specify the full address.
● To read or write data: the software reads or writes the data value from or to any
memory location in the data section.
Since the NAND Flash memory automatically increments addresses, there is no need to
increment the address of the data section to access consecutive memory locations.
NOR Flash memories are addressed in 16-bit words. The maximum capacity is 512 Mbit (26
address lines).
NOR-Flash memories are addressed in 16-bit words. The maximum capacity is 512 Mbit
(26 address lines).
PSRAM
NE[x] O Chip select, x = 1..4 (called NCE by PSRAM (Cellular RAM i.e. CRAM))
NOE O Output enable
NWE O Write enable
NL(= NADV) O Address valid PSRAM input (memory signal name: NADV)
NWAIT I PSRAM wait input signal to the FSMC
NBL[1] O Upper byte enable (memory signal name: NUB)
NBL[0] O Lowed byte enable (memory signal name: NLB)
PSRAM memories are addressed in 16-bit words. The maximum capacity is 512 Mbit (26
address lines).
Asynchronous R 8 16 Y
Asynchronous W 8 16 N
Asynchronous R 16 16 Y
Asynchronous W 16 16 Y
Split into 2 FSMC
NOR Flash Asynchronous R 32 16 Y
accesses
(muxed I/Os
and nonmuxed Asynchronous Split into 2 FSMC
W 32 16 Y
I/Os) accesses
Asynchronous
R - 16 N Mode is not supported
page
Synchronous R 8 16 N
Synchronous R 16 16 Y
Synchronous R 32 16 Y
Asynchronous R 8 16 Y
Asynchronous W 8 16 Y Use of byte lanes NBL[1:0]
Asynchronous R 16 16 Y
Asynchronous W 16 16 Y
Split into 2 FSMC
Asynchronous R 32 16 Y
accesses
PSRAM Split into 2 FSMC
(muxed I/Os Asynchronous W 32 16 Y
accesses
and nonmuxed
I/Os) Asynchronous
R - 16 N Mode is not supported
page
Synchronous R 8 16 N
Synchronous R 16 16 Y
Synchronous R 32 16 Y
Synchronous W 8 16 Y Use of byte lanes NBL[1:0]
Synchronous W 16/32 16 Y
8 / 16 /
Asynchronous R 8 / 16 Y Use of byte lanes NBL[1:0]
SRAM and 32
ROM 8 / 16 /
Asynchronous W 8 / 16 Y Use of byte lanes NBL[1:0]
32
Mode 1 - SRAM/CRAM
Memory transaction
A[25:0]
NBL[1:0]
NEx
NOE
NWE
High
Mode1 write accessesThe one HCLK cycle at the end of the write transaction helps
Memory transaction
A[25:0]
NBL[1:0]
NEx
NOE
1HCLK
NWE
guarantee the address and data hold time after the NWE rising edge. Due to the presence
of this one HCLK cycle, the DATAST value must be greater than zero (DATAST > 0).
31-15 0x0000
14-10 0x0
9 WAITPOL Meaningful only if bit 15 is 1
8 BURSTEN 0x0
7 -
6 FACCEN -
5-4 MWID As needed
3-2 MTYP As needed, exclude 10 (NOR Flash)
1 MUXEN 0x0
0 MBKEN 0x1
31-16 0x0000
Duration of the second access phase (DATAST+1 HCLK cycles for
15-8 DATAST write accesses, DATAST+3 HCLK cycles for read accesses).
This value cannot be 0 (minimum is 1).
7-4 0x0
3-0 ADDSET Duration of the first access phase (ADDSET+1 HCLK cycles) .
A[25:0]
NBL[1:0]
NEx
NOE
NWE
High
A[25:0]
NBL[1:0]
NEx
NOE
1HCLK
NWE
The differences compared with mode1 are the toggling of NOE and the independent read
and write timings.
31-16 0x0000
15 0x0
14 EXTMOD 0x1
13-10 0x0
9 WAITPOL Meaningful only if bit 15 is 1
8 BURSTEN 0x0
7 -
6 FACCEN -
5-4 MWID As needed
3-2 MTYP As needed, exclude 10 (NOR Flash)
1 MUXEN 0x0
0 MBKEN 0x1
31-30 0x0
29-28 ACCMOD 0x0
27-16 0x000
Duration of the second access phase (DATAST+3 HCLK cycles) in
15-8 DATAST
read. This value cannot be 0 (minimum is 1)
7-4 0x0
3-0 ADDSET Duration of the first access phase (ADDSET+1 HCLK cycles) in read.
31-30 0x0
29-28 ACCMOD 0x0
27-16 0x000
Duration of the second access phase (DATAST+1 HCLK cycles) in
15-8 DATAST
write. This value cannot be 0 (minimum is 1).
7-4 0x0
Duration of the first access phase (ADDSET+1 HCLK cycles) in write
3-0 ADDSET
A[25:0]
NADV
NEx
NOE
NWE
High
A[25:0]
NADV
NEx
NOE
1HCLK
NWE
Memory transaction
A[25:0]
NADV
NEx
NOE
1HCLK
NWE
The differences with mode1 are the toggling of NADV and the independent read and write
timings when extended mode is set (Mode B).
31-15 0x0000
14 EXTMOD 0x1 for mode B, 0x0 for mode 2
13-10 0x0
9 WAITPOL Meaningful only if bit 15 is 1
8 BURSTEN 0x0
7 -
6 FACCEN 0x1
5-4 MWID As needed
3-2 MTYP 10 (NOR Flash)
1 MUXEN 0x0
0 MBKEN 0x1
31-30 0x0
29-28 ACCMOD 0x1 if extended mode is set
27-16 0x000
Duration of the access second phase (DATAST+3 HCLK cycles) in
15-8 DATAST
read. This value can not be 0 (minimum is 1)
7-4 0x0
Duration of the access first phase (ADDSET+1 HCLK cycles) in
3-0 ADDSET
read.
31-30 0x0
29-28 ACCMOD 0x1 if extended mode is set
27-16 0x000
Duration of the access second phase (DATAST+1 HCLK cycles) in
15-8 DATAST
write. This value can not be 0 (minimum is 1).
7-4 0x0
Duration of the access first phase (ADDSET+1 HCLK cycles) in
3-0 ADDSET
write.
Note: The FSMC_BWTRx register is valid only if extended mode is set (mode B), otherwise all its
content is don’t care.
A[25:0]
NADV
NEx
NOE
NWE
High
A[25:0]
NADV
NEx
NOE
1HCLK
NWE
The differences compared with mode1 are the toggling of NOE and NADV and the
independent read and write timings.
31-15 0x0000
14 EXTMOD 0x1
13-10 0x0
9 WAITPOL Meaningful only if bit 15 is 1
8 BURSTEN 0x0
7 -
6 FACCEN 1
5-4 MWID As needed
3-2 MTYP 0x02 (NOR Flash)
1 MUXEN 0x0
0 MBKEN 0x1
31-30 0x0
29-28 ACCMOD 0x2
27-16 0x000
Duration of the second access phase (DATAST+3 HCLK cycles) in
15-8 DATAST
read. This value cannot be 0 (minimum is 1)
7-4 0x0
Duration of the first access phase (ADDSET+1 HCLK cycles) in
3-0 ADDSET
read.
31-30 0x0
29-28 ACCMOD 0x2
27-16 0x000
Duration of the second access phase (DATAST+1 HCLK cycles) in
15-8 DATAST
write. This value cannot be 0 (minimum is 1)
7-4 0x0
Duration of the first access phase (ADDSET+1 HCLK cycles) in
3-0 ADDSET
write.
A[25:0]
NADV
NEx
NOE
NWE
High
ModeD write accessesThe differences with mode1 are the toggling of NADV, NOE that
Memory transaction
A[25:0]
NADV
NEx
NOE
1HCLK
NWE
goes on toggling after NADV changes and the independent read and write timings.
31-15 0x0000
14 EXTMOD 0x1
13-10 0x0
9 WAITPOL Meaningful only if bit 15 is 1
8 BURSTEN 0x0
7 -
6 FACCEN Set according to memory support
5-4 MWID As needed
3-2 MTYP As needed
1 MUXEN 0x0
0 MBKEN 0x1
31-30 0x0
29-28 ACCMOD 0x2
27-16 0x000
Duration of the second access phase (DATAST+3 HCLK cycles) in
15-8 DATAST
read. This value cannot be 0 (minimum is 1)
Duration of the middle phase of the read access (ADDHLD+1 HCLK
7-4 ADDHLD
cycles)
Duration of the first access phase (ADDSET+1 HCLK cycles) in
3-0 ADDSET
read.
31-30 0x0
29-28 ACCMOD 0x2
27-16 0x000
Duration of the second access phase (DATAST+1 HCLK cycles) in
15-8 DATAST
write. This value cannot be 0 (minimum is 1)
Duration of the middle phase of the write access (ADDHLD+1 HCLK
7-4 ADDHLD
cycles)
3-0 ADDSET Duration of the first access phase (ADDSET+1 HCLK cycles) in write.
A[25:16]
NADV
NEx
NOE
NWE
High
1. The bus turnaround delay (BUSTURN + 1) and the delay between side-by-side transactions overlap, so
BUSTURN 5 has not impact.
A[25:16]
NADV
NEx
NOE
1HCLK
NWE
The difference with mode D is the drive of the lower address byte(s) on the databus.
31-15 0x0000
14 EXTMOD 0x0
13-10 0x0
9 WAITPOL Meaningful only if bit 15 is 1
8 BURSTEN 0x0
7 -
6 FACCEN 0x1
5-4 MWID As needed
3-2 MTYP 0x2 (NOR)
1 MUXEN 0x1
0 MBKEN 0x1
31-20 0x0000
Duration of the last phase of the access (BUSTURN+1 HCLK)
19-16 BUSTURN
Single-burst transfer
When the selected bank is configured in synchronous burst mode, if an AHB single-burst
transaction is requested, the FSMC performs a burst transaction of length 1 (if the AHB
transfer is 16-bit), or length 2 (if the AHB transfer is 32-bit) and de-assert the chip select
signal when the last data is strobed.
Clearly, such a transfer is not the most efficient in terms of cycles (compared to an
asynchronous read). Nevertheless, a random asynchronous access would first require to re-
program the memory access mode, which would altogether last longer.
Wait management
For synchronous burst NOR Flash, NWAIT is evaluated after the programmed latency
period, (DATALAT+1) CLK clock cycles.
If NWAIT is sensed active (low level when WAITPOL = 0, high level when WAITPOL = 1),
wait states are inserted until NWAIT is sensed inactive (high level when WAITPOL = 0, low
level when WAITPOL = 1).
When NWAIT is inactive, the data is considered valid either immediately (bit WAITCFG = 1)
or on the next clock edge (bit WAITCFG = 0).
During wait-state insertion via the NWAIT signal, the controller continues to send clock
pulses to the memory, keeping the chip select and output enable signals valid, and does not
consider the data valid.
There are two timing configurations for the NOR Flash NWAIT signal in burst mode:
● Flash memory asserts the NWAIT signal one data cycle before the wait state (default
after reset)
● Flash memory asserts the NWAIT signal during the wait state
These two NOR Flash wait state configurations are supported by the FSMC, individually for
each chip select, thanks to the WAITCFG bit in the FSMC_BCRx registers (x = 0..3).
HCLK
CLK
A[25:16] addr[25:16]
NEx
NOE
High
NWE
NADV
NWAIT
(WAITCFG = 0)
NWAIT
(WAITCFG = 1)
1 clock 1 clock
cycle cycle
Data strobes Data strobes
ai14730
1. Byte lane outputs BL are not shown; for NOR access, they are held high, and, for PSRAM (CRAM) access, they are held
low.
31-20 0x0000
19 CBURSTRW No effect on synchronous read
18-15 0x0
14 EXTMOD 0x0
When high, the first data after latency period is taken as always
13 WAITEN
valid, regardless of the wait from memory value
12 WREN no effect on synchronous read
HCLK
CLK
A[25:16] addr[25:16]
NEx
Hi-Z
NOE
NWE
NADV
NWAIT
(WAITCFG = 0)
DATALAT CLK cycles inserted wait state
1 CLK 1 CLK
cycle cycle ai14731c
1. Memory must issue NWAIT signal one cycle in advance, accordingly WAITCFG must be programmed to 0.
2. Byte Lane (NBL) outputs are not shown, they are held low while NEx is active.
31-20 0x0000
19 CBURSTRW 0x1
18-15 0x0
14 EXTMOD 0x0
When high, the first data after latency period is taken as always
13 WAITEN
valid, regardless of the wait from memory value
12 WREN no effect on synchronous read
11 WAITCFG 0x0
10 WRAPMOD to be set according to memory
9 WAITPOL to be set according to memory
8 BURSTEN no effect on synchronous write
7 FWPRLVL Set to protect memory from accidental writes
6 FACCEN Set according to memory support
5-4 MWID As needed
3-2 MTYP 0x1
1 MUXEN As needed
0 MBKEN 0x1
31-30 - 0x0
27-24 DATLAT Data latency
0 to get CLK = HCLK (not supported)
23-20 CLKDIV
1 to get CLK = 2 × HCLK
19-16 BUSTURN No effect
15-8 DATAST No effect
7-4 ADDHLD No effect
3-0 ADDSET No effect
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CBURSTRW
WRAPMOD
BURSTEN
WAITCFG
WAITPOL
EXTMOD
FACCEN
WAITEN
MUXEN
MBKEN
WREN
MWID
MTYP
Reserved
Reserved Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
BUSTURN
ACCMOD
ADDHLD
ADDSET
DATAST
CLKDIV
DATLAT
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: PSRAMs (CRAMs) have a variable latency due to internal refresh. Therefore these
memories issue the NWAIT signal during the whole latency phase to prolong the latency as
needed.
With PSRAMs (CRAMs) the filed DATLAT must be set to 0, so that the FSMC exits its
latency phase soon and starts sampling NWAIT from memory, then starts to read or write
when the memory is ready.
This method can be used also with the latest generation of synchronous Flash memories
that issue the NWAIT signal, unlike older Flash memories (check the datasheet of the
specific Flash memory being used).
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ACCM
DATLAT CLKDIV DATAST ADDHLD ADDSET
Res. OD Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
There is no theoretical capacity limitation as the FSMC can manage as many address
cycles as needed.
There is no theoretical capacity limitation as the FSMC can manage as many address
cycles as needed.
Asynchronous R 8 8 Y
Asynchronous W 8 8 Y
Asynchronous R 16 8 Y Split into 2 FSMC accesses
NAND 8-bit
Asynchronous W 16 8 Y Split into 2 FSMC accesses
Asynchronous R 32 8 Y Split into 4 FSMC accesses
Asynchronous W 32 8 Y Split into 4 FSMC accesses
Asynchronous R 8 16 Y
Asynchronous W 8 16 N
Asynchronous R 16 16 Y
NAND 16-bit
Asynchronous W 16 16 Y
Asynchronous R 32 16 Y Split into 2 FSMC accesses
Asynchronous W 32 16 Y Split into 2 FSMC accesses
Figure 175. NAND/PC Card controller timing for common memory access
HCLK
A[25:0]
NCEx(2)
NREG, High
NIOW,
NIOR
MEMxSET + 1 MEMxWAIT + 1 MEMxHOLD + 1
NWE,
NOE(1)
MEMxHIZ + 1
write_data
read_data Valid
ai14732c
1. NOE remains high (inactive) during write access. NWE remains high (inactive) during read access.
2. NCEx goes low as soon as NAND access is requested and remains low until a different memory bank is accessed.
the start address for read operations. Using the attribute memory space makes it
possible to use a different timing configuration of the FSMC, which can be used to
implement the prewait functionality needed by some NAND Flash memories (see
details in Section 19.6.5: NAND Flash pre-wait functionality on page 446).
4. The controller waits for the NAND Flash to be ready (R/NB signal high) to become
active, before starting a new access (to same or another memory bank). While waiting,
the controller maintains the NCE signal active (low).
5. The CPU can then perform byte read operations in the common memory space to read
the NAND Flash page (data field + Spare field) byte by byte.
6. The next NAND Flash page can be read without any CPU command or address write
operation, in three different ways:
– by simply performing the operation described in step 5
– a new random address can be accessed by restarting the operation at step 3
– a new command can be sent to the NAND Flash device by restarting at step 2
NCE
CLE
ALE
NWE
High
NOE
tR
I/O[7:0] 0x00 A7-A0 A16-A9 A24-A17 A25
tWB
R/NB
(1) (2) (3) (4) (5)
ai14733
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PWAITEN
ECCEN
PBKEN
PTYP
Reserved
ECCPS TAR TCLR PWID
Reserved Res.
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FEMPT
Reserved
IREN
IFEN
ILEN
IRS
IFS
ILS
r rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MEMHIZx MEMHOLDx MEMWAITx MEMSETx
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ATTHIZx ATTHOLDx ATTWAITx ATTSETx
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
IOHIZx IOHOLDx IOWAITx IOSETx
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ECCx
r
9
8
7
6
5
4
3
2
1
0
CBURSTRW
WRAPMOD
BURSTEN
WAITCFG
WAITPOL
Reserved
EXTMOD
FACCEN
WAITEN
MUXEN
MBKEN
WREN
MWID
MTYP
0xA000 FSMC_BCR1 Reserved Reserved
0000
Reset value
BURSTEN
WAITCFG
WAITPOL
Reserved
EXTMOD
FACCEN
WAITEN
MUXEN
MBKEN
WREN
MWID
MTYP
0xA000
FSMC_BCR2 Reserved Reserved
0008
BURSTEN
WAITCFG
WAITPOL
EXTMOD
Reserved
FACCEN
WAITEN
MUXEN
MBKEN
WREN
MTYP
MWID
0xA000
FSMC_BCR3 Reserved Reserved
0010
BURSTEN
WAITCFG
WAITPOL
Reserved
EXTMOD
FACCEN
WAITEN
MUXEN
MBKEN
WREN
MTYP
MWID
0xA000
FSMC_BCR4 Reserved Reserved
0018
0xA000 ACCM
FSMC_BTR1 Res. DATLAT CLKDIV BUSTURN DATAST ADDHLD ADDSET
0004 OD
0xA000 ACCM
FSMC_BTR2 Res. DATLAT CLKDIV BUSTURN DATAST ADDHLD ADDSET
000C OD
0xA000 ACCM
FSMC_BTR3 Res. DATLAT CLKDIV BUSTURN DATAST ADDHLD ADDSET
0014 OD
0xA000 ACCM
FSMC_BTR4 Res. DATLAT CLKDIV BUSTURN DATAST ADDHLD ADDSET
001C OD
0xA000 ACCM
FSMC_BWTR1 Res. DATLAT CLKDIV Reserved DATAST ADDHLD ADDSET
0104 OD
0xA000 ACCM
FSMC_BWTR2 Res. DATLAT CLKDIV Reserved DATAST ADDHLD ADDSET
010C OD
0xA000 ACCM
FSMC_BWTR3 Res. DATLAT CLKDIV Reserved DATAST ADDHLD ADDSET
0114 OD
0xA000 ACCM
FSMC_BWTR4 Res. DATLAT CLKDIV Reserved DATAST ADDHLD ADDSET
011C OD
PBKEN
PTYP
0xA000
FSMC_PCR2 Reserved ECCPS TAR TCLR Res. PWID
0060
ECCEN
PBKEN
PTYP
0xA000
FSMC_PCR3 Reserved ECCPS TAR TCLR Res. PWID
0080
FEMPT FEMPT FEMPT ECCEN
PBKEN
PTYP
0xA000
FSMC_PCR4 Reserved ECCPS TAR TCLR Res. PWID
00A0
IREN
IFEN
0xA000
ILEN
IRS
IFS
ILS
FSMC_SR2 Reserved
0064
IREN
IFEN
0xA000
ILEN
IRS
IFS
ILS
FSMC_SR3 Reserved
0084
IREN
IFEN
0xA000
ILEN
IRS
IFS
ILS
FSMC_SR4 Reserved
00A4
0xA000
FSMC_PMEM2 MEMHIZx MEMHOLDx MEMWAITx MEMSETx
0068
0xA000
FSMC_PMEM3 MEMHIZx MEMHOLDx MEMWAITx MEMSETx
0088
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
0xA000
FSMC_PMEM4 MEMHIZx MEMHOLDx MEMWAITx MEMSETx
00A8
0xA000
FSMC_PATT2 ATTHIZx ATTHOLDx ATTWAITx ATTSETx
006C
0xA000
FSMC_PATT3 ATTHIZx ATTHOLDx ATTWAITx ATTSETx
008C
0xA000
FSMC_PATT4 ATTHIZx ATTHOLDx ATTWAITx ATTSETx
00AC
0xA000
FSMC_PIO4 IOHIZx IOHOLDx IOWAITx IOSETx
00B0
0xA000
FSMC_ECCR2 ECCx
0054
0xA000
FSMC_ECCR3 ECCx
0074
SDIO_D
ai14734
SDIO_D Data block crc Data block crc Data block crc
ai14735
SDIO_D Busy Data block crc Busy Data block crc Busy
ai14737
Note: The SDIO will not send any data as long as the Busy signal is asserted (SDIO_D0 pulled
low).
From host to
card(s) From card to host Stop command
stops data transfer
Data from card to host
ai14738
From host to
card(s) From card to host Stop command
stops data transfer
Data from host to card
ai14739
SDIO SDIO_CK
Interrupts and
DMA request SDIO_CMD
HCLK/2 SDIOCLK
ai14740
By default SDIO_D0 is used for data transfer. After initialization, the host can change the
databus width.
If a MultiMediaCard is connected to the bus, SDIO_D0, SDIO_D[3:0] or SDIO_D[7:0] can be
used for data transfer. MMC V3.31 or previous, supports only 1 bit of data so only SDIO_D0
can be used.
If an SD or SD I/O card is connected to the bus, data transfer can be configured by the host
to use SDIO_D0 or SDIO_D[3:0]. All data lines are operating in push-pull mode.
SDIO_CMD has two operational modes:
● Open-drain for initialization (only for MMCV3.31 or previous)
● Push-pull for command transfer (SD/SD I/O card MMC4.2 use push-pull drivers also for
initialization)
SDIO_CK is the clock to the card: one bit is transferred on both command and data lines
with each clock cycle. The clock frequency can vary between 0 MHz and 20 MHz (for a
MultiMediaCard V3.31), between 0 and 48 MHz for a MultiMediaCard V4.0/4.2, or between
0 and 25 MHz (for an SD/SD I/O card).
The SDIO uses two clock signals:
● SDIO adapter clock (SDIOCLK = HCLK)
● AHB bus clock (HCLK/2)
The signals shown in Table 120 are used on the MultiMediaCard/SD/SD I/O card bus.
SDIO adapter
Command
Card bus
SDIO_CMD
path
Adapter
registers
To AHB
interface Data path
SDIO_D[7:0]
FIFO
HCLK/2 SDIOCLK
ai14740
The SDIO adapter is a multimedia/secure digital memory card bus master that provides an
interface to a multimedia card stack or to a secure digital memory card. It consists of five
subunits:
● Adapter register block
● Control unit
● Command path
● Data path
● Data FIFO
Note: The adapter registers and FIFO use the AHB bus clock domain (HCLK/2). The control unit,
command path and data path use the SDIO adapter clock domain (SDIOCLK).
Control unit
The control unit contains the power management functions and the clock divider for the
memory card clock.
There are three power phases:
● power-off
● power-up
● power-on
Control unit
Power management
ai14804
The control unit is illustrated in Figure 184. It consists of a power management subunit and
a clock management subunit.
The power management subunit disables the card bus output signals during the power-off
and power-up phases.
The clock management subunit generates and controls the SDIO_CK signal. The SDIO_CK
output can use either the clock divide or the clock bypass mode. The clock output is inactive:
● after reset
● during the power-off or power-up phases
● if the power saving mode is enabled and the card bus is in the Idle state (eight clock
periods after both the command and data path subunits enter the Idle phase)
Command path
The command path unit sends commands to and receives responses from the cards.
Adapter registers
SDIO_CMDin
CMD
Argument
CRC SDIO_CMDout
Shift
CMD register
ai14805
CE-ATA Command
On reset Completion signal
received or Wait_CPL
CPSM disabled or
Command CRC failed
Pend
Enabled and
CPSM Disabled or
command start Receive
CPSM disabled or command timeout
no response
Last Data
Response
started
Send
When the Wait state is entered, the command timer starts running. If the timeout is reached
before the CPSM moves to the Receive state, the timeout flag is set and the Idle state is
entered.
Note: The command timeout has a fixed value of 64 SDIO_CK clock periods.
If the interrupt bit is set in the command register, the timer is disabled and the CPSM waits
for an interrupt request from one of the cards. If a pending bit is set in the command register,
the CPSM enters the Pend state, and waits for a CmdPend signal from the data path
subunit. When CmdPend is detected, the CPSM moves to the Send state. This enables the
data counter to trigger the stop command transmission.
Note: The CPSM remains in the Idle state for at least eight SDIO_CK periods to meet the NCC and
NRC timing constraints. NCC is the minimum delay between two host commands, and NRC is
the minimum delay between the host command and the card response.
SDIO_CMD Hi-Z Controller drives Hi-Z Card drives Hi-Z Controller drives
ai14707
● Command format
– Command: a command is a token that starts an operation. Command are sent
from the host either to a single card (addressed command) or to all connected
cards (broadcast command are available for MMC V3.31 or previous). Commands
are transferred serially on the CMD line. All commands have a fixed length of 48
bits. The general format for a command token for MultiMediaCards, SD-Memory
cards and SDIO-Cards is shown in Table 121. CE-ATA commands are an
extension of MMC commands V4.2, and so have the same format.
The command path operates in a half-duplex mode, so that commands and
responses can either be sent or received. If the CPSM is not in the Send state, the
SDIO_CMD output is in the Hi-Z state, as shown in Figure 187 on page 464. Data
on SDIO_CMD are synchronous with the rising edge of SDIO_CK. Table shows
the command format.
47 1 0 Start bit
46 1 1 Transmission bit
[45:40] 6 - Command index
[39:8] 32 - Argument
[7:1] 7 - CRC7
0 1 1 End bit
47 1 0 Start bit
46 1 0 Transmission bit
[45:40] 6 - Command index
[39:8] 32 - Argument
[7:1] 7 - CRC7(or 1111111)
0 1 1 End bit
The command register contains the command index (six bits sent to a card) and the
command type. These determine whether the command requires a response, and whether
the response is 48 or 136 bits long (see Section 20.9.4 on page 499). The command path
implements the status flags shown in Table 124:
The CRC generator calculates the CRC checksum for all bits before the CRC code. This
includes the start bit, transmitter bit, command index, and command argument (or card
status). The CRC checksum is calculated for the first 120 bits of CID or CSD for the long
response format. Note that the start bit, transmitter bit and the six reserved bits are not used
in the CRC calculation.
The CRC checksum is a 7-bit value:
CRC[6:0] = Remainder [(M(x) * x7) / G(x)]
G(x) = x7 + x3 + 1
M(x) = (start bit) * x39 + ... + (last bit before CRC) * x0, or
M(x) = (start bit) * x119 + ... + (last bit before CRC) * x0
Data path
The data path subunit transfers data to and from cards. Figure 188 shows a block diagram
of the data path.
Data FIFO
SDIO_Din[7:0]
Transmit
CRC SDIO_Dout[7:0]
Shift
register
Receive
ai14808
The card databus width can be programmed using the clock control register. If the 4-bit wide
bus mode is enabled, data is transferred at four bits per clock cycle over all four data signals
(SDIO_D[3:0]). If the 8-bit wide bus mode is enabled, data is transferred at eight bits per
clock cycle over all eight data signals (SDIO_D[7:0]). If the wide bus mode is not enabled,
only one bit per clock cycle is transferred over SDIO_D0.
Depending on the transfer direction (send or receive), the data path state machine (DPSM)
moves to the Wait_S or Wait_R state when it is enabled:
● Send: the DPSM moves to the Wait_S state. If there is data in the transmit FIFO, the
DPSM moves to the Send state, and the data path subunit starts sending data to a
card.
● Receive: the DPSM moves to the Wait_R state and waits for a start bit. When it
receives a start bit, the DPSM moves to the Receive state, and the data path subunit
starts receiving data from a card.
Data path state machine (DPSM)
The DPSM operates at SDIO_CK frequency. Data on the card bus signals is synchronous to
the rising edge of SDIO_CK. The DPSM has six states, as shown in Figure 189: Data path
state machine (DPSM).
ReadWait Stop
Disabled or
end of data
Disabled or
Busy Rx FIFO empty or timeout or
start bit error
Not busy
Enable and send Data received and
Wait_R Read Wait Started and
SD I/O mode enabled
End of packet
Send
Receive
ai14809b
● Idle: the data path is inactive, and the SDIO_D[7:0] outputs are in Hi-Z. When the data
control register is written and the enable bit is set, the DPSM loads the data counter
with a new value and, depending on the data direction bit, moves to either the Wait_S
or the Wait_R state.
● Wait_R: if the data counter equals zero, the DPSM moves to the Idle state when the
receive FIFO is empty. If the data counter is not zero, the DPSM waits for a start bit on
SDIO_D. The DPSM moves to the Receive state if it receives a start bit before a
timeout, and loads the data block counter. If it reaches a timeout before it detects a
start bit, or a start bit error occurs, it moves to the Idle state and sets the timeout status
flag.
● Receive: serial data received from a card is packed in bytes and written to the data
FIFO. Depending on the transfer mode bit in the data control register, the data transfer
mode can be either block or stream:
– In block mode, when the data block counter reaches zero, the DPSM waits until it
receives the CRC code. If the received code matches the internally generated
CRC code, the DPSM moves to the Wait_R state. If not, the CRC fail status flag is
set and the DPSM moves to the Idle state.
– In stream mode, the DPSM receives data while the data counter is not zero. When
the counter is zero, the remaining data in the shift register is written to the data
FIFO, and the DPSM moves to the Wait_R state.
If a FIFO overrun error occurs, the DPSM sets the FIFO error flag and moves to the Idle
state:
● Wait_S: the DPSM moves to the Idle state if the data counter is zero. If not, it waits until
the data FIFO empty flag is deasserted, and moves to the Send state.
Note: The DPSM remains in the Wait_S state for at least two clock periods to meet the NWR timing
requirements, where NWR is the number of clock cycles between the reception of the card
response and the start of the data transfer from the host.
● Send: the DPSM starts sending data to a card. Depending on the transfer mode bit in
the data control register, the data transfer mode can be either block or stream:
– In block mode, when the data block counter reaches zero, the DPSM sends an
internally generated CRC code and end bit, and moves to the Busy state.
– In stream mode, the DPSM sends data to a card while the enable bit is high and
the data counter is not zero. It then moves to the Idle state.
If a FIFO underrun error occurs, the DPSM sets the FIFO error flag and moves to the
Idle state.
● Busy: the DPSM waits for the CRC status flag:
– If it does not receive a positive CRC status, it moves to the Idle state and sets the
CRC fail status flag.
– If it receives a positive CRC status, it moves to the Wait_S state if SDIO_D0 is not
low (the card is not busy).
If a timeout occurs while the DPSM is in the Busy state, it sets the data timeout flag and
moves to the Idle state.
The data timer is enabled when the DPSM is in the Wait_R or Busy state, and
generates the data timeout error:
– When transmitting data, the timeout occurs if the DPSM stays in the Busy state for
longer than the programmed timeout period
– When receiving data, the timeout occurs if the end of the data is not true, and if the
DPSM stays in the Wait_R state for longer than the programmed timeout period.
● Data: data can be transferred from the card to the host or vice versa. Data is
transferred via the data lines. They are stored in a FIFO of 32 words, each word is 32
bits wide.
Data FIFO
The data FIFO (first-in-first-out) subunit is a data buffer with a transmit and receive unit.
The FIFO contains a 32-bit wide, 32-word deep data buffer, and transmit and receive logic.
Because the data FIFO operates in the AHB clock domain (HCLK/2), all signals from the
subunits in the SDIO clock domain (SDIOCLK) are resynchronized.
Depending on the TXACT and RXACT flags, the FIFO can be disabled, transmit enabled, or
receive enabled. TXACT and RXACT are driven by the data path subunit and are mutually
exclusive:
– The transmit FIFO refers to the transmit logic and data buffer when TXACT is
asserted
– The receive FIFO refers to the receive logic and data buffer when RXACT is
asserted
● Transmit FIFO:
Data can be written to the transmit FIFO through the AHB interface when the SDIO is
enabled for transmission.
The transmit FIFO is accessible via 32 sequential addresses. The transmit FIFO
contains a data output register that holds the data word pointed to by the read pointer.
When the data path subunit has loaded its shift register, it increments the read pointer
and drives new data out.
If the transmit FIFO is disabled, all status flags are deasserted. The data path subunit
asserts TXACT when it transmits data.
TXFIFOF Set to high when all 32 transmit FIFO words contain valid data.
TXFIFOE Set to high when the transmit FIFO does not contain valid data.
Set to high when 8 or more transmit FIFO words are empty. This flag can be used
TXFIFOHE
as a DMA request.
Set to high when the transmit FIFO contains valid data. This flag is the inverse of
TXDAVL
the TXFIFOE flag.
Set to high when an underrun error occurs. This flag is cleared by writing to the
TXUNDERR
SDIO Clear register.
● Receive FIFO
When the data path subunit receives a word of data, it drives the data on the write
databus. The write pointer is incremented after the write operation completes. On the
read side, the contents of the FIFO word pointed to by the current value of the read
pointer is driven onto the read databus. If the receive FIFO is disabled, all status flags
are deasserted, and the read and write pointers are reset. The data path subunit
asserts RXACT when it receives data. Table 127 lists the receive FIFO status flags.
The receive FIFO is accessible via 32 sequential addresses.
RXFIFOF Set to high when all 32 receive FIFO words contain valid data
RXFIFOE Set to high when the receive FIFO does not contain valid data.
Set to high when 8 or more receive FIFO words contain valid data. This flag can be
RXFIFOHF
used as a DMA request.
Set to high when the receive FIFO is not empty. This flag is the inverse of the
RXDAVL
RXFIFOE flag.
Set to high when an overrun error occurs. This flag is cleared by writing to the SDIO
RXOVERR
Clear register.
SDIO interrupts
The interrupt logic generates an interrupt request signal that is asserted when at least one
of the selected status flags is high. A mask register is provided to allow selection of the
conditions that will generate an interrupt. A status flag generates the interrupt request if a
corresponding mask flag is set.
SDIO/DMA interface: procedure for data transfers between the SDIO and
memory
In the example shown, the transfer is from the SDIO host controller to an MMC (512 bytes
using CMD24 (WRITE_BLOCK). The SDIO FIFO is filled by data stored in a memory using
the DMA controller.
1. Do the card identification process
2. Increase the SDIO_CK frequency
3. Select the card by sending CMD7
4. Configure the DMA2 as follows:
a) Enable DMA2 controller and clear any pending interrupts
b) Program the DMA2_Channel4 source address register with the memory location’s
base address and DMA2_Channel4 destination address register with the
SDIO_FIFO register address
c) Program DMA2_Channel4 control register (memory increment, not peripheral
increment, peripheral and source width is word size)
d) Enable DMA2_Channel4
By using these commands without including the voltage range as the operand, the SDIO
card host can query each card and determine the common voltage range before placing out-
of-range cards in the inactive state. This query is used when the SDIO card host is able to
select a common voltage range or when the user requires notification that cards are not
usable.
The host can abort reading at any time, within a multiple block operation, regardless of its
type. Transaction abort is done by sending the stop transmission command.
If the card detects an error (for example, out of range, address misalignment or internal
error) during a multiple block read operation (both types) it stops the data transmission and
remains in the data state. The host must than abort the operation by sending the stop
transmission command. The read error is reported in the response to the stop transmission
command.
If the host sends a stop transmission command after the card transmits the last block of a
multiple block operation with a predefined number of blocks, it is responded to as an illegal
command, since the card is no longer in the data state. If the host uses partial blocks whose
accumulated length is not block-aligned and block misalignment is not allowed, the card
detects a block misalignment error condition at the beginning of the first misaligned block
(ADDRESS_ERROR error bit is set in the status register).
20.4.7 Stream access, stream write and stream read (MultiMediaCard only)
In stream mode, data is transferred in bytes and no CRC is appended at the end of each
block.
8 2 writebllen – NSAC )
Maximumspeed = MIN (TRANSPEED,------------------------------------------------------------------------
TAAC R2WFACTOR
8 2 readbllen – NSAC )
Maximumspeed = MIN (TRANSPEED,-----------------------------------------------------------------------
TAAC R2WFACTOR
The card indicates that an erase is in progress by holding SDIO_D low. The actual erase
time may be quite long, and the host may issue CMD7 to deselect the card.
Password protect
The password protection feature enables the SDIO card host module to lock and unlock a
card with a password. The password is stored in the 128-bit PWD register and its size is set
in the 8-bit PWD_LEN register. These registers are non-volatile so that a power cycle does
not erase them. Locked cards respond to and execute certain commands. This means that
the SDIO card host module is allowed to reset, initialize, select, and query for status,
however it is not allowed to access data on the card. When the password is set (as indicated
by a nonzero value of PWD_LEN), the card is locked automatically after power-up. As with
the CSD and CID register write commands, the lock/unlock commands are available in the
transfer state only. In this state, the command does not include an address argument and
the card must be selected before using it. The card lock/unlock commands have the
structure and bus transaction types of a regular single-block write command. The
transferred data block includes all of the required information for the command (the
password setting mode, the PWD itself, and card lock/unlock). The command data block
size is defined by the SDIO card host module before it sends the card lock/unlock command,
and has the structure shown in Table 141.
The bit settings are as follows:
● ERASE: setting it forces an erase operation. All other bits must be zero, and only the
command byte is sent
● LOCK_UNLOCK: setting it locks the card. LOCK_UNLOCK can be set simultaneously
with SET_PWD, however not with CLR_PWD
● CLR_PWD: setting it clears the password data
● SET_PWD: setting it saves the password data to memory
● PWD_LEN: it defines the length of the password in bytes
● PWD: the password (new or currently used, depending on the command)
The following sections list the command sequences to set/reset a password, lock/unlock the
card, and force an erase.
Locking a card
1. Select a card (SELECT/DESELECT_CARD, CMD7), if none is already selected.
2. Define the block length (SET_BLOCKLEN, CMD16) to send, given by the 8-bit card
lock/unlock mode (byte 0 in Table 141), the 8-bit PWD_LEN, and the number of bytes of
the current password.
3. Send LOCK/UNLOCK (CMD42) with the appropriate data block size on the data line
including the 16-bit CRC. The data block indicates the mode (LOCK_UNLOCK = 1), the
length (PWD_LEN), and the password (PWD) itself.
4. When the password is matched, the card is locked and the CARD_IS_LOCKED status
bit is set in the card status register. When the password sent does not correspond (in
size and/or content) to the expected password, the LOCK_UNLOCK_FAILED error bit
is set in the card status register, and the lock fails.
It is possible to set the password and to lock the card in the same sequence. In this case,
the SDIO card host module performs all the required steps for setting the password (see
Setting the password on page 477), however it is necessary to set the LOCK_UNLOCK bit
in Step 3 when the new password command is sent.
When the password is previously set (PWD_LEN is not 0), the card is locked automatically
after power on reset. An attempt to lock a locked card or to lock a card that does not have a
password fails and the LOCK_UNLOCK_FAILED error bit is set in the card status register.
The unlocking function is only valid for the current power session. When the PWD field is not
clear, the card is locked automatically on the next power-up.
An attempt to unlock an unlocked card fails and the LOCK_UNLOCK_FAILED error bit is set
in the card status register.
Forcing erase
If the user has forgotten the password (PWD content), it is possible to access the card after
clearing all the data on the card. This forced erase operation erases all card data and all
password data.
1. Select a card (SELECT/DESELECT_CARD, CMD7), if none is already selected.
2. Set the block length (SET_BLOCKLEN, CMD16) to 1 byte. Only the 8-bit card
lock/unlock byte (byte 0 in Table 141) is sent.
3. Send LOCK/UNLOCK (CMD42) with the appropriate data byte on the data line including
the 16-bit CRC. The data block indicates the mode (ERASE = 1). All other bits must be
zero.
4. When the ERASE bit is the only bit set in the data field, all card contents are erased,
including the PWD and PWD_LEN fields, and the card is no longer locked. When any
other bits are set, the LOCK_UNLOCK_FAILED error bit is set in the card status
register and the card retains all of its data, and remains locked.
An attempt to use a force erase on an unlocked card fails and the LOCK_UNLOCK_FAILED
error bit is set in the card status register.
SIZE_OF_PROTECTED_AREA
Setting this field differs between standard- and high-capacity cards. In the case of a
standard-capacity card, the capacity of protected area is calculated as follows:
Protected area = SIZE_OF_PROTECTED_AREA_* MULT * BLOCK_LEN.
SIZE_OF_PROTECTED_AREA is specified by the unit in MULT*BLOCK_LEN.
In the case of a high-capacity card, the capacity of protected area is specified in this field:
Protected area = SIZE_OF_PROTECTED_AREA
SIZE_OF_PROTECTED_AREA is specified by the unit in bytes.
SPEED_CLASS
This 8-bit field indicates the speed class and the value can be calculated by PW/2 (where
PW is the write performance).
00h Class 0
01h Class 2
02h Class 4
03h Class 6
04h – FFh Reserved
PERFORMANCE_MOVE
This 8-bit field indicates Pm (performance move) and the value can be set by 1 [MB/sec]
steps. If the card does not move used RUs (recording units), Pm should be considered as
infinity. Setting the field to FFh means infinity.
AU_SIZE
This 4-bit field indicates the AU size and the value can be selected in the power of 2 base
from 16 KB.
09h 4 MB
Ah – Fh Reserved
The maximum AU size, which depends on the card capacity, is defined in Table 133. The
card can be set to any AU size between RU size and maximum AU size.
ERASE_SIZE
This 16-bit field indicates NERASE. When NERASE numbers of AUs are erased, the timeout
value is specified by ERASE_TIMEOUT (Refer to ERASE_TIMEOUT). The host should
determine the proper number of AUs to be erased in one operation so that the host can
show the progress of the erase operation. If this field is set to 0, the erase timeout
calculation is not supported.
ERASE_TIMEOUT
This 6-bit field indicates TERASE and the value indicates the erase timeout from offset when
multiple AUs are being erased as specified by ERASE_SIZE. The range of
ERASE_TIMEOUT can be defined as up to 63 seconds and the card manufacturer can
choose any combination of ERASE_SIZE and ERASE_TIMEOUT depending on the
implementation. Determining ERASE_TIMEOUT determines the ERASE_SIZE.
--------- ---------
63 63 [sec]
ERASE_OFFSET
This 2-bit field indicates TOFFSET and one of four values can be selected. This field is
meaningless if the ERASE_SIZE and ERASE_TIMEOUT fields are set to 0.
0h 0 [sec]
1h 1 [sec]
2h 2 [sec]
3h 3 [sec]
suspend/resume operation on the MMC/SD bus, the MMC/SD module performs the
following steps:
1. Determines the function currently using the SDIO_D [3:0] line(s)
2. Requests the lower-priority or slower transaction to suspend
3. Waits for the transaction suspension to complete
4. Begins the higher-priority transaction
5. Waits for the completion of the higher priority transaction
6. Restores the suspended transaction
SD I/O ReadWait
The optional ReadWait (RW) operation is defined only for the SD 1-bit and 4-bit modes. The
ReadWait operation allows the MMC/SD module to signal a card that it is reading multiple
registers (IO_RW_EXTENDED, CMD53) to temporarily stall the data transfer while allowing
the MMC/SD module to send commands to any function within the SD I/O device. To
determine when a card supports the ReadWait protocol, the MMC/SD module must test
capability bits in the internal card registers. The timing for ReadWait is based on the
interrupt period.
The bus transaction for a GEN_CMD is the same as the single-block read or write
commands (WRITE_BLOCK, CMD24 or READ_SINGLE_BLOCK,CMD17). In this case, the
argument denotes the direction of the data transfer rather than the address, and the data
block has vendor-specific format and meaning.
The card must be selected (in transfer state) before sending GEN_CMD (CMD56). The data
block size is defined by SET_BLOCKLEN (CMD16). The response to GEN_CMD (CMD56)
is in R1b format.
Command types
Both application-specific and general commands are divided into the four following types:
● broadcast command (BC): sent to all cards; no responses returned.
● broadcast command with response (BCR): sent to all cards; responses received
from all cards simultaneously.
● addressed (point-to-point) command (AC): sent to the card that is selected; does
not include a data transfer on the SDIO_D line(s).
● addressed (point-to-point) data transfer command (ADTC): sent to the card that is
selected; includes a data transfer on the SDIO_D line(s).
Command formats
See Table 121 on page 464 for command formats.
CMD32
Reserved. These command indexes cannot be used in order to maintain backward compatibility with older
...
versions of the MultiMediaCard.
CMD34
Sets the address of the first erase
CMD35 ac [31:0] data address R1 ERASE_GROUP_START group within a range to be selected
for erase.
Sets the address of the last erase
CMD36 ac [31:0] data address R1 ERASE_GROUP_END group within a continuous range to be
selected for erase.
Reserved. This command index cannot be used in order to maintain backward compatibility with older
CMD37
versions of the MultiMediaCards
Erases all previously selected write
CMD38 ac [31:0] stuff bits R1 ERASE
blocks.
CMD40 bcr [31:0] stuff bits R5 GO_IRQ_STATE Places the system in the interrupt mode.
CMD41 Reserved
47 1 0 Start bit
46 1 0 Transmission bit
[45:40] 6 X Command index
[39:8] 32 X Card status
[7:1] 7 X CRC7
0 1 1 End bit
20.5.2 R1b
It is identical to R1 with an optional busy signal transmitted on the data line. The card may
become busy after receiving these commands based on its state prior to the command
reception.
47 1 0 Start bit
46 1 0 Transmission bit
[45:40] 6 ‘111111’ Reserved
[39:8] 32 X OCR register
[7:1] 7 ‘1111111’ Reserved
0 1 1 End bit
47 1 0 Start bit
46 1 0 Transmission bit
[45:40] 6 ‘111111’ Reserved
[31:16] 16 X RCA
[39:8] Argument field [15:8] 8 X register address
[7:0] 8 X read register contents
[7:1] 7 ‘1111111’ CRC7
0 1 1 End bit
20.5.6 R4b
For SD I/O only: an SDIO card receiving the CMD5 will respond with a unique SDIO
response R4. The format is:
47 1 0 Start bit
46 1 0 Transmission bit
[45:40] 6 x Reserved
39 16 X Card is ready
[38:36] 3 X Number of I/O functions
[39:8] Argument field 35 1 X Present memory
[34:32] 3 X Stuff bits
[31:8] 24 X I/O ORC
[7:1] 7 X Reserved
0 1 1 End bit
Once an SD I/O card has received a CMD5, the I/O portion of that card is enabled to
respond normally to all further commands. This I/O enable of the function within the I/O card
will remain set until a reset, power cycle or CMD52 with write to I/O reset is received by the
card. Note that an SD memory-only card may respond to a CMD5. The proper response for
a memory-only card would be Present memory = 1 and Number of I/O functions = 0. A
memory-only card built to meet the SD Memory Card specification version 1.0 would detect
the CMD5 as an illegal command and not respond. The I/O aware host will send CMD5. If
the card responds with response R4, the host determines the card’s configuration based on
the data contained within the R4 response.
47 1 0 Start bit
46 1 0 Transmission bit
[45:40] 6 ‘111111’ CMD40
RCA [31:16] of winning
[31:16] 16 X
card or of the host
[39:8] Argument field
Not defined. May be used
[15:0] 16 X
for IRQ data
[7:1] 7 X CRC7
0 1 1 End bit
20.5.8 R6
Only for SD I/O. The normal response to CMD3 by a memory device. It is shown in
Table 149.
47 1 0 Start bit
46 1 0 Transmission bit
[45:40] 6 ‘101000’ CMD40
The card [23:8] status bits are changed when CMD3 is sent to an I/O-only card. In this case,
the 16 bits of response are the SD I/O-only values:
● Bit [15] COM_CRC_ERROR
● Bit [14] ILLEGAL_COMMAND
● Bit [13] ERROR
● Bits [12:0] Reserved
As SDIO_CK is stopped, any command can be issued to the card. During a read/wait
interval, the SDIO can detect SDIO interrupts on SDIO_D1.
When ‘0’ is received on the CMD line, the CPSM enters the Idle state. No new command
can be sent for 7 bit cycles. Then, for the last 5 cycles (out of the 7) the CMD line is driven to
‘1’ in push-pull mode.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PWRC
Reserved TRL
rw rw
Note: After a data write, data cannot be written to this register for seven HCLK clock periods.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NEGEDGE
HWFC_EN
PWRSAV
BYPASS
CLKEN
WID
CLKDIV
Reserved BUS
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: 1 While the SD/SDIO card or MultiMediaCard is in identification mode, the SDIO_CK
frequency must be less than 400 kHz.
2 The clock frequency can be changed to the maximum card bus frequency when relative
card addresses are assigned to all cards.
3 After a data write, data cannot be written to this register for seven HCLK clock periods.
SDIO_CK can also be stopped during the read wait interval for SD I/O cards: in this case the
SDIO_CLKCR register does not control SDIO_CK.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CMDARG
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SDIOSuspend
ENCMDcompl
CE-ATACMD
CMDINDEX
WAITPEND
WAITRESP
CPSMEN
WAITINT
nIEN
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: 1 After a data write, data cannot be written to this register for seven HCLK clock periods.
2 MultiMediaCards can send two kinds of response: short responses, 48 bits long, or long
responses,136 bits long. SD card and SD I/O card can send only short responses, the
argument can vary according to the type of response: the software will distinguish the type
of response according to the sent command. CE-ATA devices send only short responses.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RESPCMD
Reserved
r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CARDSTATUSx
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
The Card Status size is 32 or 127 bits, depending on the response type.
The most significant bit of the card status is received first. The SDIO_RESP3 register LSB is
always 0b.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DATATIME
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: A data transfer must be written to the data timer register and the data length register before
being written to the data control register.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DATALENGTH
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: For a block data transfer, the value in the data length register must be a multiple of the block
size (see SDIO_DCTRL). A data transfer must be written to the data timer register and the
data length register before being written to the data control register.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RWSTART
DTMODE
RWSTOP
RWMOD
SDIOEN
DMAEN
DTDIR
DTEN
DBLOCKSIZE
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw
Bit 2 DTMODE: Data transfer mode selection 1: Stream or SDIO multibyte data transfer.
0: Block data transfer.
1: Stream data transfer.
Bit 1 DTDIR: Data transfer direction selection
0: From controller to card.
1: From card to controller.
[0] DTEN: Data transfer enabled bit
Data transfer starts if 1b is written to the DTEN bit. Depending on the direction bit, DTDIR,
the DPSM moves to the Wait_S, Wait_R state or Readwait if RW Start is set immediately at
the beginning of the transfer. It is not necessary to clear the enable bit after the end of a data
transfer but the SDIO_DCTRL must be updated to enable a new data transfer
Note: After a data write, data cannot be written to this register for seven HCLK clock periods.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DATACOUNT
Reserved
r r r r r r r r r r r r r r r r r r r r r r r r r
Note: This register should be read only when the data transfer is complete.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TXUNDERR
DTIMEOUT
CTIMEOUT
CEATAEND
CMDREND
RXFIFOHF
STBITERR
CMDSENT
TXFIFOHE
DCRCFAIL
CCRCFAIL
DBCKEND
RXOVERR
DATAEND
RXFIFOE
Reserved
RXFIFOF
TXFIFOE
CMDACT
TXFIFOF
RXDAVL
TXDAVL
RXACT
SDIOIT
TXACT
Res. r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TXUNDERRC
DTIMEOUTC
CTIMEOUTC
CEATAENDC
CMDRENDC
STBITERRC
CMDSENTC
DCRCFAILC
CCRCFAILC
RXOVERRC
DBCKENDC
DATAENDC
SDIOITC
Reserved Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TXUNDERRIE
DTIMEOUTIE
CTIMEOUTIE
CEATAENDIE
CMDRENDIE
RXFIFOHFIE
STBITERRIE
CMDSENTIE
TXFIFOHEIE
DCRCFAILIE
CCRCFAILIE
DBCKENDIE
RXOVERRIE
DATAENDIE
RXFIFOEIE
RXFIFOFIE
TXFIFOEIE
CMDACTIE
TXFIFOFIE
RXDAVLIE
TXDAVLIE
RXACTIE
SDIOITIE
TXACTIE
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FIFOCOUNT
Reserved
r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FIF0Data
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
9
8
7
6
5
4
3
2
1
0
PWRCTRL
Reserved
0x00 SDIO_POWER
NEGEDGE
HWFC_EN
Reserved
PWRSAV
WIDBUS
BYPASS
CLKDIV
CLKEN
0x04 SDIO_CLKCR
CMDINDEX
WAITPEND
WAITRESP
Reserved
CPSMEN
WAITINT
nIEN
0x0C SDIO_CMD
SDIO_RESPCM
0x10 Reserved RESPCMD
D
0x14 SDIO_RESP1 CARDSTATUS1
0x18 SDIO_RESP2 CARDSTATUS2
0x1C SDIO_RESP3 CARDSTATUS3
0x20 SDIO_RESP4 CARDSTATUS4
0x24 SDIO_DTIMER DATATIME
0x28 SDIO_DLEN Reserved DATALENGTH
DBLOCKSIZE
RWSTART
DTMODE
RWSTOP
Reserved
RWMOD
SDIOEN
DMAEN
DTDIR
DTEN
0x2C SDIO_DCTRL
CMDREND
RXFIFOHF
TXFIFOHE
STBITERR
CMDSENT
DCRCFAIL
CCRCFAIL
RXOVERR
DBCKEND
DATAEND
RXFIFOE
RXFIFOF
Reserved
TXFIFOE
CMDACT
TXFIFOF
RXDAVL
TXDAVL
RXACT
SDIOIT
TXACT
0x34 SDIO_STA
0x3C
Note:
Offset
RM0008
SDIO_ICR
Register
SDIO_FIFO
SDIO_MASK
SDIO_FIFOCNT
31
30
29
Reserved Reserved 28
27
Reserved
26
25
24
CEATAENDIE CEATAENDC 23
SDIOITIE SDIOITC 22
Table 151. SDIO register map (continued)
RXDAVLIE 21
TXDAVLIE 20
RXFIFOEIE 19
TXFIFOEIE 18
RXFIFOFIE 17
TXFIFOFIE Reserved
16
TXFIFOHEIE 14
RXACTIE 13
TXACTIE 12
CMDACTIE 11
FIFOCOUNT
DBCKENDIE DBCKENDC 10
Refer to Table 1 on page 41 for the register boundary addresses.
STBITERRIE STBITERRC 9
DATAENDIE DATAENDC 8
CMDSENTIE CMDSENTC 7
CMDRENDIE CMDRENDC 6
RXOVERRIE RXOVERRC 5
TXUNDERRIE TXUNDERRC 4
DTIMEOUTIE DTIMEOUTC 3
CTIMEOUTIE CTIMEOUTC 2
DCRCFAILIE DCRCFAILC 1
CCRCFAILIE CCRCFAILC
Secure digital input/output interface (SDIO)
511/995
0
Universal serial bus full-speed device interface (USB) RM0008
DP DM
USB
Control
RX-TX Clock
registers & logic
Suspend recovery
timer Control
Endpoint Interrupt
selection registers & logic
S.I.E.
Packet
buffer Endpoint Endpoint
interface registers registers
Packet
Register Interrupt
Arbiter buffer
mapper mapper
memory
APB1 wrapper
APB1 interface
PCLK1 APB1 bus IRQs to NVIC
The USB peripheral provides an USB compliant connection between the host PC and the
function implemented by the microcontroller. Data transfer between the host PC and the
system memory occurs through a dedicated packet buffer memory accessed directly by the
USB peripheral. The size of this dedicated buffer memory must be according to the number
of endpoints used and the maximum packet size. This dedicated memory is sized to 512
bytes and up to 16 mono-directional or 8 bidirectional endpoints can be used.The USB
peripheral interfaces with the USB host, detecting token packets, handling data
transmission/reception, and processing handshake packets as required by the USB
standard. Transaction formatting is performed by the hardware, including CRC generation
and checking.
Each endpoint is associated with a buffer description block indicating where the endpoint
related memory area is located, how large it is or how many bytes must be transmitted.
When a token for a valid function/endpoint pair is recognized by the USB peripheral, the
related data transfer (if required and if the endpoint is configured) takes place. The data
buffered by the USB peripheral is loaded in an internal 16 bit register and memory access to
the dedicated buffer is performed. When all the data has been transferred, if needed, the
proper handshake packet over the USB is generated or expected according to the direction
of the transfer.
At the end of the transaction, an endpoint-specific interrupt is generated, reading status
registers and/or using different interrupt response routines. The microcontroller can
determine:
● Which endpoint has to be served
● Which type of transaction took place, if errors occurred (bit stuffing, format, CRC,
protocol, missing ACK, over/underrun, etc.)
Special support is offered to Isochronous transfers and high throughput bulk transfers,
implementing a double buffer usage, which allows to always have an available buffer for the
USB peripheral while the microcontroller uses the other one.
The unit can be placed in low-power mode (SUSPEND mode), by writing in the control
register, whenever required. At this time, all static power dissipation is avoided, and the USB
clock can be slowed down or stopped. The detection of activity at the USB inputs, while in
low-power mode, wakes the device up asynchronously. A special interrupt source can be
connected directly to a wakeup line to allow the system to immediately restart the normal
clock generation and/or support direct clock start/stop.
● Control Registers: These are the registers containing information about the status of
the whole USB peripheral and used to force some USB events, such as resume and
power-down.
● Interrupt Registers: These contain the Interrupt masks and a record of the events. They
can be used to inquire an interrupt reason, the interrupt status or to clear the status of a
pending interrupt.
Note: * Endpoint 0 is always used for control transfer in single-buffer mode.
The USB peripheral is connected to the APB1 bus through an APB1 interface, containing
the following blocks:
● Packet Memory: This is the local memory that physically contains the Packet Buffers. It
can be used by the Packet Buffer interface, which creates the data structure and can be
accessed directly by the application software. The size of the Packet Memory is 512
bytes, structured as 256 words by 16 bits.
● Arbiter: This block accepts memory requests coming from the APB1 bus and from the
USB interface. It resolves the conflicts by giving priority to APB1 accesses, while
always reserving half of the memory bandwidth to complete all USB transfers. This
time-duplex scheme implements a virtual dual-port SRAM that allows memory access,
while an USB transaction is happening. Multiword APB1 transfers of any length are
also allowed by this scheme.
● Register Mapper: This block collects the various byte-wide and bit-wide registers of the
USB peripheral in a structured 16-bit wide word set addressed by the APB1.
● APB1 Wrapper: This provides an interface to the APB1 for the memory and register. It
also maps the whole USB peripheral in the APB1 address space.
● Interrupt Mapper: This block is used to select how the possible USB events can
generate interrupts and map them to three different lines of the NVIC:
– USB low-priority interrupt (Channel 20): Triggered by all USB events (Correct
transfer, USB reset, etc.). The firmware has to check the interrupt source before
serving the interrupt.
– USB high-priority interrupt (Channel 19): Triggered only by a correct transfer event
for isochronous and double-buffer bulk transfer to reach the highest possible
transfer rate.
– USB wakeup interrupt (Channel 42): Triggered by the wakeup event from the USB
Suspend mode.
clock is fixed by the requirements of the USB standard at 48 MHz, and this can be different
from the clock used for the interface to the APB1 bus. Different clock configurations are
possible where the APB1 clock frequency can be higher or lower than the USB peripheral
one.
Note: Due to USB data rate and packet memory interface requirements, the APB1 clock frequency
must be greater than 8 MHz to avoid data overrun/underrun problems.
Each endpoint is associated with two packet buffers (usually one for transmission and the
other one for reception). Buffers can be placed anywhere inside the packet memory
because their location and size is specified in a buffer description table, which is also
located in the packet memory at the address indicated by the USB_BTABLE register. Each
table entry is associated to an endpoint register and it is composed of four 16-bit words so
that table start address must always be aligned to an 8-byte boundary (the lowest three bits
of USB_BTABLE register are always “000”). Buffer descriptor table entries are described in
the Section 21.5.3: Buffer descriptor table. If an endpoint is unidirectional and it is neither an
Isochronous nor a double-buffered bulk, only one packet buffer is required (the one related
to the supported transfer direction). Other table locations related to unsupported transfer
directions or unused endpoints, are available to the user. isochronous and double-buffered
bulk endpoints have special handling of packet buffers (Refer to Section 21.4.4: Isochronous
transfers and Section 21.4.3: Double-buffered endpoints respectively). The relationship
between buffer description table entries and packet buffer areas is depicted in Figure 191.
Figure 191. Packet buffer areas with examples of buffer description table locations
Buffer for
double-buffered
IN Endpoint 3
Each packet buffer is used either during reception or transmission starting from the bottom.
The USB peripheral will never change the contents of memory locations adjacent to the
allocated memory buffers; if a packet bigger than the allocated buffer length is received
(buffer overrun condition) the data will be copied to the memory only up to the last available
location.
Endpoint initialization
The first step to initialize an endpoint is to write appropriate values to the
ADDRn_TX/ADDRn_RX registers so that the USB peripheral finds the data to be
transmitted already available and the data to be received can be buffered. The EP_TYPE
bits in the USB_EPnR register must be set according to the endpoint type, eventually using
the EP_KIND bit to enable any special required feature. On the transmit side, the endpoint
must be enabled using the STAT_TX bits in the USB_EPnR register and COUNTn_TX must
be initialized. For reception, STAT_RX bits must be set to enable reception and
COUNTn_RX must be written with the allocated buffer size using the BL_SIZE and
NUM_BLOCK fields. Unidirectional endpoints, except Isochronous and double-buffered bulk
endpoints, need to initialize only bits and registers related to the supported direction. Once
the transmission and/or reception are enabled, register USB_EPnR and locations
ADDRn_TX/ADDRn_RX, COUNTn_TX/COUNTn_RX (respectively), should not be modified
by the application software, as the hardware can change their value on the fly. When the
data transfer operation is completed, notified by a CTR interrupt event, they can be
accessed again to re-enable a new operation.
second IN transaction addressed to the same endpoint immediately following the one which
triggered the CTR interrupt.
Control transfers
Control transfers are made of a SETUP transaction, followed by zero or more data stages,
all of the same direction, followed by a status stage (a zero-byte transfer in the opposite
direction). SETUP transactions are handled by control endpoints only and are very similar to
OUT ones (data reception) except that the values of DTOG_TX and DTOG_RX bits of the
addressed endpoint registers are set to 1 and 0 respectively, to initialize the control transfer,
and both STAT_TX and STAT_RX are set to ‘10’ (NAK) to let software decide if subsequent
transactions must be IN or OUT depending on the SETUP contents. A control endpoint must
check SETUP bit in the USB_EPnR register at each CTR_RX event to distinguish normal
OUT transactions from SETUP ones. A USB device can determine the number and direction
of data stages by interpreting the data transferred in the SETUP stage, and is required to
STALL the transaction in the case of errors. To do so, at all data stages before the last, the
unused direction should be set to STALL, so that, if the host reverses the transfer direction
too soon, it gets a STALL as a status stage. While enabling the last data stage, the opposite
direction should be set to NAK, so that, if the host reverses the transfer direction (to perform
the status stage) immediately, it is kept waiting for the completion of the control operation. If
the control operation completes successfully, the software will change NAK to VALID,
otherwise to STALL. At the same time, if the status stage will be an OUT, the STATUS_OUT
(EP_KIND in the USB_EPnR register) bit should be set, so that an error is generated if a
status transaction is performed with not-zero data. When the status transaction is serviced,
the application clears the STATUS_OUT bit and sets STAT_RX to VALID (to accept a new
command) and STAT_TX to NAK (to delay a possible status stage immediately following the
next setup).
Since the USB specification states that a SETUP packet cannot be answered with a
handshake different from ACK, eventually aborting a previously issued command to start the
new one, the USB logic doesn’t allow a control endpoint to answer with a NAK or STALL
packet to a SETUP token received from the host.
When the STAT_RX bits are set to ‘01’ (STALL) or ‘10’ (NAK) and a SETUP token is
received, the USB accepts the data, performing the required data transfers and sends back
an ACK handshake. If that endpoint has a previously issued CTR_RX request not yet
acknowledged by the application (i.e. CTR_RX bit is still set from a previously completed
reception), the USB discards the SETUP transaction and does not answer with any
handshake packet regardless of its state, simulating a reception error and forcing the host to
send the SETUP token again. This is done to avoid losing the notification of a SETUP
transaction addressed to the same endpoint immediately following the transaction, which
triggered the CTR_RX interrupt.
The memory buffer which is currently being used by the USB peripheral is defined by DTOG
buffer flag, while the buffer currently in use by application software is identified by SW_BUF
buffer flag. The relationship between the buffer flag value and the used packet buffer is the
same in both cases, and it is listed in the following table.
DBL_BUF setting, STAT bit pair is not affected by the transaction termination and its value
remains ‘11’ (Valid). However, as the token packet of a new transaction is received, the
actual endpoint status will be masked as ‘10’ (NAK) when a buffer conflict between the USB
peripheral and the application software is detected (this condition is identified by DTOG and
SW_BUF having the same value, see Table 153 on page 522). The application software
responds to the CTR event notification by clearing the interrupt flag and starting any
required handling of the completed transaction. When the application packet buffer usage is
over, the software toggles the SW_BUF bit, writing ‘1’ to it, to notify the USB peripheral
about the availability of that buffer. In this way, the number of NAKed transactions is limited
only by the application elaboration time of a transaction data: if the elaboration time is
shorter than the time required to complete a transaction on the USB bus, no re-
transmissions due to flow control will take place and the actual transfer rate will be limited
only by the host PC.
The application software can always override the special flow control implemented for
double-buffered bulk endpoints, writing an explicit status different from ‘11’ (Valid) into the
STAT bit pair of the related USB_EPnR register. In this case, the USB peripheral will always
use the programmed endpoint status, regardless of the buffer usage condition.
The actual procedure used to suspend the USB peripheral is device dependent since
according to the device composition, different actions may be required to reduce the total
consumption.
A brief description of a typical suspend procedure is provided below, focused on the USB-
related aspects of the application software routine responding to the SUSP notification of
the USB peripheral:
1. Set the FSUSP bit in the USB_CNTR register to 1. This action activates the suspend
mode within the USB peripheral. As soon as the suspend mode is activated, the check
on SOF reception is disabled to avoid any further SUSP interrupts being issued while
the USB is suspended.
2. Remove or reduce any static power consumption in blocks different from the USB
peripheral.
3. Set LP_MODE bit in USB_CNTR register to 1 to remove static power consumption in
the analog USB transceivers but keeping them able to detect resume activity.
4. Optionally turn off external oscillator and device PLL to stop any activity inside the
device.
When an USB event occurs while the device is in SUSPEND mode, the RESUME procedure
must be invoked to restore nominal clocks and regain normal USB behavior. Particular care
must be taken to insure that this process does not take more than 10mS when the wakening
event is an USB reset sequence (See “Universal Serial Bus Specification” for more details).
The start of a resume or reset sequence, while the USB peripheral is suspended, clears the
LP_MODE bit in USB_CNTR register asynchronously. Even if this event can trigger an
WKUP interrupt if enabled, the use of an interrupt response routine must be carefully
evaluated because of the long latency due to system clock restart; to have the shorter
latency before re-activating the nominal clock it is suggested to put the resume procedure
just after the end of the suspend one, so its code is immediately executed as soon as the
system clock restarts. To prevent ESD discharges or any other kind of noise from waking-up
the system (the exit from suspend mode is an asynchronous event), a suitable analog filter
on data line status is activated during suspend; the filter width is about 70ns.
The following is a list of actions a resume procedure should address:
1. Optionally turn on external oscillator and/or device PLL.
2. Clear FSUSP bit of USB_CNTR register.
3. If the resume triggering event has to be identified, bits RXDP and RXDM in the
USB_FNR register can be used according to Table 155, which also lists the intended
software action in all the cases. If required, the end of resume or reset sequence can
be detected monitoring the status of the above mentioned bits by checking when they
reach the “10” configuration, which represent the Idle bus state; moreover at the end of
a reset sequence the RESET bit in USB_ISTR register is set to 1, issuing an interrupt if
enabled, which should be handled as usual.
A device may require to exit from suspend mode as an answer to particular events not
directly related to the USB protocol (e.g. a mouse movement wakes up the whole system).
In this case, the resume sequence can be started by setting the RESUME bit in the
USB_CNTR register to ‘1’ and resetting it to 0 after an interval between 1mS and 15mS (this
interval can be timed using ESOF interrupts, occurring with a 1mS period when the system
clock is running at nominal frequency). Once the RESUME bit is clear, the resume
sequence will be completed by the host PC and its end can be monitored again using the
RXDP and RXDM bits in the USB_FNR register.
Note: The RESUME bit must be anyway used only after the USB peripheral has been put in
suspend mode, setting the FSUSP bit in USB_CNTR register to 1.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CTRM PMAOVRM ERRM WKUPM SUSPM RESETM SOFM ESOFM Reserved RESUME FSUSP LP_MODE PDWN FRES
rw rw rw rw rw rw rw rw Res. rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PMA
CTR ERR WKUP SUSP RESET SOF ESOF Reserved DIR EP_ID[3:0]
OVR
This register contains the status of all the interrupt sources allowing application software to
determine, which events caused an interrupt request.
The upper part of this register contains single bits, each of them representing a specific
event. These bits are set by the hardware when the related event occurs; if the
corresponding bit in the USB_CNTR register is set, a generic interrupt request is generated.
The interrupt routine, examining each bit, will perform all necessary actions, and finally it will
clear the serviced bits. If any of them is not cleared, the interrupt is considered to be still
pending, and the interrupt line will be kept high again. If several bits are set simultaneously,
only a single interrupt will be generated.
Endpoint transaction completion can be handled in a different way to reduce interrupt
response latency. The CTR bit is set by the hardware as soon as an endpoint successfully
completes a transaction, generating a generic interrupt request if the corresponding bit in
USB_CNTR is set. An endpoint dedicated interrupt condition is activated independently
from the CTRM bit in the USB_CNTR register. Both interrupt conditions remain active until
software clears the pending bit in the corresponding USB_EPnR register (the CTR bit is
actually a read only bit). For endpoint-related interrupts, the software can use the Direction
of Transaction (DIR) and EP_ID read-only bits to identify, which endpoint made the last
interrupt request and called the corresponding interrupt service routine.
The user can choose the relative priority of simultaneously pending USB_ISTR events by
specifying the order in which software checks USB_ISTR bits in an interrupt service routine.
Only the bits related to events, which are serviced, are cleared. At the end of the service
routine, another interrupt will be requested, to service the remaining conditions.
To avoid spurious clearing of some bits, it is recommended to clear them with a load
instruction where all bits which must not be altered are written with 1, and all bits to be
cleared are written with ‘0’ (these bits can only be cleared by software). Read-modify-write
cycles should be avoided because between the read and the write operations another bit
could be set by the hardware and the next write will clear it before the microprocessor has
the time to serve the event.
The following describes each bit in detail:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Res. rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
BTABLE[15:3] Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw Res.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rc_w0 t t t r rw rw rw rc_w0 t t t rw rw rw rw
They are also reset when an USB reset is received from the USB bus or forced through bit
FRES in the CTLR register, except the CTR_RX and CTR_TX bits, which are kept
unchanged to avoid missing a correct packet notification immediately followed by an USB
reset event. Each endpoint has its USB_EPnR register where n is the endpoint identifier.
Read-modify-write cycles on these registers should be avoided because between the read
and the write operations some bits could be set by the hardware and the next write would
modify them before the CPU has the time to detect the change. For this purpose, all bits
affected by this problem have an ‘invariant’ value that must be used whenever their
modification is not required. It is recommended to modify these registers with a load
instruction where all the bits, which can be modified only by the hardware, are written with
their ‘invariant’ value.
00 BULK
01 CONTROL
10 ISO
11 INTERRUPT
00 BULK DBL_BUF
01 CONTROL STATUS_OUT
10 ISO Not used
11 INTERRUPT Not used
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ADDRn_TX[15:1] -
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw -
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- COUNTn_TX[9:0]
rw rw rw rw rw rw rw rw rw rw
Bits 15:10 These bits are not used since packet size is limited by USB specifications to 1023 bytes. Their
value is not considered by the USB peripheral.
Bits 9:0 COUNTn_TX[9:0]: Transmission byte count
These bits contain the number of bytes to be transmitted by the endpoint associated with the
USB_EPnR register at the next IN token addressed to it.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
- COUNTn_TX_1[9:0]
- - - - - - rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- COUNTn_TX_0[9:0]
- - - - - - rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ADDRn_RX[15:1] -
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw -
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw r r r r r r r r r r
This table location is used to store two different values, both required during packet
reception. The most significant bits contains the definition of allocated buffer size, to allow
buffer overflow detection, while the least significant part of this location is written back by the
USB peripheral at the end of reception to give the actual number of received bytes. Due to
the restrictions on the number of available bits, buffer size is represented using the number
of allocated memory blocks, where block size can be selected to choose the trade-off
between fine-granularity/small-buffer and coarse-granularity/large-buffer. The size of
allocated buffer is a part of the endpoint descriptor and it is normally defined during the
enumeration process according to its maxPacketSize parameter value (See “Universal
Serial Bus Specification”).
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
BLSIZE
NUM_BLOCK_1[4:0] COUNTn_RX_1[9:0]
_1
rw rw rw rw rw rw r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
BLSIZE
NUM_BLOCK_0[4:0] COUNTn_RX_0[9:0]
_0
rw rw rw rw rw rw r r r r r r r r r r
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
DTOG_RX
DTOG_TX
EP_KIND
CTR_RX
CTR_TX
STAT_ EP STAT_
SETUP
USB_EP0R RX TYPE TX EA[3:0]
0x00 Reserved
[1:0] [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DTOG_RX
DTOG_TX
EP_KIND
CTR_RX
CTR_TX
STAT_ EP STAT_
SETUP
USB_EP1R RX TYPE TX EA[3:0]
0x04 Reserved
[1:0] [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DTOG_RX
DTOG_TX
EP_KIND
CTR_RX
CTR_TX
STAT_ EP STAT_
SETUP
USB_EP2R RX TYPE TX EA[3:0]
0x08 Reserved
[1:0] [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DTOG_RX
DTOG_TX
EP_KIND
CTR_RX
CTR_TX
STAT_ EP STAT_
SETUP
USB_EP3R RX TYPE TX EA[3:0]
0x0C Reserved
[1:0] [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DTOG_RX
DTOG_TX
EP_KIND
CTR_RX
CTR_TX
STAT_ EP STAT_
SETUP
USB_EP4R RX TYPE TX EA[3:0]
0x10 Reserved
[1:0] [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DTOG_RX
DTOG_TX
EP_KIND
CTR_RX
CTR_TX
STAT_ SETUP EP STAT_
USB_EP5R RX TYPE TX EA[3:0]
0x14 Reserved
[1:0] [1:0] [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DTOG_RX
DTOG_TX
EP_KIND
CTR_RX
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DTOG_RX
DTOG_TX
EP_KIND
CTR_RX
CTR_TX
STAT_ EP STAT_
SETUP
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x20-
Reserved
0x3F
PMAOVRM
RESUME
LPMODE
RESETM
WKUPM
SUSPM
ESOFM
FSUSP
PDWN
ERRM
CTRM
SOFM
FRES
USB_CNTR
0x40 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 1 1
PMAOVR
RESET
WKUP
ESOF
SUSP
ERR
CTR
SOF
DIR
USB_ISTR EP_ID[3:0]
0x44 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0
RXDM
RXDP
LSOF
LCK
USB_FNR FN[10:0]
0x48 Reserved [1:0]
Reset value 0 0 0 0 0 x x x x x x x x x x x
USB_DADDR EF ADD[6:0]
0x4C Reserved Reserved
Reset value 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
USB_BTABLE BTABLE[15:3]
0x50 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0
Management
● Maskable interrupts
● Software-efficient mailbox mapping at a unique address space
Dual CAN (connectivity line only)
● CAN1: Master bxCAN for managing the communication between a Slave bxCAN and
the 512-byte SRAM memory
● CAN2: Slave bxCAN, with no direct access to the SRAM memory.
● The two bxCAN cells share the 512-byte SRAM memory (see Figure 193 on page 545)
Note: In medium-density and high-density devices the USB and CAN share a dedicated 512-byte
SRAM memory for data transmission and reception, and so they cannot be used
concurrently (the shared SRAM is accessed through CAN and USB exclusively). The USB
and CAN can be used in the same application but not at the same time.
CAN node 2
CAN node n
MCU
Application
CAN
Controller
CAN CAN
Rx Tx
CAN
Transceiver
CAN CAN
High Low
CAN Bus
22.3.3 Tx mailboxes
Three transmit mailboxes are provided to the software for setting up messages. The
transmission Scheduler decides which mailbox has to be transmitted first.
Receive FIFO
Two receive FIFOs are used by hardware to store the incoming messages. Three complete
messages can be stored in each FIFO. The FIFOs are managed completely by hardware.
Rx FIFO 1 Status
Acceptance Filters
Interrupt Enable
27
CAN 2.0B Active Core .. .. 26
Error Status Memory 2 3
1
Access Filter 0
Bit Timing Controller
Filter Mode
Transmission
Filter Scale Scheduler
Slave Slave
Slave Receive FIFO 0 Receive FIFO 1
Filter FIFO Assign Tx Mailboxes 2 2
Filter Activation 2 1 1
1 Mailbox 0 Mailbox 0
Mailbox 0
CAN2 (Slave)
Control/Status/Configuration
Master Control
Master Status
Tx Status
Rx FIFO 0 Status
CAN 2.0B Active Core
Rx FIFO 1 Status
Interrupt Enable
Error Status
Note: CAN 2 start filter bank number n is configurable by writing to
Bit Timing the CAN2SB[5:0] bits in the CAN_ FMR register.
ai16094
To synchronize, bxCAN waits until the CAN bus is idle, this means 11 consecutive recessive
bits have been monitored on CANRX.
On CAN bus activity detection, hardware automatically performs the wakeup sequence by
clearing the SLEEP bit if the AWUM bit in the CAN_MCR register is set. If the AWUM bit is
cleared, software has to clear the SLEEP bit when a wakeup interrupt occurs, in order to exit
from Sleep mode.
Note: If the wakeup interrupt is enabled (WKUIE bit set in CAN_IER register) a wakeup interrupt
will be generated on detection of CAN bus activity, even if the bxCAN automatically performs
the wakeup sequence.
After the SLEEP bit has been cleared, Sleep mode is exited once bxCAN has synchronized
with the CAN bus, refer to Figure 194: bxCAN operating modes. The Sleep mode is exited
once the SLAK bit has been cleared by hardware.
3LEEP
3,!+
).!+
1
.2 3,
) %%
9 .# 0
)
3 .2
3, 1
0 #+ %% !
%% ! 0 #+
3, )
% %0 .2
3, 1
!
#+
1. ACK = The wait state during which hardware confirms a request by setting the INAK or SLAK bits in the
CAN_MSR register
2. SYNC = The state during which bxCAN waits until the CAN bus is idle, meaning 11 consecutive recessive
bits have been monitored on CANRX
bxCAN
Tx Rx
=1
CANTX CANRX
bxCAN
Tx Rx
CANTX CANRX
This mode is provided for self-test functions. To be independent of external events, the CAN
Core ignores acknowledge errors (no dominant bit sampled in the acknowledge slot of a
data / remote frame) in Loop Back Mode. In this mode, the bxCAN performs an internal
feedback from its Tx output to its Rx input. The actual value of the CANRX input pin is
disregarded by the bxCAN. The transmitted messages can be monitored on the CANTX pin.
bxCAN
Tx Rx
=1
CANTX CANRX
Transmit priority
By identifier:
When more than one transmit mailbox is pending, the transmission order is given by the
identifier of the message stored in the mailbox. The message with the lowest identifier value
has the highest priority according to the arbitration of the CAN protocol. If the identifier
values are equal, the lower mailbox number will be scheduled first.
By transmit request order:
The transmit mailboxes can be configured as a transmit FIFO by setting the TXFP bit in the
CAN_MCR register. In this mode the priority order is given by the transmit request order.
This mode is very useful for segmented transmission.
Abort
A transmission request can be aborted by the user setting the ABRQ bit in the CAN_TSR
register. In pending or scheduled state, the mailbox is aborted immediately. An abort
request while the mailbox is in transmit state can have two results. If the mailbox is
transmitted successfully the mailbox becomes empty with the TXOK bit set in the
CAN_TSR register. If the transmission fails, the mailbox becomes scheduled, the
transmission is aborted and becomes empty with TXOK cleared. In all cases the mailbox
will become empty again at least at the end of the current transmission.
EMPTY
RQCP=X
TXOK=X
TXRQ=1
TME = 1
PENDING
RQCP=0 Mailbox has
TXOK=0 highest priority
ABRQ=1
TME = 0
EMPTY
Transmit succeeded
RQCP=1
TXOK=1
TME = 1
Valid message
A received message is considered as valid when it has been received correctly according to
the CAN protocol (no error until the last but one bit of the EOF field) and It passed through
the identifier filtering successfully, see Section 22.7.4: Identifier filtering.
PENDING_1
Release FMP=0x01
Mailbox FOVR=0
PENDING_2
FMP=0x10
FOVR=0
PENDING_3
FMP=0x11 Valid Message
FOVR=0 Received
OVERRUN
Release FMP=0x11
Mailbox FOVR=1
RFOM=1
Valid Message
Received
FIFO management
Starting from the empty state, the first valid message received is stored in the FIFO which
becomes pending_1. The hardware signals the event setting the FMP[1:0] bits in the
CAN_RFR register to the value 01b. The message is available in the FIFO output mailbox.
The software reads out the mailbox content and releases it by setting the RFOM bit in the
CAN_RFR register. The FIFO becomes empty again. If a new valid message has been
received in the meantime, the FIFO stays in pending_1 state and the new message is
available in the output mailbox.
If the application does not release the mailbox, the next valid message will be stored in the
FIFO which enters pending_2 state (FMP[1:0] = 10b). The storage process is repeated for
the next valid message putting the FIFO into pending_3 state (FMP[1:0] = 11b). At this
point, the software must release the output mailbox by setting the RFOM bit, so that a
mailbox is free to store the next valid message. Otherwise the next valid message received
will cause a loss of message.
Refer also to Section 22.7.5: Message storage
Overrun
Once the FIFO is in pending_3 state (i.e. the three mailboxes are full) the next valid
message reception will lead to an overrun and a message will be lost. The hardware
signals the overrun condition by setting the FOVR bit in the CAN_RFR register. Which
message is lost depends on the configuration of the FIFO:
● If the FIFO lock function is disabled (RFLM bit in the CAN_MCR register cleared) the
last message stored in the FIFO will be overwritten by the new incoming message. In
this case the latest messages will be always available to the application.
● If the FIFO lock function is enabled (RFLM bit in the CAN_MCR register set) the most
recent message will be discarded and the software will have the three oldest messages
in the FIFO available.
resources which would be otherwise needed to perform filtering by software. Each filter
bank x consists of two 32-bit registers, CAN_FxR0 and CAN_FxR1.
Scalable width
To optimize and adapt the filters to the application needs, each filter bank can be scaled
independently. Depending on the filter scale a filter bank provides:
● One 32-bit filter for the STDID[10:0], EXTID[17:0], IDE and RTR bits.
● Two 16-bit filters for the STDID[10:0], RTR, IDE and EXTID[17:15] bits.
Refer to Figure 200.
Furthermore, the filters can be configured in mask mode or in identifier list mode.
Mask mode
In mask mode the identifier registers are associated with mask registers specifying which
bits of the identifier are handled as “must match” or as “don’t care”.
FBMx = 0
ID CAN_FxR1[31:24] CAN_FxR1[23:16] CAN_FxR1[15:8] CAN_FxR1[7:0]
n
Mask CAN_FxR2[31:24] CAN_FxR2[23:16] CAN_FxR2[15:8] CAN_FxR2[7:0]
FSCx = 1
n
Mask CAN_FxR1[31:24] CAN_FxR1[23:16]
ID CAN_FxR2[15:8] CAN_FxR2[7:0]
n+1
Mask CAN_FxR2[31:24] CAN_FxR2[23:16]
FSCx = 0
2
1 ID Mask (32-bit) 2 4 ID List (32-bit) 3
3
4 Deactivated 4
3 ID List (16-bit) 7
5 ID Mask (16-bit) 5
6
Deactivated 7 6
5 8 ID Mask (16-bit)
ID List (32-bit) 8 7
8
9 Deactivated 9
6 ID Mask (16-bit) 10 10
10 ID List (16-bit)
11
11 12
9 ID List (32-bit) 11 ID List (32-bit)
12 13
ID=Identifier
Filter bank
Num Receive FIFO
Identifier 0
0
Identifier 1 Message
Identifier List
Identifier 4 Identifier #4 Match Stored
2
Identifier 5
Identifier & Mask
1
Identifier
Mask 2 Filter number stored in the
FMI
Filter Match Index field
within the CAN_RDTxR
Identifier register
4 3
Mask
No Match
Found
Message Discarded
The example above shows the filtering principle of the bxCAN. On reception of a message,
the identifier is compared first with the filters configured in identifier list mode. If there is a
match, the message is stored in the associated FIFO and the index of the matching filter is
stored in the Filter Match Index. As shown in the example, the identifier matches with
Identifier #2 thus the message content and FMI 2 is stored in the FIFO.
If there is no match, the incoming identifier is then compared with the filters configured in
mask mode.
If the identifier does not match any of the identifiers configured in the filters, the message is
discarded by hardware without disturbing the software.
Transmit mailbox
The software sets up the message to be transmitted in an empty transmit mailbox. The
status of the transmission is indicated by hardware in the CAN_TSR register.
0 CAN_TIxR
4 CAN_TDTxR
8 CAN_TDLxR
12 CAN_TDHxR
Receive mailbox
When a message has been received, it is available to the software in the FIFO output
mailbox. Once the software has handled the message (e.g. read it) the software must
release the FIFO output mailbox by means of the RFOM bit in the CAN_RFR register to
make the next incoming message available. The filter match index is stored in the MFMI field
of the CAN_RDTxR register. The 16-bit time stamp value is stored in the TIME[15:0] field of
CAN_RDTxR.
0 CAN_RIxR
4 CAN_RDTxR
8 CAN_RDLxR
12 CAN_RDHxR
%22/2 !#4)6%
%22/2 0! 33)6%
"53 /&&
AI
Bus-Off recovery
The Bus-Off state is reached when TEC is greater than 255, this state is indicated by BOFF
bit in CAN_ESR register. In Bus-Off state, the bxCAN is no longer able to transmit and
receive messages.
Depending on the ABOM bit in the CAN_MCR register bxCAN will recover from Bus-Off
(become error active again) either automatically or on software request. But in both cases
the bxCAN has to wait at least for the recovery sequence specified in the CAN standard
(128 occurrences of 11 consecutive recessive bits monitored on CANRX).
If ABOM is set, the bxCAN will start the recovering sequence automatically after it has
entered Bus-Off state.
If ABOM is cleared, the software must initiate the recovering sequence by requesting
bxCAN to enter and to leave initialization mode.
Note: In initialization mode, bxCAN does not monitor the CANRX signal, therefore it cannot
complete the recovery sequence. To recover, bxCAN must be in normal mode.
A valid edge is defined as the first transition in a bit time from dominant to recessive bus
level provided the controller itself does not send a recessive bit.
If a valid edge is detected in BS1 instead of SYNC_SEG, BS1 is extended by up to SJW so
that the sample point is delayed.
Conversely, if a valid edge is detected in BS2 instead of SYNC_SEG, BS2 is shortened by
up to SJW so that the transmit point is moved earlier.
As a safeguard against programming errors, the configuration of the Bit Timing Register
(CAN_BTR) is only possible while the device is in Standby mode.
Note: For a detailed description of the CAN bit timing and resynchronization mechanism, please
refer to the ISO 11898 standard.
1 x tq tBS1 tBS2
Inter-Frame Space
Inter-Frame Space Data Frame (Standard identifier) or Overload Frame
44 + 8 * N
Arbitration Field Ctrl Field Data Field CRC Field Ack Field
2
32 6 8*N 16 7
IDE
r0
RTR
SOF
ACK
Inter-Frame Space
Inter-Frame Space Data Frame (Extended Identifier) or Overload Frame
64 + 8 * N
Arbitration Field Arbitration Field Ctrl Field Data Field CRC Field Ack Field
2
32 32 6 8*N 16 7
r1
RTR
IDE
r0
SRR
SOF
ACK
Inter-Frame Space
Inter-Frame Space Remote Frame or Overload Frame
44
Arbitration Field Ctrl Field CRC Field Ack Field
2
32 6 16 7
ACK
Data Frame or Inter-Frame Space
Remote Frame Error Frame or Overload Frame Notes:
Error Flag Echo Error Delimiter 0 <= N <= 8
Flag
6 6 8 SOF = Start Of Frame
ID = Identifier
RTR = Remote Transmission Request
Data Frame or IDE = Identifier Extension Bit
Any Frame Inter-Frame Space Remote Frame r0 = Reserved Bit
Suspend DLC = Data Length Code
Intermission Transmission Bus Idle
3 CRC = Cyclic Redundancy Code
8
Error flag: 6 dominant bits if node is error
ai15154
FMPIE0
FMP0
& FIFO 0
INTERRUPT
FFIE0
CAN_RF0R FULL0
& +
FOVIE0
FOVR0
&
FMPIE1
FMP1
& FIFO 1
INTERRUPT
FFIE1
CAN_RF1R FULL1
& +
FOVIE1
FOVR1
&
ERRIE
EWGIE
EWGF &
EPVIE
CAN_ESR EPVF & &
BOFIE
+
ERRI
BOFF & CAN_MSR STATUS CHANGE
ERROR
LECIE
1LEC6 & INTERRUPT
WKUIE
WKUI
&
CAN_MSR
SLKIE
SLAKI
&
● The error and status change interrupt can be generated by the following events:
– Error condition, for more details on error conditions please refer to the CAN Error
Status register (CAN_ESR).
– Wakeup condition, SOF monitored on the CAN Rx signal.
– Entry into Sleep mode.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
DBF
Reserved
rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SLKIE WKUIE
Reserved
rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
REC[7:0] TEC[7:0]
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
BRP[9:0]
Reserved
rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
STID[10:0]/EXID[28:18] EXID[17:13]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
CAN mailbox data length control and time stamp register (CAN_TDTxR)
(x=0..2)
All bits of this register are write protected when the mailbox is not in empty state.
Address offsets: 0x184, 0x194, 0x1A4
Reset value: undefined
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
TIME[15:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TGT DLC[3:0]
Reserved Reserved
rw rw rw rw rw
DATA3[7:0] DATA2[7:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DATA1[7:0] DATA0[7:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
DATA7[7:0] DATA6[7:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DATA5[7:0] DATA4[7:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
STID[10:0]/EXID[28:18] EXID[17:13]
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CAN receive FIFO mailbox data length control and time stamp register
(CAN_RDTxR) (x=0..1)
Address offsets: 0x1B4, 0x1C4
Reset value: undefined
Note: All RX registers are write protected.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
TIME[15:0]
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FMI[7:0] DLC[3:0]
Reserved
r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
DATA3[7:0] DATA2[7:0]
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DATA1[7:0] DATA0[7:0]
r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
DATA7[7:0] DATA6[7:0]
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DATA5[7:0] DATA4[7:0]
r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FINIT
Reserved
rw
CAN2SB[5:0] FINIT
Reserved Reserved
rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
FBM27 FBM26 FBM25 FBM24 FBM23 FBM22 FBM21 FBM20 FBM19 FBM18 FBM17 FBM16
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FBM15 FBM14 FBM13 FBM12 FBM11 FBM10 FBM9 FBM8 FBM7 FBM6 FBM5 FBM4 FBM3 FBM2 FBM1 FBM0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: Please refer to Figure 200: Filter bank scale configuration - register organization on
page 554
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
FSC27 FSC26 FSC25 FSC24 FSC23 FSC22 FSC21 FSC20 FSC19 FSC18 FSC17 FSC16
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FSC15 FSC14 FSC13 FSC12 FSC11 FSC10 FSC9 FSC8 FSC7 FSC6 FSC5 FSC4 FSC3 FSC2 FSC1 FSC0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: Please refer to Figure 200: Filter bank scale configuration - register organization on
page 554
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
FFA27 FFA26 FFA25 FFA24 FFA23 FFA22 FFA21 FFA20 FFA19 FFA18 FFA17 FFA16
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FFA15 FFA14 FFA13 FFA12 FFA11 FFA10 FFA9 FFA8 FFA7 FFA6 FFA5 FFA4 FFA3 FFA2 FFA1 FFA0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
FACT27 FACT26 FACT25 FACT24 FACT23 FACT22 FACT21 FACT20 FACT19 FACT18 FACT17 FACT16
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FACT15 FACT14 FACT13 FACT12 FACT11 FACT10 FACT9 FACT8 FACT7 FACT6 FACT5 FACT4 FACT3 FACT2 FACT1 FACT0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
FB31 FB30 FB29 FB28 FB27 FB26 FB25 FB24 FB23 FB22 FB21 FB20 FB19 FB18 FB17 FB16
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FB15 FB14 FB13 FB12 FB11 FB10 FB9 FB8 FB7 FB6 FB5 FB4 FB3 FB2 FB1 FB0
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
In all configurations:
Bits 31:0 FB[31:0]: Filter bits
Identifier
Each bit of the register specifies the level of the corresponding bit of the expected identifier.
0: Dominant bit is expected
1: Recessive bit is expected
Mask
Each bit of the register specifies whether the bit of the associated identifier register must
match with the corresponding bit of the expected identifier or not.
0: Don’t care, the bit is not used for the comparison
1: Must match, the bit of the incoming identifier must have the same level has specified in
the corresponding identifier register of the filter.
Note: Depending on the scale and mode configuration of the filter the function of each register can
differ. For the filter mapping, functions description and mask registers association, refer to
Section 22.7.4: Identifier filtering on page 552.
A Mask/Identifier register in mask mode has the same bit mapping as in identifier list
mode.
For the register mapping/addresses of the filter banks please refer to the Table 164 on
page 583.
9
8
7
6
5
4
3
2
1
0
RESET
SLEEP
AWUM
ABOM
TTCM
RFLM
NART
TXFP
INRQ
DBF
CAN_MCR
0x000 Reserved Reserved
Reset value 1 0 0 0 0 0 0 0 1 0
SAMP
SLAKI
WKUI
SLAK
ERRI
INAK
RXM
TXM
RX
CAN_MSR
0x004 Reserved Reserved
Reset value 1 1 0 0 0 0 0 1 0
CODE[1:0]
RQCP2
RQCP1
RQCP0
ABRQ2
ABRQ1
ABRQ0
TERR2
TXOK2
TERR1
TXOK1
TERR0
TXOK0
ALST2
ALST1
ALST0
CAN_TSR LOW[2:0] TME[2:0]
0x008 Reserved Reserved Reserved
Reset value 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FMP0[1:0]
RFOM0
FOVR0
FULL0
Reserved
CAN_RF0R
0x00C Reserved
Reset value 0 0 0 0 0
FMP1[1:0]
RFOM1
FOVR1
FULL1
Reserved
CAN_RF1R
0x010 Reserved
Reset value 0 0 0 0 0
FMPIE1
FMPIE0
FOVIE1
FOVIE0
EWGIE
WKUIE
ERRIE
TMEIE
Reserved
BOFIE
EPVIE
LECIE
SLKIE
FFIE1
FFIE0
CAN_IER
0x014 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0
LEC[2:0]
EWGF
Reserved
BOFF
EPVF
CAN_ESR REC[7:0] TEC[7:0]
0x018 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SJW[1:0]
Reserved
LBKM
SILM
Reset value 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
0x020-
Reserved
0x17F TXRQ
RTR
IDE
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x 0
TGT
Reset value x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
TXRQ
RTR
IDE
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
TGT
CAN_TDT1R TIME[15:0] DLC[3:0]
0x194 Reserved Reserved
Reset value x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
TXRQ
RTR
IDE
CAN_TI2R STID[10:0]/EXID[28:18] EXID[17:0]
0x1A0
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x 0
TGT
CAN_TDT2R TIME[15:0] DLC[3:0]
0x1A4 Reserved Reserved
Reset value x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reserved
RTR
IDE
CAN_RI0R STID[10:0]/EXID[28:18] EXID[17:0]
0x1B0
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reserved
RTR
IDE
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
0x1D0-
Reserved
0x1FF
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0 FINIT
CAN_FMR CAN2SB[5:0]
0x200 Reserved Reserved
Reset value 0 0 1 1 1 0 1
CAN_FM1R FBM[27:0]
0x204 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x208 Reserved
CAN_FS1R FSC[27:0]
0x20C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x210 Reserved
CAN_FFA1R FFA[27:0]
0x214 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x218 Reserved
CAN_FA1R FACT[27:0]
0x21C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x220 Reserved
0x224-
Reserved
0x23F
CAN_F0R1 FB[31:0]
0x240
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
CAN_F0R2 FB[31:0]
0x244
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
CAN_F1R1 FB[31:0]
0x248
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
CAN_F1R2 FB[31:0]
0x24C
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
. . .
. . .
. . .
. . .
CAN_F27R1 FB[31:0]
0x318
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
CAN_F27R2 FB[31:0]
0x31C
Reset value x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
Warning: Since some SPI3/I2S3 pins are shared with JTAG pins
(SPI3_NSS/I2S3_WS with JTDI and SPI3_SCK/I2S3_CK with
JTDO), they are not controlled by the I/O controller and are
reserved for JTAG usage (after each Reset).
For this purpose prior to configure the SPI3/I2S3 pins, the
user has to disable the JTAG and use the SWD interface
(when debugging the application), or disable both JTAG/SWD
interfaces (for standalone application). For more information
on the configuration of JTAG/SWD interface pins, please refer
to Section 8.3.5: JTAG/SWD alternate function remapping.
Read
Rx buffer
MOSI SPI_CR2
TXE RXNE ERR TXDM RXDM
0 0 SSOE AEN AEN
IE IE IE
Shift register
MISO
LSB first SPI_SR
MOD CRC
BSY OVR ERR 0 0 TXE RXNE
Tx buffer F
Write
0
Communication
control 1
SCK BR[2:0]
Baud rate generator
NSS
ai14744
Master Slave
MSBit LSBit MSBit LSBit
MISO MISO
8-bit shift register 8-bit shift register
MOSI MOSI
SSM bit
ai14746
CPHA =1
CPOL = 1
CPOL = 0
MISO LSBit
MSBit
(from master)
8 or 16 bits depending on Data Frame Format (see SPI_CR1)
MOSI
MSBit LSBit
(from slave)
NSS
(to slave)
Capture strobe
CPHA =0
CPOL = 1
CPOL = 0
NSS
(to slave)
Capture strobe
Note: These timings are shown with the LSBFIRST bit reset in the SPI_CR1 register.
1. These timings are shown with the LSBFIRST bit reset in the SPI_CR1 register.
Procedure
1. Set the DFF bit to define 8- or 16-bit data frame format
2. Select the CPOL and CPHA bits to define one of the four relationships between the
data transfer and the serial clock (see Figure 210). For correct data transfer, the CPOL
and CPHA bits must be configured in the same way in the slave device and the master
device.
3. The frame format (MSB-first or LSB-first depending on the value of the LSBFIRST bit in
the SPI_CR1 register) must be the same as the master device.
4. In Hardware mode (refer to Slave select (NSS) pin management on page 590), the
NSS pin must be connected to a low level signal during the complete byte transmit
sequence. In Software mode, set the SSM bit and clear the SSI bit in the SPI_CR1
register.
5. Clear the MSTR bit and set the SPE bit (both in the SPI_CR1 register) to assign the
pins to alternate functions.
In this configuration the MOSI pin is a data input and the MISO pin is a data output.
Transmit sequence
The data byte is parallel-loaded into the Tx buffer during a write cycle.
The transmit sequence begins when the slave device receives the clock signal and the most
significant bit of the data on its MOSI pin. The remaining bits (the 7 bits in 8-bit data frame
format, and the 15 bits in 16-bit data frame format) are loaded into the shift-register. The
TXE flag in the SPI_SR register is set on the transfer of data from the Tx Buffer to the shift
register and an interrupt is generated if the TXEIE bit in the SPI_CR2 register is set.
Receive sequence
For the receiver, when data transfer is complete:
● The Data in shift register is transferred to Rx Buffer and the RXNE flag (SPI_SR
register) is set
● An Interrupt is generated if the RXNEIE bit is set in the SPI_CR2 register.
After the last sampling clock edge the RXNE bit is set, a copy of the data byte received in
the shift register is moved to the Rx buffer. When the SPI_DR register is read, the SPI
peripheral returns this buffered value.
Clearing of the RXNE bit is performed by reading the SPI_DR register.
Procedure
1. Select the BR[2:0] bits to define the serial clock baud rate (see SPI_CR1 register).
2. Select the CPOL and CPHA bits to define one of the four relationships between the
data transfer and the serial clock (see Figure 210).
3. Set the DFF bit to define 8- or 16-bit data frame format
4. Configure the LSBFIRST bit in the SPI_CR1 register to define the frame format
5. If the NSS pin is required in input mode, in hardware mode, connect the NSS pin to a
high-level signal during the complete byte transmit sequence. In software mode, set the
SSM and SSI bits in the SPI_CR1 register.
If the NSS pin is required in output mode, the SSOE bit only should be set.
6. The MSTR and SPE bits must be set (they remain set only if the NSS pin is connected
to a high-level signal).
In this configuration the MOSI pin is a data output and the MISO pin is a data input.
Transmit sequence
The transmit sequence begins when a byte is written in the Tx Buffer.
The data byte is parallel-loaded into the shift register (from the internal bus) during the first
bit transmission and then shifted out serially to the MOSI pin MSB first or LSB first
depending on the LSBFIRST bit in the SPI_CR1 register. The TXE flag is set on the transfer
of data from the Tx Buffer to the shift register and an interrupt is generated if the TXEIE bit in
the SPI_CR2 register is set.
Receive sequence
For the receiver, when data transfer is complete:
● The data in the shift register is transferred to the RX Buffer and the RXNE flag is set
● An interrupt is generated if the RXNEIE bit is set in the SPI_CR2 register
At the last sampling clock edge the RXNE bit is set, a copy of the data byte received in the
shift register is moved to the Rx buffer. When the SPI_DR register is read, the SPI
peripheral returns this buffered value.
Clearing the RXNE bit is performed by reading the SPI_DR register.
A continuous transmit stream can be maintained if the next data to be transmitted is put in
the Tx buffer once the transmission is started. Note that TXE flag should be ‘1’ before any
attempt to write the Tx buffer is made.
Note: In the NSS hardware mode, the slave's NSS input is controlled by the NSS pin or another
GPIO pin that has to be controlled by software.
communication. The transfer direction (Input/Output) is selected by the BIDIOE bit in the
SPI_CR1 register. When this bit is 1, the data line is output otherwise it is input.
BUSY flag
This flag indicates the state of the SPI communication layer. When it is set, it indicates that
the SPI is busy communicating and/or there is a valid data byte in the Tx buffer waiting to be
transmitted. The purpose of this flag is to indicate if there is any communication ongoing on
the SPI bus or not. This flag is set as soon as:
1. Data is written in the SPI_DR register in master mode
2. The SCK clock is present in slave mode
The BUSY flag is reset each time a byte is transmitted/received. This flag is set and cleared
by hardware. It can be monitored to avoid write collision errors. Writing to this flag has no
effect. The BUSY flag is meaningful only when the SPE bit is set.
Note: In master receiver mode (1-line bidirectional), the BUSY flag must NOT be checked.
using a programmable polynomial serially on each bit. It is calculated on the sampling clock
edge defined by the CPHA and CPOL bits in the SPI_CR1 register.
Note: This SPI offers two kinds of CRC calculation standard which depend directly on the data
frame format selected for the transmission and/or reception: 8-bit data (CR8) and 16-bit data
(CRC16-CCITT).
CRC calculation is enabled by setting the CRCEN bit in the SPI_CR1 register. This action
resets the CRC registers (SPI_RXCRCR and SPI_TXCRCR). When the CRCNEXT bit in
SPI_CR1 is set, the SPI_TXCRCR value is transmitted at the end of the current byte
transmission.
The CRCERR flag in the SPI_SR register is set if the value received in the shift register
during the SPI_TXCRCR value transmission does not match the SPI_RXCRCR value.
If data are present in the TX buffer, the CRC value is transmitted only after the transmission
of the data byte. During CRC transmission, the CRC calculator is switched off and the
register value remains unchanged.
Note: Please refer to the product specifications for availability of this feature.
SPI communication using CRC is possible through the following procedure:
● Program the CPOL, CPHA, LSBFirst, BR, SSM, SSI and MSTR values
● Program the polynomial in the SPI_CRCPR register
● Enable the CRC calculation by setting the CRCEN bit in the SPI_CR1 register. This
also clears the SPI_RXCRCR and SPI_TXCRCR registers
● Enable the SPI by setting the SPE bit in the SPI_CR1 register
● Start the communication and sustain the communication until all but one byte or half-
word have been transmitted or received.
● On writing the last byte or half-word to the TX buffer, set the CRCNext bit in the
SPI_CR1 register to indicate that after transmission of the last byte, the CRC should be
transmitted. CRC calculation is frozen during the CRC transmission.
● After transmitting the last byte or half word, the SPI transmits the CRC. The CRCNEXT
bit is reset. The CRC is also received and compared against the SPI_RXCRCR value.
If the value does not match, the CRCERR flag in SPI_SR is set and an interrupt can be
generated when the ERRIE bit in the SPI_CR2 register is set.
Note: When the SPI is in slave mode, be careful to enable CRC calculation only when the clock is
stable. If not, a wrong CRC calculation may be done.
With high bit rate frequencies, be carefull when transmitting the CRC. As the number of
used CPU cycles has to be as low as possible in the CRC transfer phase, it is forbidden to
call software functions in the CRC transmission sequence to avoid errors in the last data
and CRC reception.
For high bit rate frequencies, it is advised to use the DMA mode to avoid the degradation of
the SPI speed performance due to CPU accesses impacting the SPI bandwidth.
When the STM32F10xxx is configured as slave and the NSS hardware mode is used, the
NSS pin needs to be kept low between the data phase and the CRC phase.
DMA access is requested when the enable bit in the SPI_CR2 register is enabled. There are
separate requests for the Tx buffer and the Rx buffer.
Overrun condition
An overrun condition occurs when the master device has sent data bytes and the slave
device has not cleared the RXNE bit resulting from the previous data byte transmitted.
When an overrun condition occurs:
● OVR bit is set and an interrupt is generated if the ERRIE bit is set.
In this case, the receiver buffer contents will not be updated with the newly received data
from the master device. A read to the SPI_DR register returns this byte. All other
subsequently transmitted bytes are lost.
Clearing the OVR bit is done by a read of the SPI_DR register followed by a read access to
the SPI_SR register.
CRC error
This flag is used to verify the validity of the value received when the CRCEN bit in the
SPI_CR1 register is set. The CRCERR flag in the SPI_SR register is set if the value
received in the shift register (after transmission of the transmitter SPI_TXCRCR value) does
not match the receiver SPI_RXCRCR value.
Tx buffer
MOSI/ SD
Shift register
MISO
LSB first Communication
16-bit control
Rx buffer
NSS/WS
I2S I2SE
MOD
SPI LSB
SPE BR2 BR1 BR0 MSTR CPOL CPHA
baud rate generator First
CK
I2SMOD
MCK
MCKOE ODD I2SDIV[7:0]
I2SxCLK
ai14748
The SPI could function as an audio I2S interface when the I2S capability is enabled (by
setting the I2SMOD bit in the SPI_I2SCFGR register). This interface uses almost the same
pins, flags and interrupts as the SPI.
The I2S shares three common pins with the SPI:
● SD: Serial Data (mapped on the MOSI pin) to transmit or receive the two time-
multiplexed data channels (in simplex mode only).
● WS: Word Select (mapped on the NSS pin) is the data control signal output in master
mode and input in slave mode.
● CK: Serial Clock (mapped on the SCK pin) is the serial clock output in master mode
and serial clock input in slave mode.
An additional pin could be used when a master clock output is needed for some external
audio devices:
● MCK: Master Clock (mapped separately) is used, when the I2S is configured in master
mode (and when the MCKOE bit in the SPI_I2SPR register is set), to output this
additional clock generated at a preconfigured frequency rate equal to 256 × FS, where
FS is the audio sampling frequency.
The I2S uses its own clock generator to produce the communication clock when it is set in
master mode. This clock generator is also the source of the master clock output. Two
additional registers are available in I2S mode. One is linked to the clock generator
configuration SPI_I2SPR and the other one is a generic I2S configuration register
SPI_I2SCFGR (audio standard, slave/master mode, data format, packet frame, clock
polarity, etc.).
The SPI_CR1 register and all CRC registers are not used in the I2S mode. Likewise, the
SSOE bit in the SPI_CR2 register and the MODF and CRCERR bits in the SPI_SR are not
used.
The I2S uses the same SPI register for data transfer (SPI_DR) in 16-bit wide mode.
Figure 212. I2S Phillips protocol waveforms (16/32-bit full accuracy, CPOL = 0)
CK
WS
Transmission Reception
Channel left
Channel right
Data are latched on the falling edge of CK (for the transmitter) and are read on the rising
edge (for the receiver). The WS signal is also latched on the falling edge of CK.
Figure 213. I2S Phillips standard waveforms (24-bit frame with CPOL = 0)
CK
WS
Transmission Reception
24-bit data 8-bit remaining
SD
0 forced
MSB LSB
This mode needs two write or read operations to/from the SPI_DR.
● In transmission mode:
if 0x8EAA33 has to be sent (24-bit):
0x8EAA 0x33XX
Only the 8 MSBs are sent to complete the 24 bits
8 LSB bits have no meaning and could be
anything
● In reception mode:
if data 0x8EAA33 is received:
First read from Data register Second read from Data register
0x8EAA 0x3300
Only the 8MSB are right
The 8 LSB will always be 00
Figure 216. I2S Phillips standard (16-bit extended to 32-bit packet frame with
CPOL = 0)
CK
WS
Transmission Reception
16-bit data 16-bit remaining
SD
0 forced
MSB LSB
When 16-bit data frame extended to 32-bit channel frame is selected during the I2S
configuration phase, only one access to SPI_DR is required. The 16 remaining bits are
forced by hardware to 0x0000 to extend the data to 32-bit format.
If the data to transmit or the received data are 0x76A3 (0x76A30000 extended to 32-bit), the
operation shown in Figure 217 is required.
0X76A3
For transmission, each time an MSB is written to SPI_DR, the TXE flag is set and its
interrupt, if allowed, is generated to load SPI_DR with the new value to send. This takes
place even if 0x0000 have not yet been sent because it is done by hardware.
For reception, the RXNE flag is set and its interrupt, if allowed, is generated when the first
16 MSB half-word is received.
In this way, more time is provided between two write or read operations, which prevents
underrun or overrun conditions (depending on the direction of the data transfer).
Figure 218. MSB Justified 16-bit or 32-bit full-accuracy length with CPOL = 0
CK
WS
Transmission Reception
Channel left
Channel right
Data are latched on the falling edge of CK (for transmitter) and are read on the rising edge
(for the receiver).
CK
WS
Transmission Reception
Figure 220. MSB Justified 16-bit extended to 32-bit packet frame with CPOL = 0
CK
WS
Transmission Reception
CK
WS
Transmission Reception
Channel left
Channel right
CK
WS
Transmission Reception
● In transmission mode:
If data 0x3478AE have to be transmitted, two write operations to the SPI_DR register
are required from software or by DMA. The operations are shown below.
0xXX34 0x78AE
Only the 8 LSB bits of the half-word
are significant. Whatever the 8 MSBs
a field of 0x00 is forced instead
● In reception mode:
If data 0x3478AE are received, two successive read operations from SPI_DR are
required on each RXNE event.
First read from Data register Second read from Data register
conditioned by RXNE = ‘1’ conditioned by RXNE = ‘1’
0x0034 0x78AE
Only the 8 LSB bits of the half-word
are significant. Whatever the 8 MSBs,
a field of 0x00 is forced instead
Figure 225. LSB Justified 16-bit extended to 32-bit packet frame with CPOL = 0
CK
WS
Transmission Reception
When 16-bit data frame extended to 32-bit channel frame is selected during the I2S
configuration phase, Only one access to SPI_DR is required. The 16 remaining bits are
forced by hardware to 0x0000 to extend the data to 32-bit format. In this case it corresponds
to the half-word MSB.
If the data to transmit or the received data are 0x76A3 (0x0000 76A3 extended to 32-bit),
the operation shown in Figure 226 is required.
0X76A3
In transmission mode, when TXE is asserted, the application has to write the data to be
transmitted (in this case 0x76A3). The 0x000 field is transmitted first (extension on 32-bit).
TXE is asserted again as soon as the effective data (0x76A3) is sent on SD.
In reception mode, RXNE is asserted as soon as the significant half-word is received (and
not the 0x0000 field).
In this way, more time is provided between two write or read operations to prevent underrun
or overrun conditions.
PCM standard
For the PCM standard, there is no need to use channel-side information. The two PCM
modes (short and long frame) are available and configurable using the PCMSYNC bit in
SPI_I2SCFGR.
WS
short
frame
up to 13-bit
WS
long
frame
SD 16-bit
MSB LSB MSB
For long frame synchronization, the WS signal assertion time is fixed 13 bits in master
mode.
For short frame synchronization, the WS synchronization signal is only one cycle long.
Figure 228. PCM standard waveforms (16-bit extended to 32-bit packet frame)
CK
WS
short
frame
up to 13-bit
WS
long
frame
SD 16-bit
MSB LSB
Note: For both modes (master and slave) and for both synchronizations (short and long), the
number of bits between two consecutive pieces of data (and so two synchronization signals)
needs to be specified (DATLEN and CHLEN bits in the SPI_I2SCFGR register) even in slave
mode.
32-bits or 64-bits
FS
sampling point
sampling point
When the master mode is configured, a specific action needs to be taken to properly
program the linear divider in order to communicate with the desired audio frequency.
MCK
0 CK
I2SxCLK 8-bit Linear
Divider by 4 Div2 0 1
Divider +
reshaping stage 1
MCKOE
1. Where x could be 2 or 3.
Figure 229 presents the communication clock architecture. the I2SxCLK source is the
system clock (provided by the HSI, the HSE or the PLL and sourcing the AHB clock). For
connectivity line devices, the I2SxCLK source can be either SYSCLK or the PLL3 VCO
clock in order to have maximum accuracy. This selection is made using the I2S2SRC and
I2S3SRC bits in the RCC_CFGR2 register.
The audio sampling frequency may be 96 kHz, 48 kHz, 44.1 kHz, 32 kHz, 22.05 kHz,
16 kHz, 11.025 kHz or 8 kHz (or any other value within this range). In order to reach the
desired frequency, the linear divider needs to be programmed according to the formulas
below:
When the master clock is generated (MCKOE in the SPI_I2SPR register is set):
FS = I2SxCLK / [(16*2)*((2*I2SDIV)+ODD)*8)] when the channel frame is 16-bit wide
FS = I2SxCLK / [(32*2)*((2*I2SDIV)+ODD)*4)] when the channel frame is 32-bit wide
When the master clock is disabled (MCKOE bit cleared):
FS = I2SxCLK / [(16*2)*((2*I2SDIV)+ODD))] when the channel frame is 16-bit wide
FS = I2SxCLK / [(32*2)*((2*I2SDIV)+ODD))] when the channel frame is 32-bit wide
Table 166 and Table 167 provide example precision values for different clock configurations.
Note: Other configurations are possible that allow optimum clock precision.
Table 166. Audio-frequency precision using standard 25 MHz and PLL3 (connectivity line
devices only)
PREDIV2 PLL3 I2SDIV I2SODD Real FS (kHz) Error
Target
MCLK
FS (Hz)
16-bit 32-bit 16-bit 32-bit 16-bit 32-bit 16-bit 32-bit 16-bit 32-bit 16-bit 32-bit
Table 167. Audio-frequency precision using standard 14.7456 MHz and PLL3 (connectivity line
devices only)
PREDIV2 PLL3 I2SDIV I2SODD Real FS (kHz) Error
Target
MCLK
FS (Hz)
16-bit 32-bit 16-bit 32-bit 16-bit 32-bit 16-bit 32-bit 16-bit 32-bit 16-bit 32-bit
Procedure
1. Select the I2SDIV[7:0] bits in the SPI_I2SPR register to define the serial clock baud
rate to reach the proper audio sample frequency. The ODD bit in the SPI_I2SPR
register also has to be defined.
2. Select the CKPOL bit to define the steady level for the communication clock. Set the
MCKOE bit in the SPI_I2SPR register if the master clock MCK needs to be provided to
the external DAC/ADC audio component (the I2SDIV and ODD values should be
computed depending on the state of the MCK output, for more details refer to
Section 23.4.3: Clock generator).
3. Set the I2SMOD bit in SPI_I2SCFGR to activate the I2S functionalities and choose the
I2S standard through the I2SSTD[1:0] and PCMSYNC bits, the data length through the
DATLEN[1:0] bits and the number of bits per channel by configuring the CHLEN bit.
Select also the I2S master mode and direction (Transmitter or Receiver) through the
I2SCFG[1:0] bits in the SPI_I2SCFGR register.
4. If needed, select all the potential interruption sources and the DMA capabilities by
writing the SPI_CR2 register.
5. The I2SE bit in SPI_I2SCFGR register must be set.
WS and CK are configured in output mode. MCK is also an output, if the MCKOE bit in
SPI_I2SPR is set.
Transmission sequence
The transmission sequence begins when a half-word is written into the Tx buffer.
Assumedly, the first data written into the Tx buffer correspond to the channel Left data.
When data are transferred from the Tx buffer to the shift register, TXE is set and data
corresponding to the channel Right have to be written into the Tx buffer. The CHSIDE flag
indicates which channel is to be transmitted. It has a meaning when the TXE flag is set
because the CHSIDE flag is updated when TXE goes high.
A full frame has to be considered as a Left channel data transmission followed by a Right
channel data transmission. It is not possible to have a partial frame where only the left
channel is sent.
The data half-word is parallel loaded into the 16-bit shift register during the first bit
transmission, and then shifted out, serially, to the MOSI/SD pin, MSB first. The TXE flag is
set after each transfer from the Tx buffer to the shift register and an interrupt is generated if
the TXEIE bit in the SPI_CR2 register is set.
For more details about the write operations depending on the I2S standard mode selected,
refer to Section 23.4.2: Supported audio protocols).
To ensure a continuous audio data transmission, it is mandatory to write the SPI_DR with
the next data to transmit before the end of the current transmission.
To switch off the I2S, by clearing I2SE, it is mandatory to wait for TXE = 0 and BSY = 0.
Reception sequence
The operating mode is the same as for the transmission mode except for the point 3, where
the configuration should set the master reception mode through the I2SCFG[1:0] bits.
Whatever the data or channel length, the audio data are received by 16-bit packets. This
means that each time the Rx buffer is full, the RXNE flag is set and an interrupt is generated
if the RXNEIE bit is set in SPI_CR2 register. Depending on the data and channel length
configuration, the audio value received for a right or left channel may result from one or two
receptions into the Rx buffer.
Clearing the RXNE bit is performed by reading the SPI_DR register.
CHSIDE is updated after each reception. It is sensitive to the WS signal generated by the
I2S cell.
For more details about the read operations depending on the I2S standard mode selected,
refer to Section 23.4.2: Supported audio protocols.
If data are received while the precedent received data have not been read yet, an overrun is
generated and the OVR flag is set. If the ERRIE bit is set in the SPI_CR2 register, an
interrupt is generated to indicate the error.
To switch off the I2S in reception mode, I2SE has to be cleared during and before the end of
the last data reception. Even if I2SE is switched off while the last data are being transferred,
the clock and the transfer are maintained until the end of the current data transmission.
Transmission sequence
The transmission sequence begins when a half-word (corresponding to channel Left data) is
written to the Tx buffer. When data are transferred from the Tx buffer to the shift register, the
TXE flag is set and data corresponding to the channel Right have to be written into the Tx
buffer. The CHSIDE flag indicates which channel is to be transmitted. Compared to the
master transmission mode, in slave mode, CHSIDE is sensitive to the WS signal coming
from the external master. This means that the slave needs to be ready to transmit the first
data before the clock is generated by the master. WS assertion corresponds to channel Left
transmitted first.
Note: The I2SE has to be written at least two PCLK cycles before the first clock of the master
comes on the CK line.
The data half-word is parallel-loaded into the 16-bit shift register (from the internal bus)
during the first bit transmission, and then shifted out serially to the MOSI/SD pin MSB first.
The TXE flag is set after each transfer from the Tx buffer to the shift register and an interrupt
is generated if the TXEIE bit in the SPI_CR2 register is set.
Note that the TXE flag should be checked to be at 1 before attempting to write the Tx buffer.
For more details about the write operations depending on the I2S standard mode selected,
refer to Section 23.4.2: Supported audio protocols.
To secure a continuous audio data transmission, it is mandatory to write the SPI_DR
register with the next data to transmit before the end of the current transmission. An
underrun flag is set and an interrupt may be generated if the data are not written into the
SPI_DR register before the first clock edge of the next data communication. This indicates
to the software that the transferred data are wrong. If the ERRIE bit is set into the SPI_CR2
register, an interrupt is generated when the UDR flag in the SPI_SR register goes high. In
this case, it is mandatory to switch off the I2S and to restart a data transfer starting from the
channel left.
Reception sequence
The operating mode is the same as for the transmission mode except for the point 1. where
the configuration should set the master reception mode using the I2SCFG[1:0] bits in the
SPI_I2SCFGR register.
Whatever the data length or the channel length, the audio data are received by 16-bit
packets. This means that each time the RX buffer is full, the RXNE flag in the SPI_SR
register is set and an interrupt is generated if the RXNEIE bit is set in the SPI_CR2 register.
Depending on the data length and channel length configuration, the audio value received for
a right or left channel may result from one or two receptions into the RX buffer.
The CHSIDE flag is updated each time data are received to be read from SPI_DR. It is
sensitive to the external WS line managed by the external master component.
Clearing the RXNE bit is performed by reading the SPI_DR register.
For more details about the read operations depending the I2S standard mode selected, refer
to Section 23.4.2: Supported audio protocols.
If data are received while the precedent received data have not yet been read, an overrun is
generated and the OVR flag is set. If the bit ERRIE is set in the SPI_CR2 register, an
interrupt is generated to indicate the error.
To switch off the I2S in reception mode, I2SE has to be cleared during and before the end of
the last data reception. Even if I2SE is switched off while the last data is being transferred,
the clock and the transfer go on until the end of the last data transmission.
Note: The external master components should have the capability to send/receive data on 16-bit
or 32-bit packet via an audio channel.
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Res. rw rw rw Res. rw rw rw
CRC CHSID
Reserved BSY OVR MODF UDR TXE RXNE
ERR E
Res. r r r rc_w0 r r r r
DR[15:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
CRCPOLY[15:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
RxCRC[15:0]
r r r r r r r r r r r r r r r r
TxCRC[15:0]
r r r r r r r r r r r r r r r r
PCMSY
I2SMOD I2SE I2SCFG I2SSTD CKPOL DATLEN CHLEN
NC
Reserved Reserved
rw rw rw rw rw rw rw rw rw rw rw
Res. rw rw rw
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
BIDIMODE
CRCNEXT
LSBFIRST
RXONLY
CRCEN
BIDIOE
MSTR
CPHA
CPOL
SSM
SPE
DFF
SSI
SPI_CR1 BR [2:0]
0x00 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RXDMAEN
TXDMAEN
RXNEIE
ERRIE
Reserved
TXEIE
SSOE
SPI_CR2
0x04 Reserved
Reset value 0 0 0 0 0 0
CRCERR
CHSIDE
MODF
RXNE
UDR
OVR
BSY
TXE
SPI_SR
0x08 Reserved
Reset value 0 0 0 0 0 0 1 0
SPI_DR DR[15:0]
0x0C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SPI_CRCPR CRCPOLY[15:0]
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
SPI_RXCRCR RxCRC[15:0]
0x14 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SPI_TXCRCR TxCRC[15:0]
0x18 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PCMSYNC
I2SMOD
DATLEN
I2SCFG
I2SSTD
CKPOL
CHLEN
Reserved
I2SE
SPI_I2SCFGR
0x1C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0
MCKOE
0x20
SPI_I2SPR
Reserved ODD I2SDIV
Reset value 0 0 0 0 0 0 0 0 1 0
● Error flags:
– Arbitration lost condition for master mode
– Acknowledgement failure after address/ data transmission
– Detection of misplaced start or stop condition
– Overrun/Underrun if clock stretching is disabled
● 2 Interrupt vectors:
– 1 Interrupt for successful address/ data communication
– 1 Interrupt for error condition
● Optional Clock Stretching
● 1-byte buffer with DMA capability
● Configurable PEC (Packet Error Checking) Generation or Verification:
– PEC value can be transmitted as last byte in Tx mode
– PEC error checking for last received byte
● SMBus 2.0 Compatibility:
– 25 ms clock low timeout delay
– 10 ms master cumulative clock low extend time
– 25 ms slave cumulative clock low extend time
– Hardware PEC generation/verification with ACK control
– Address Resolution Protocol (ARP) supported
● PMBus Compatibility
Note: Some of the above features may not be available in certain products. The user should refer
to the product data sheet, to identify the specific features supported by the I2C interface
implementation.
Communication flow
In Master mode, the I2C interface initiates a data transfer and generates the clock signal. A
serial data transfer always begins with a start condition and ends with a stop condition. Both
start and stop conditions are generated in master mode by software.
In Slave mode, the interface is capable of recognizing its own addresses (7 or 10-bit), and
the General Call address. The General Call address detection may be enabled or disabled
by software.
Data and addresses are transferred as 8-bit bytes, MSB first. The first byte(s) following the
start condition contain the address (one in 7-bit mode, two in 10-bit mode). The address is
always transmitted in Master mode.
A 9th clock pulse follows the 8 clock cycles of a byte transfer, during which the receiver must
send an acknowledge bit to the transmitter. Refer to the following figure.
SDA
MSB ACK
SCL
1 2 8 9
Start Stop
condition condition
Acknowledge may be enabled or disabled by software. The I2C interface addresses (dual
addressing 7-bit/ 10-bit and/or general call address) can be selected by software.
The block diagram of the I2C interface is shown in Figure 232.
DATA REGISTER
DATA
SDA CONTROL DATA SHIFT REGISTER
CLOCK CONTROL
REGISTER (CCR)
CONTROL REGISTERS
(CR1&CR2)
CONTROL
STATUS REGISTERS LOGIC
(SR1&SR2)
SMBALERT
Note: SMBALERT is an optional signal in SMBus mode. This signal is not applicable if
SMBus is disabled.
Header matched (10-bit mode only): the interface generates an acknowledge pulse if the
ACK bit is set and waits for the 8-bit slave address.
Address matched: the interface generates in sequence:
● An acknowledge pulse if the ACK bit is set
● The ADDR bit is set by hardware and an interrupt is generated if the ITEVFEN bit is
set.
● If ENDUAL=1, the software has to read the DUALF bit to check which slave address
has been acknowledged.
In 10-bit mode, after receiving the address sequence the slave is always in Receiver mode.
It will enter Transmitter mode on receiving a repeated Start condition followed by the header
sequence with matching address bits and the least significant bit set (11110xx1).
The TRA bit indicates whether the slave is in Receiver or Transmitter mode.
Slave transmitter
Following the address reception and after clearing ADDR, the slave sends bytes from the
DR register to the SDA line via the internal shift register.
The slave stretches SCL low until ADDR is cleared and DR filled with the data to be sent
(see Figure 233 Transfer sequencing EV1 EV3).
When the acknowledge pulse is received:
● The TxE bit is set by hardware with an interrupt if the ITEVFEN and the ITBUFEN bits
are set.
If TxE is set and some data were not written in the I2C_DR register before the end of the
next data transmission, the BTF bit is set and the interface waits until BTF is cleared by a
read to I2C_SR1 followed by a write to the I2C_DR register, stretching SCL low.
Slave receiver
Following the address reception and after clearing ADDR, the slave receives bytes from the
SDA line into the DR register via the internal shift register. After each byte the interface
generates in sequence:
● An acknowledge pulse if the ACK bit is set
● The RxNE bit is set by hardware and an interrupt is generated if the ITEVFEN and
ITBUFEN bit is set.
If RxNE is set and the data in the DR register is not read before the end of the next data
reception, the BTF bit is set and the interface waits until BTF is cleared by a read from
I2C_SR1 followed by a read from the I2C_DR register, stretching SCL low (see Figure 234
Transfer sequencing).
Start condition
Setting the START bit causes the interface to generate a Start condition and to switch to
Master mode (M/SL bit set) when the BUSY bit is cleared.
Note: In master mode, setting the START bit causes the interface to generate a ReStart condition
at the end of the current byte transfer.
Once the Start condition is sent:
● The SB bit is set by hardware and an interrupt is generated if the ITEVFEN bit is set.
Then the master waits for a read of the SR1 register followed by a write in the DR register
with the Slave address (see Figure 235 & Figure 236 Transfer sequencing EV5).
Master transmitter
Following the address transmission and after clearing ADDR, the master sends bytes from
the DR register to the SDA line via the internal shift register.
The master waits until the first data byte is written into I2C_DR (see Figure 235 Transfer
sequencing EV8_1).
When the acknowledge pulse is received:
● The TxE bit is set by hardware and an interrupt is generated if the ITEVFEN and
ITBUFEN bits are set.
If TxE is set and a data byte was not written in the DR register before the end of the last data
transmission, BTF is set and the interface waits until BTF is cleared by a read from I2C_SR1
followed by a write to I2C_DR, stretching SCL low.
%6 3" CLEARED BY READING 32 REGISTER FOLLOWED BY WRITING $2 REGISTER WITH !DDRESS
%6 !$$2 CLEARED BY READING 32 REGISTER FOLLOWED BY READING 32
%6? 4X% SHIFT REGISTER EMPTY DATA REGISTER EMPTY WRITE $2
%6 4X% SHIFT REGISTER NOT EMPTY DATA REGISTER EMPTY CLEARED BY WRITING $2 REGISTER
%6? 4X% "4& 0ROGRAM 3TOP REQUEST 4X% AND "4& ARE CLEARED BY HARDWARE BY THE 3TOP CONDITION
%6 !$$ CLEARED BY READING 32 REGISTER FOLLOWED BY WRITING $2 REGISTER
.OTES 4HE %6 %6 %6 %6? AND %6? EVENTS STRETCH 3#, LOW UNTIL THE END OF THE CORRESPONDING SOFTWARE SEQUENCE
4HE %6 SOFTWARE SEQUENCE MUST COMPLETE BEFORE THE END OF THE CURRENT BYTE TRANSFER
AI
Master receiver
Following the address transmission and after clearing ADDR, the I2C interface enters
Master Receiver mode. In this mode the interface receives bytes from the SDA line into the
DR register via the internal shift register. After each byte the interface generates in
sequence:
● An acknowledge pulse if the ACK bit is set
● The RxNE bit is set and an interrupt is generated if the ITEVFEN and ITBUFEN bits are
set (see Figure 236 Transfer sequencing EV7).
If the RxNE bit is set and the data in the DR register is not read before the end of the last
data reception, the BTF bit is set by hardware and the interface waits until BTF is cleared by
a read in the SR1 register followed by a read in the DR register, stretching SCL low.
24.3.6 SMBus
Introduction
The System Management Bus (SMBus) is a two-wire interface through which various
devices can communicate with each other and with the rest of the system. It is based on I2C
principles of operation. SMBus provides a control bus for system and power management
related tasks. A system may use SMBus to pass messages to and from devices instead of
toggling individual control lines.
The System Management Bus Specification refers to three types of devices. A slave is a
device that is receiving or responding to a command. A master is a device that issues
commands, generates the clocks, and terminates the transfer. A host is a specialized master
that provides the main interface to the system's CPU. A host must be a master-slave and
must support the SMBus host notify protocol. Only one host is allowed in a system.
Device identification
Any device that exists on the System Management Bus as a slave has a unique address
called the Slave Address. For the list of reserved slave addresses, refer to the SMBus
specification ver. 2.0 (http://smbus.org/specs/).
Bus protocols
The SMBus specification supports up to 9 bus protocols. For more details of these protocols
and SMBus address types, refer to SMBus specification ver. 2.0 (http://smbus.org/specs/).
These protocols should be implemented by the user software.
A slave-only device can signal the host through SMBALERT that it wants to talk by setting
ALERT bit in I2C_CR1 register. The host processes the interrupt and simultaneously
accesses all SMBALERT devices through the Alert Response Address (known as ARA
having a value 0001 100X). Only the device(s) which pulled SMBALERT low will
acknowledge the Alert Response Address. This status is identified using SMBALERT Status
flag in I2C_SR1 register. The host performs a modified Receive Byte operation. The 7 bit
device address provided by the slave transmit device is placed in the 7 most significant bits
of the byte. The eighth bit can be a zero or one.
If more than one device pulls SMBALERT low, the highest priority (lowest address) device
will win communication rights via standard arbitration during the slave address transfer. After
acknowledging the slave address the device must disengage its SMBALERT pull-down. If
the host still sees SMBALERT low when the message transfer is complete, it knows to read
the ARA again.
A host which does not implement the SMBALERT signal may periodically access the ARA.
For more details on SMBus Alert mode, refer to SMBus specification ver. 2.0
(http://smbus.org/specs/).
Timeout error
There are differences in the timing specifications between I2C and SMBus.
SMBus defines a clock low timeout, TIMEOUT of 35 ms. Also SMBus specifies TLOW:
SEXT as the cumulative clock low extend time for a slave device. SMBus specifies TLOW:
MEXT as the cumulative clock low extend time for a master device. For more details on
these timeouts, refer to SMBus specification ver. 2.0 (http://smbus.org/specs/).
The status flag Timeout or Tlow Error in I2C_SR1 shows the status of this feature.
corresponding DMA channel is reached, the DMA controller sends an End of Transfer EOT
signal to the I2C interface and generates a Transfer Complete interrupt if enabled:
● Master transmitter: In the interrupt routine after the EOT interrupt, disable DMA
requests then wait for a BTF event before programming the Stop condition.
● Master receiver: when the number of bytes to be received is equal to or greater than
two, the DMA controller sends a hardware signal, EOT_1, corresponding to the last but
one data byte (number_of_bytes – 1). If, in the I2C_CR2 register, the LAST bit is set,
I2C automatically sends a NACK after the next byte following EOT_1. The user can
generate a Stop condition in the DMA Transfer Complete interrupt routine if enabled.
When the number of data transfers which has been programmed in the DMA Controller
registers is reached, the DMA controller sends an End of Transfer EOT/ EOT_1 signal to the
I2C interface and DMA generates an interrupt, if enabled, on the DMA channel interrupt
vector.
Note: Do not enable the ITBUFEN bit in the I2C_CR2 register if DMA is used for reception.
Note: 1 SB, ADDR, ADD10, STOPF, BTF, RxNE and TxE are logically ORed on the same interrupt
channel.
2 BERR, ARLO, AF, OVR, PECERR, TIMEOUT and SMBALERT are logically ORed on the
same interrupt channel.
ITEVFEN
SB
ADDR
ADD10
STOPF
it_event
BTF
TxE
ITBUFEN
RxNE
ITERREN
BERR
ARLO
it_error
AF
OVR
PECERR
TIMEOUT
SMBAlert
SW NO EN EN SMB SM
ALERT PEC POS ACK STOP START ENGC PE
RST Res. STRETCH PEC ARP TYPE Res. BUS
rw rw rw rw rw rw rw rw rw rw rw rw rw rw
ADD
ADD[9:8] ADD[7:1] ADD0
MODE Res. Reserved
rw rw rw rw rw rw rw rw rw rw rw
ADD2[7:1] ENDUAL
Reserved
rw rw rw rw rw rw rw rw
DR[7:0]
Reserved
rw rw rw rw rw rw rw rw
SMB
SMB GEN
PEC[7:0] DUALF DEF Res. TRA BUSY MSL
HOST CALL
AULT
r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Bits 11:0 CCR[11:0]: Clock control register in Fast/Standard mode (Master mode)
Controls the SCL clock in master mode.
Standard mode or SMBus:
Thigh = CCR * TPCLK1
Tow = CCR * TPCLK1
Fast mode:
If DUTY = 0:
Thigh = CCR * TPCLK1
Tow = 2 * CCR * TPCLK1
If DUTY = 1: (to reach 400 kHz)
Thigh = 9 * CCR * TPCLK1
Tow = 16 * CCR * TPCLK1
For instance: in standard mode, to generate a 100 kHz SCL frequency:
If FREQR = 08, TPCLK1 = 125 ns so CCR must be programmed with 0x28
(0x28 <=> 40d x 125 ns = 5000 ns.)
Note: 1. The minimum allowed value is 0x04, except in FAST DUTY mode where the
minimum allowed value is 0x01
2. thigh includes the SCLH rising edge
3. tlow includes the SCLH falling edge
4. These timings are without filters.
5. The CCR register must be configured only when the I2C is disabled (PE = 0).
6. fCK = a multiple of 10 MHz is required to generate the fast clock at 400 kHz.
Reserved TRISE[5:0]
Res. rw rw rw rw rw rw
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
NOSTRETCH
SMBTYPE
SWRST
SMBUS
ENPEC
ENARP
ALERT
START
Reserved
Reserved
ENGC
STOP
POS
PEC
ACK
PE
I2C_CR1
0x00 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ITERREN
ITBUFEN
ITEVTEN
DMAEN
Reserved
LAST
I2C_CR2 FREQ[5:0]
0x04 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0
ADDMODE
Reserved
ADD0
I2C_OAR1 ADD[9:8] ADD[7:1]
0x08 Reserved Reserved
Reset value 0 1 0 0 0 0 0 0 0 0 0 0
ENDUAL
I2C_OAR2 ADD2[7:1]
0x0C Reserved
Reset value 0 0 0 0 0 0 0 0
I2C_DR DR[7:0]
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0
SMBALERT
TIMEOUT
PECERR
STOPF
ADD10
Reserved
Reserved
ADDR
BERR
ARLO
RxNE
OVR
BTF
TxE
SB
AF
I2C_SR1
0x14 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SMBDEFAULT
SMBHOST
GENCALL
DUALF
Reserved
BUSY
MSL
TRA
I2C_SR2 PEC[7:0]
0x18 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Reserved
DUTY
F/S
I2C_CCR CCR[11:0]
0x1C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0
I2C_TRISE TRISE[5:0]
0x20 Reserved
Reset value 0 0 0 0 1 0
Through these pins, serial data is transmitted and received in normal USART mode as
frames comprising:
● An Idle Line prior to transmission or reception
● A start bit
● A data word (8 or 9 bits) least significant bit first
● 0.5,1, 1.5, 2 Stop bits indicating that the frame is complete
● This interface uses a fractional baud rate generator - with a 12-bit mantissa and 4-bit
fraction
● A status register (USART_SR)
● Data Register (USART_DR)
● A baud rate register (USART_BRR) - 12-bit mantissa and 4-bit fraction.
● A Guardtime Register (USART_GTPR) in case of Smartcard mode.
Refer to Section 25.6: USART registers on page 683 for the definitions of each bit.
The following pin is required to interface in synchronous mode:
● SCLK: Transmitter clock output. This pin outputs the transmitter data clock for
synchronous transmission corresponding to SPI master mode (no clock pulses on start
bit and stop bit, and a software option to send a clock pulse on the last data bit). In
parallel data can be received synchronously on RX. This can be used to control
peripherals that have shift registers (e.g. LCD drivers). The clock phase and polarity
are software programmable. In smartcard mode, SCLK can provide the clock to the
smartcard.
The following pins are required to interface in IrDA mode:
● IrDA_RDI: Receive Data Input is the data input in IrDA mode.
● IrDA_TDO: Transmit Data Output in IrDA mode.
the following pins are required in Hardware flow control mode:
● nCTS: Clear To Send blocks the data transmission at the end of the current transfer
when high
● nRTS: Request to send indicates that the USART is ready to receive a data (when
low).
PWDATA PRDATA
Write Read (DATA REGISTER) DR
RX IrDA
SIR
SW_RX ENDEC Receive Shift Register
Transmit Shift Register
BLOCK
IRDA_OUT
IRDA_IN GTPR
GT PSC SCLK CONTROL SCLK
CR3 CR2
DMAT DMAR SCEN NACK HD IRLP IREN LINE STOP[1:0] CKEN CPOL CPHA LBCL
CR2 CR1
USART Address UE M WAKE PCE PS PEIE
nRTS Hardware
flow
nCTS controller
WAKE RECEIVER
TRANSMIT UP RECEIVER CLOCK
CONTROL UNIT CONTROL
CR1 SR
TXEIE TCIE RXNE
IE
IDLE TE RE RWU SBK CTS LBD TXE TC RXNE IDLE ORE NE FE PE
IE
USART
INTERRUPT
CONTROL
USART_BRR
TE TRANSMITTER RATE
TRANSMITTER
CONTROL
CLOCK
/16 /USARTDIV
DIV_Mantissa DIV_Fraction
15 4 0
fPCLKx(x=1,2)
RECEIVER RATE
RE CONTROL
CONVENTIONAL BAUD RATE GENERATOR
Start
Idle frame bit
Start
Idle frame bit
25.3.2 Transmitter
The transmitter can send data words of either 8 or 9 bits depending on the M bit status.
When the transmit enable bit (TE) is set, the data in the transmit shift register is output on
the TX pin and the corresponding clock pulses are output on the SCLK pin.
Character transmission
During an USART transmission, data shifts out least significant bit first on the TX pin. In this
mode, the USART_DR register consists of a buffer (TDR) between the internal bus and the
transmit shift register (see Figure 238).
Every character is preceded by a start bit which is a logic level low for one bit period. The
character is terminated by a configurable number of stop bits.
The following stop bits are supported by USART: 0.5, 1, 1.5 and 2 stop bits.
Note: 1 The TE bit should not be reset during transmission of data. Resetting the TE bit during the
transmission will corrupt the data on the TX pin as the baud rate counters will get frozen.
The current data being transmitted will be lost.
2 An idle frame will be sent after the TE bit is enabled.
a) 1 Stop Bit
Possible Next Data Frame
Parity
Data Frame
Bit Next
Start Start
Bit Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit
1 1/2 stop bits
b) 1 1/2 stop Bits
Possible Next Data Frame
Parity
Data Frame
Bit Next
Start 2 Stop Start
Bit Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bits Bit
Procedure:
1. Enable the USART by writing the UE bit in USART_CR1 register to 1.
2. Program the M bit in USART_CR1 to define the word length.
3. Program the number of stop bits in USART_CR2.
4. Select DMA enable (DMAT) in USART_CR3 if Multi buffer Communication is to take
place. Configure the DMA register as explained in multibuffer communication.
5. Select the desired baud rate using the USART_BRR register.
6. Set the TE bit in USART_CR1 to send an idle frame as first transmission.
7. Write the data to send in the USART_DR register (this clears the TXE bit). Repeat this
for each data to be transmitted in case of single buffer.
8. After writing the last data into the USART_DR register, wait until TC=1. This indicates
that the transmission of the last frame is complete. This is required for instance when
the USART is disabled or enters the Halt mode to avoid corrupting the last
transmission.
When a transmission is taking place, a write instruction to the USART_DR register stores
the data in the TDR register and which is copied in the shift register at the end of the current
transmission.
When no transmission is taking place, a write instruction to the USART_DR register places
the data directly in the shift register, the data transmission starts, and the TXE bit is
immediately set.
If a frame is transmitted (after the stop bit) and the TXE bit is set, the TC bit goes high. An
interrupt is generated if the TCIE bit is set in the USART_CR1 register.
After writing the last data into the USART_DR register, it is mandatory to wait for TC=1
before disabling the USART or causing the microcontroller to enter the low power mode (see
Figure 241: TC/TXE behavior when transmitting).
Clearing the TC bit is performed by the following software sequence:
1. A read from the USART_SR register
2. A write to the USART_DR register
TX LINE
set by hardware set by hardware
flag TXE cleared by software cleared by software set by hardware
USART_DR F2 F3
set by
flag TC hardware
software waits until TXE=1 software waits until TXE=1 software waits until TXE=1 software wait
and writes F2 into and writes F3 into and writes F3 into until TC=1
USART_DR USART_DR USART_DR
ai17121
1. This example assumes that several other transmissions occured since TE was set. Otherwise, if
USART_DR had been written for the first time, an IDLE preamble would have been transmitted first.
Note: The TC bit can also be cleared by writing a ‘0’ to it. This clearing sequence is recommended
only for Multibuffer communication.
Break characters
Setting the SBK bit transmits a break character. The break frame length depends on the M
bit (see Figure 239).
If the SBK bit is set to ‘1’ a break character is sent on the TX line after completing the current
character transmission. This bit is reset by hardware when the break character is completed
(during the stop bit of the break character). The USART inserts a logic 1 bit at the end of the
last break frame to guarantee the recognition of the start bit of the next frame.
Note: If the software resets the SBK bit before the commencement of break transmission, the
break character will not be transmitted. For two consecutive breaks, the SBK bit should be
set after the stop bit of the previous break.
Idle characters
Setting the TE bit drives the USART to send an idle frame before the first data frame.
25.3.3 Receiver
The USART can receive data words of either 8 or 9 bits depending on the M bit in the
USART_CR1 register.
RX line
Ideal
sample
clock 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
sampled values
Real
sample X X X X X X X X 9 10 11 12 13 14 15 16
clock
6/16
7/16 7/16
One-bit time
Conditions
to validate 1 1 1 0 X 0 X 0 X 0 0 0 0 X X X X X X
the start bit
Falling edge At least 2 bits At least 2 bits
detection out of 3 at 0 out of 3 at 0 ai15471
Note: If the sequence is not complete, the start bit detection aborts and the receiver returns to idle
state (no flag is set) waiting for a falling edge.
If only 2 out of the 3 bits are at 0 (sampling on the 3rd, 5th and 7th bits or sampling on the 8th,
9th and 10th bits), the start bit is validated but the NE noise flag bit is set.
The start bit is confirmed if the last 3 samples are at 0 (sampling on the 8th, 9th, and 10th
bits.
Character reception
During an USART reception, data shifts in least significant bit first through the RX pin. In this
mode, the USART_DR register consists of a buffer (RDR) between the internal bus and the
received shift register.
Procedure:
Break character
When a break character is received, the USART handles it as a framing error.
Idle character
When an idle frame is detected, there is the same procedure as a data received character
plus an interrupt if the IDLEIE bit is set.
Overrun error
An overrun error occurs when a character is received when RXNE has not been reset. Data
can not be transferred from the shift register to the RDR register until the RXNE bit is
cleared.
The RXNE flag is set after every byte received. An overrun error occurs if RXNE flag is set
when the next data is received or the previous DMA request has not been serviced. When
an overrun error occurs:
● The ORE bit is set.
● The RDR content will not be lost. The previous data is available when a read to
USART_DR is performed.
● The shift register will be overwritten. After that point, any data received during overrun
is lost.
● An interrupt is generated if either the RXNEIE bit is set or both the EIE and DMAR bits
are set.
● The ORE bit is reset by a read to the USART_SR register followed by a USART_DR
register read operation.
Note: The ORE bit, when set, indicates that at least 1 data has been lost. There are two
possibilities:
● if RXNE=1, then the last valid data is stored in the receive register RDR and can be
read,
● if RXNE=0, then it means that the last valid data has already been read and thus there
is nothing to be read in the RDR. This case can occur when the last valid data is read in
the RDR at the same time as the new (and lost) data is received. It may also occur
when the new data is received during the reading sequence (between the USART_SR
register read access and the USART_DR read access).
Noise error
Over-sampling techniques are used (except in synchronous mode) for data recovery by
discriminating between valid incoming data and noise.
RX LINE
sampled values
Sample
clock 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
6/16
7/16 7/16
One bit time
Framing error
A framing error is detected when:
The stop bit is not recognized on reception at the expected time, following either a de-
synchronization or excessive noise.
When the framing error is detected:
● The FE bit is set by hardware
● The invalid data is transferred from the Shift register to the USART_DR register.
● No interrupt is generated in case of single byte communication. However this bit rises
at the same time as the RXNE bit which itself generates an interrupt. In case of
multibuffer communication an interrupt will be issued if the EIE bit is set in the
USART_CR3 register.
The FE bit is reset by a USART_SR register read operation followed by a USART_DR
register read operation.
baud clock period during which nothing happens, followed by 1 normal stop bit period
during which sampling occurs halfway through. Refer to Section 25.3.11: Smartcard on
page 675 for more details.
4. 2 stop bits: Sampling for 2 stop bits is done on the 8th, 9th and 10th samples of the
first stop bit. If a framing error is detected during the first stop bit the framing error flag
will be set. The second stop bit is not checked for framing error. The RXNE flag will be
set at the end of the first stop bit.
USARTDIV is an unsigned fixed point number that is coded on the USART_BRR register.
Note: The baud counters are updated with the new value of the Baud registers after a write to
USART_BRR. Hence the Baud rate register value should not be changed during
communication.
Example 2:
To program USARTDIV = 0d25.62
This leads to:
DIV_Fraction = 16*0d0.62 = 0d9.92
The nearest real number is 0d10 = 0xA
DIV_Mantissa = mantissa (0d25.620) = 0d25 = 0x19
Then, USART_BRR = 0x19A hence USARTDIV = 0d25.625
Example 3:
To program USARTDIV = 0d50.99
This leads to:
DIV_Fraction = 16*0d0.99 = 0d15.84
The nearest real number is 0d16 = 0x10 => overflow of DIV_frac[3:0] => carry must be
added up to the mantissa
DIV_Mantissa = mantissa (0d50.990 + carry) = 0d51 = 0x33
Then, USART_BRR = 0x330 hence USARTDIV = 0d51.000
Note: 1 The lower the CPU clock the lower will be the accuracy for a particular Baud rate. The upper
limit of the achievable baud rate can be fixed with this data.
2 Only USART1 is clocked with PCLK2 (72 MHz Max). Other USARTs are clocked with
PCLK1 (36 MHz Max).
The USART receiver’s tolerance to properly receive data is equal to the maximum tolerated
deviation and depends on the following choices:
● 10- or 11-bit character length defined by the M bit in the USART_CR1 register
● use of fractional baud rate or not
Note: The figures specified in Table 175 and Table 176 may slighly differ in the special case when
the received frames contain some Idle frames of exactly 10-bit times when M=0 (11-bit times
when M=1).
RXNE RXNE
RX IDLE Addr=0 Data 1 Data 2 IDLE Addr=1 Data 3 Data 4 Addr=2 Data 5
RWU written to 1
(RXNE was cleared)
Note: In case of wake up by an address mark, the MSB bit of the data is taken into account and
not the parity bit
Even parity: the parity bit is calculated to obtain an even number of “1s” inside the frame
made of the 7 or 8 LSB bits (depending on whether M is equal to 0 or 1) and the parity bit.
Ex: data=00110101; 4 bits set => parity bit will be 0 if even parity is selected (PS bit in
USART_CR1 = 0).
Odd parity: the parity bit is calculated to obtain an odd number of “1s” inside the frame
made of the 7 or 8 LSB bits (depending on whether M is equal to 0 or 1) and the parity bit.
Ex: data=00110101; 4 bits set => parity bit will be 1 if odd parity is selected (PS bit in
USART_CR1 = 1).
Transmission mode: If the PCE bit is set in USART_CR1, then the MSB bit of the data
written in the data register is transmitted but is changed by the parity bit (even number of
“1s” if even parity is selected (PS=0) or an odd number of “1s” if odd parity is selected
(PS=1)). If the parity check fails, the PE flag is set in the USART_SR register and an
interrupt is generated if PEIE is set in the USART_CR1 register.
LIN transmission
The same procedure explained in Section 25.3.2 has to be applied for LIN Master
transmission than for normal USART transmission with the following differences:
● Clear the M bit to configure 8-bit word length.
● Set the LINEN bit to enter LIN mode. In this case, setting the SBK bit sends 13 ‘0’ bits
as a break character. Then a bit of value ‘1’ is sent to allow the next start detection.
LIN reception
When the LIN mode is enabled, the break detection circuit is activated. The detection is
totally independent from the normal USART receiver. A break can be detected whenever it
occurs, during idle state or during a frame.
When the receiver is enabled (RE=1 in USART_CR1), the circuit looks at the RX input for a
start signal. The method for detecting start bits is the same when searching break
characters or data. After a start bit has been detected, the circuit samples the next bits
exactly like for the data (on the 8th, 9th and 10th samples). If 10 (when the LBDL = 0 in
USART_CR2) or 11 (when LBDL=1 in USART_CR2) consecutive bits are detected as ‘0’,
and are followed by a delimiter character, the LBD flag is set in USART_SR. If the LBDIE
bit=1, an interrupt is generated. Before validating the break, the delimiter is checked for as it
signifies that the RX line has returned to a high level.
If a ‘1’ is sampled before the 10 or 11 have occurred, the break detection circuit cancels the
current detection and searches for a start bit again.
If the LIN mode is disabled (LINEN=0), the receiver continues working as normal USART,
without taking into account the break detection.
If the LIN mode is enabled (LINEN=1), as soon as a framing error occurs (i.e. stop bit
detected at ‘0’, which will be the case for any break frame), the receiver stops until the break
detection circuit receives either a ‘1’, if the break word was not complete, or a delimiter
character if a break has been detected.
The behavior of the break detector state machine and the break flag is shown on the
Figure 246: Break detection in LIN mode (11-bit break length - LBDL bit is set) on page 671.
Examples of break frames are given on Figure 247: Break detection in LIN mode vs.
Framing error detection on page 672.
Figure 246. Break detection in LIN mode (11-bit break length - LBDL bit is set)
Case 1: break signal not long enough => break discarded, LBD is not set
Capture Strobe
Break State machine Idle Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit8 Bit9 Bit10 Idle
Read Samples 0 0 0 0 0 0 0 0 0 0 1
Case 2: break signal just long enough => break detected, LBD is set
Capture Strobe
delimiter is immediate
Break State machine Idle Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit8 Bit9 B10 Idle
Read Samples 0 0 0 0 0 0 0 0 0 0 0
LBD
Case 3: break signal long enough => break detected, LBD is set
Capture Strobe
Break State machine Idle Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit8 Bit9 Bit10 wait delimiter Idle
Read Samples 0 0 0 0 0 0 0 0 0 0 0
LBD
Figure 247. Break detection in LIN mode vs. Framing error detection
In these examples, we suppose that LBDL=1 (11-bit break length), M=0 (8-bit data)
RXNE / FE
LBD
RXNE / FE
LBD
3 It is advised that TE and RE are set in the same instruction in order to minimize the setup
and the hold time of the receiver.
4 The USART supports master mode only: it cannot receive or send data related to an input
clock (SCLK is always an output).
RX Data out
TX Data in
SCLK Clock
Data on TX 0 1 2 3 4 5 6 7
(from master)
Start LSB MSB Stop
Data on RX 0 1 2 3 4 5 6 7
(from slave)
LSB MSB
*
Capture Strobe
Data on TX 0 1 2 3 4 5 6 7 8
(from master)
Start LSB MSB Stop
Data on RX 0 1 2 3 4 5 6 7 8
(from slave)
LSB MSB
*
Capture Strobe
tSETUP tHOLD
Note: The function of SCLK is different in Smartcard mode. Refer to the Smartcard mode chapter
for more details.
Apart from this, the communications are similar to what is done in normal USART mode.
The conflicts on the line must be managed by the software (by the use of a centralized
arbiter, for instance). In particular, the transmission is never blocked by hardware and
continue to occur as soon as a data is written in the data register while the TE bit is set.
25.3.11 Smartcard
The Smartcard mode is selected by setting the SCEN bit in the USART_CR3 register. In
smartcard mode, the following bits must be kept cleared:
● LINEN bit in the USART_CR2 register,
● HDSEL and IREN bits in the USART_CR3 register.
Moreover, the CLKEN bit may be set in order to provide a clock to the smartcard.
The Smartcard interface is designed to support asynchronous protocol Smartcards as
defined in the ISO 7816-3 standard. The USART should be configured as:
● 8 bits plus parity: where M=1 and PCE=1 in the USART_CR1 register
● 1.5 stop bits when transmitting and receiving : where STOP=’11’ in the USART_CR2
register.
Note: It is also possible to choose 0.5 stop bit for receiving but it is recommended to use 1.5 stop
bits for both transmitting and receiving to avoid switching between the two configurations.
Figure 252 shows examples of what can be seen on the data line with and without parity
error.
S 0 1 2 3 4 5 6 7 P
Start
bit
S 0 1 2 3 4 5 6 7 P
When connected to a smartcard, the TX output of the USART drives a bidirectional line that
the smartcard also drives into. To do so, SW_RX must be connected on the same I/O than
TX at product level. The Transmitter output enable TX_EN is asserted during the
transmission of the start bit and the data byte, and is deasserted during the stop bit (weak
pull up), so that the receive can drive the line in case of a parity error. If TX_EN is not used,
TX is driven at high level during the stop bit: Thus the receiver can drive the line as long as
TX is configured in open-drain.
Smartcard is a single wire half duplex communication protocol.
● Transmission of data from the transmit shift register is guaranteed to be delayed by a
minimum of 1/2 baud clock. In normal operation a full transmit shift register will start
shifting on the next baud clock edge. In Smartcard mode this transmission is further
delayed by a guaranteed 1/2 baud clock.
● If a parity error is detected during reception of a frame programmed with a 0.5 or 1.5
stop bit period, the transmit line is pulled low for a baud clock period after the
completion of the receive frame. This is to indicate to the Smartcard that the data
transmitted to USART has not been correctly received. This NACK signal (pulling
transmit line low for 1 baud clock) will cause a framing error on the transmitter side
(configured with 1.5 stop bits). The application can handle re-sending of data according
to the protocol. A parity error is ‘NACK’ed by the receiver if the NACK control bit is set,
otherwise a NACK is not transmitted.
● The assertion of the TC flag can be delayed by programming the Guard Time register.
In normal operation, TC is asserted when the transmit shift register is empty and no
further transmit requests are outstanding. In Smartcard mode an empty transmit shift
register triggers the guard time counter to count up to the programmed value in the
Guard Time register. TC is forced low during this time. When the guard time counter
reaches the programmed value TC is asserted high.
● The de-assertion of TC flag is unaffected by Smartcard mode.
● If a framing error is detected on the transmitter end (due to a NACK from the receiver),
the NACK will not be detected as a start bit by the receive block of the transmitter.
According to the ISO protocol, the duration of the received NACK can be 1 or 2 baud
clock periods.
● On the receiver side, if a parity error is detected and a NACK is transmitted the receiver
will not detect the NACK as a start bit.
Note: 1 A break character is not significant in Smartcard mode. A 0x00 data with a framing error will
be treated as data and not as a break.
2 No IDLE frame is transmitted when toggling the TE bit. The IDLE frame (as defined for the
other configurations) is not defined by the ISO protocol.
Figure 253 details how the NACK signal is sampled by the USART. In this example the
USART is transmitting a data and is configured with 1.5 stop bits. The receiver part of the
USART is enabled in order to check the integrity of the data and the NACK signal.
Figure 253. Parity error detection using the 1.5 stop bits
sampling at sampling at
8th, 9th, 10th 16th, 17th, 18th
sampling at sampling at
8th, 9th, 10th 8th, 9th, 10th
The USART can provide a clock to the smartcard through the SCLK output. In smartcard
mode, SCLK is not associated to the communication but is simply derived from the internal
peripheral input clock through a 5-bit prescaler. The division ratio is configured in the
prescaler register USART_GTPR. SCLK frequency can be programmed from fCK/2 to
fCK/62, where fCK is the peripheral input clock.
TX
OR USART_TX
SIR
Transmit IrDA_OUT
SIREN Encoder
USART
SIR
RX Receive IrDA_IN
Decoder
USART_RX
IrDA_OUT
3/16
IrDA_IN
RX 0 1
0 1 0 1 0 0 1 1
When the number of data transfers programmed in the DMA Controller is reached, the DMA
controller generates an interrupt on the DMA channel interrupt vector. The DMAR bit should
be cleared by software in the USART_CR3 register during the interrupt subroutine.
Note: If DMA is used for reception, do not enable the RXNEIE bit.
USART 1 USART 2
TX RX
RX TX
RTS and CTS flow control can be enabled independently by writing respectively RTSE and
CTSE bits to 1 (in the USART_CR3 register).
nRTS
nCTS
The USART interrupt events are connected to the same interrupt vector (see Figure 259).
● During transmission: Transmission Complete, Clear to Send or Transmit Data Register
empty interrupt.
● While receiving: Idle Line detection, Overrun error, Receive Data register not empty,
Parity error, LIN break detection, Noise Flag (only in multi buffer communication) and
Framing Error (only in multi buffer communication).
These events generate an interrupt if the corresponding Enable Control Bit is set.
TC
TCIE
TXE
TXEIE
CTS
CTSIE
USART
IDLE
IDLEIE interrupt
RXNEIE
ORE
RXNEIE
RXNE
PE
PEIE
LBD
LBDIE
FE
NE
ORE EIE
DMAR
Asynchronous mode X X X X X
Hardware Flow Control X X X NA NA
Multibuffer Communication (DMA) X X X X NA
Multiprocessor Communication X X X X X
Synchronous X X X NA NA
Smartcard X X X NA NA
Half-Duplex (Single-Wire mode) X X X X X
IrDA X X X X X
LIN X X X X X
1. X = supported; NA = not applicable.
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved DR[8:0]
Res. rw rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DIV_Mantissa[11:0] DIV_Fraction[3:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved UE M WAKE PCE PS PEIE TXEIE TCIE RXNEIE IDLEIE TE RE RWU SBK
Res. rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CLK
LINEN STOP[1:0] CPOL CPHA LBCL Res. LBDIE LBDL Res. ADD[3:0]
Res. EN
rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Note: These 3 bits (CPOL, CPHA, LBCL) should not be written while the transmitter is enabled.
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HD
Reserved CTSIE CTSE RTSE DMAT DMAR SCEN NACK IRLP IREN EIE
SEL
Res. rw rw rw rw rw rw rw rw rw rw rw
Reserved
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
GT[7:0] PSC[7:0]
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
RXNE
IDLE
ORE
CTS
LBD
TXE
NE
TC
PE
FE
USART_SR
0x00 Reserved
Reset value 0 0 1 1 0 0 0 0 0 0
USART_DR DR[8:0]
0x04 Reserved
Reset value 0 0 0 0 0 0 0 0 0
DIV_Fraction
USART_BRR DIV_Mantissa[15:4]
0x08 Reserved [3:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RXNEIE
IDLEIE
WAKE
TXEIE
RWU
PEIE
TCIE
PCE
SBK
UE
RE
PS
TE
USART_CR1
M
0x0C Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0
CLKEN
Reserved
Reserved
LINEN
LBDIE
CPHA
CPOL
LBCL
LBDL
STOP
USART_CR2 ADD[3:0]
0x10 Reserved [1:0]
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0
HDSEL
DMAR
CTSIE
SCEN
NACK
DMAT
CTSE
RTSE
IREN
IRLP
EIE
USART_CR3
0x14 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Cortex-M3
AHB Peripheral
USB Interrupt
USB2.0 OTG DP
Power&
OTG FS FS
Clock DM
Core UTMIFS PHY
CTRL USB duspend
ID
System clock USB clock
USB Clock at 48 MHz domain domain VBUS
RAM bus
1.25 Kbytes
USB data
FIFOs
ai17106
within the USB data RAM. There is one Tx-FIFO push register for each in-endpoint
(peripheral mode) or out-channel (host mode).
The CPU receives the data from the USB by reading 32-bit words from dedicated OTG_FS
addresses (pop registers). The data are then automatically retrieved from a shared Rx-FIFO
configured within the 1.25 KB USB data RAM. There is one Rx-FIFO pop register for each
out-endpoint or in-channel.
The USB protocol layer is driven by the serial interface engine (SIE) and serialized over the
USB by the full-/low-speed transceiver module within the on-chip physical layer (PHY).
VDD(2)
EN
ST20x2
GPIO
Current-limited 5 V Pwr
Overcurrent power distribution
GPIO+IRQ switch
(2)
STM32F105xx
STM32F107xx
USBmicro-AB connector
VBUS
PA9
DM
PA11
OSC_IN DP
PA12
ID
PA10
OSC_OUT
VSS
ai17115
1. External voltage regulator only needed when building a VBUS powered device
2. ST20x2 only needed if the application has to to support VBUS powered devices. A basic power switch can
be used if 5 V are available on the application board.
3. VDD range is between 2 V and 3.6 V.
The HNP program model is described in detail in Section 26.15: OTG_FS programming
model.
VDD(2) 5V to VDD
Volatge regulator (1)
STM32F105xx
STM32F107xx
VBUS
ai17116
Soft disconnect
The powered state can be exited by software with the soft disconnect feature. The DP pull-
up resistor is removed by setting the soft disconnect bit in the device control register (SDIS
bit in OTG_FS_DCTL), causing a device disconnect detection interrupt on the host side
even though the USB cable was not really removed from the host port.
Default state
In the Default state the OTG_FS expects to recieve a SET_ADDRESS command from the
host. No other USB operation is possible. When a valid SET_ADDRESS command is
decoded on the USB, the application writes the corresponding number into the device
address field in the device configuration register (DAD bit in OTG_FS_DCFG). The OTG_FS
then enters the address state and is ready to answer host transactions at the configured
USB address.
Suspended state
The OTG_FS peripheral constantly monitors the USB activity. After counting 3 ms of USB
idleness, the early suspend interrupt (ESUSP bit in OTG_FS_GINTSTS) is issued, and
confirmed 3 ms later, if appropriate, by the suspend interrupt (USBSUSP bit in
OTG_FS_GINTSTS). The device suspend bit is then automatically set in the device status
register (SUSPSTS bit in OTG_FS_DSTS) and the OTG_FS enters the suspended state.
The suspended state may optionally be exited by the device itself. In this case the
application sets the remote wakeup signaling bit in the device control register (WKUPINT bit
in OTG_FS_DCTL) and clears it after 1 to 15 ms.
When a resume signaling is detected from the host, the resume interrupt (RWUSIG bit in
OTG_FS_GINTSTS) is generated and the device suspend bit is automatically cleared.
on which the transfer is not completed in the current frame. This interrupt is
asserted along with the end of periodic frame interrupt (GINTSTS/EOPF).
● 3 OUT endpoints
– each of them can be configured to support the isochronous, bulk or interrupt
transfer type
– each of them has a proper control (DOEPCTLx), transfer configuration
(DOEPTSIZx) and status-interrupt (DOEPINTx) register
– Device Out endpoints common interrupt mask register (DOEPMSK) is available to
enable/disable a single kind of endpoint interrupt source on all of the OUT
endpoints (EP0 included)
– support incomplete isochronous OUT transfer interrupt (INCOMPISOOUT bit in
OTG_FS_GINTSTS), asserted when there is at least one isochronous OUT
endpoint on which the transfer is not completed in the current frame. This interrupt
is asserted along with the end of periodic frame interrupt (GINTSTS/EOPF).
Endpoint control
● The following endpoint controls are available to the application through the device
endpoint-x IN/OUT control register (DIEPCTLx/DOEPCTLx):
– endpoint enable/disable
– endpoint activation in current configuration
– program the USB transfer type (isochronous, bulk, interrupt)
– program the supported packet size
– program the Tx-FIFO number associated with the IN endpoint
– program the expected or transmitted data0/data1 PID (bulk/interrupt only)
– program the even/odd frame during which the transaction is received or
transmitted (isochronous only)
– optionally program the NAK bit to always negative-acknowledge the host
regardless of the FIFO status
– optionally program the STALL bit to always stall host tokens to that endpoint
– optionally program the SNOOP mode for OUT endpoint not to check the CRC field
of received data
Endpoint transfer
The device endpoint-x transfer size registers (DIEPTSIZx/DOEPTSIZx) allow the application
to program the transfer size parameters and read the transfer status. Programming must be
done before setting the endpoint enable bit in the endpoint control register. Once the
endpoint is enabled, these fields are read-only as the OTG FS core updates them with the
current transfer status.
● The following transfer parameters can be programmed:
– transfer size in bytes
– number of packets constituing the overall transfer size
Endpoint status/interrupt
The device endpoint-x interrupt registers (DIEPINTx/DOPEPINTx) indicate the status of an
endpoint with respect to USB- and AHB-related events. The application must read these
registers when the OUT endpoint interrupt bit or the IN endpoint interrupt bit in the core
configured to generate port interrupts. The overcurrent ISR must promptly disable the VBUS
generation.
VDD(2)
EN
GPIO ST20x2
Current limited 5V Pwr
Overcurrent power distribution
GPIO+IRQ switch (1)
STM32F105xx
STM32F107xx VBUS
ai17117
1. ST20x2 only needed if the application has to support a VBUS powered device. A basic power switch can be
used if 5 V are available on the application board.
2. VDD range is between 2 V and 3.6 V.
VBUS valid
The VBUS input ensures that valid VBUS levels are supplied by the charge pump during USB
operations.
Any unforeseen VBUS voltage drop below the VBUS valid threshold (4.25 V) leads to an OTG
interrupt triggered by the session end detected bit (SEDET bit in OTG_FS_GOTGINT). The
application is then required to remove the VBUS power and clear the port power bit. The
charge pump overcurrent flag can also be used to prevent electrical damage. Connect the
overcurrent flag output from the charge pump to any GPIO input and configure it to generate
a port interrupt on the active level. The overcurrent ISR must promptly disable the VBUS
generation and clear the port power bit.
Host enumeration
After detecting a peripheral connection the host must start the enumeration process by
sending USB reset and configuration commands to the new peripheral.
Before starting to drive a USB reset, the application waits for the OTG interrupt triggered by
the debounce done bit (DBCDNE bit in OTG_FS_GOTGINT), which indicates that the bus is
stable again after the electrical debounce caused by the attachment of a pull-up resistor on
DP (FS) or DM (LS).
The application drives a USB reset signaling (single-ended zero) over the USB by keeping
the port reset bit set in the host port control and status register (PRST bit in
OTG_FS_HPRT) for a minimum of 10 ms and a maximum of 20 ms. The application takes
care of the timing count and then of clearing the port reset bit.
Once the USB reset sequence has completed, the host port interrupt is triggered by the port
enable/disable change bit (PENCHNG bit in OTG_FS_HPRT). This informs the application
that the speed of the enumerated peripheral can be read from the port speed field in the
host port control and status register (PSPD bit in OTG_FS_HPRT) and that the host is
starting to drive SOFs (FS) or Keep alives (LS). The Host is now ready to complete the
peripheral enumeration by sending peripheral configuration commands.
Host suspend
The application decides to suspend the USB activity by setting the port suspend bit in the
host port control and status register (PSUSP bit in OTG_FS_HPRT). The OTG_FS Core
stops sending SOFs and enters the suspended state.
The suspended state can be optionally exited on the remote device’s initiative (remote
wakeup). In this case the remote wakeup interrupt (WKUPINT bit in OTG_FS_GINTSTS) is
generated upon detection of a remote wakeup signaling, the port resume bit in the host port
control and status register (PRES bit in OTG_FS_HPRT) self-sets, and resume signaling is
automatically driven over the USB. The application must time the resume window and then
clear the port resume bit to exit the suspended state and restart the SOF.
If the suspended state is exited on the host’s initiative, the application must set the port
resume bit to start resume signaling on the host port, time the resume window and finally
clear the port resume bit.
same time. If more than 8 transfer requests are pending from the application, the host
controller driver (HCD) must re-allocate channels when they become available from
previous duty, that is, after receiving the transfer completed and channel halted interrupts.
Each host channel can be configured to support in/out and any type of periodic/nonperiodic
transaction. Each host channel makes us of proper control (HCCHARx), transfer
configuration (HCTSIZx) and status/interrupt (HCINTx) registers with associated mask
(HCINTMSKx) registers.
corresponding bits in the HAINT and GINTSTS registers. The mask bits for each interrupt
source of each channel are also available in the OTG_FS_HCINTMSK-x register.
● The host core provides the following status checks and interrupt generation:
– transfer completed interrupt, indicating that the data transfer is complete on both
the application (AHB) and USB sides
– channel has stopped due to transfer completed, USB transaction error or disable
command from the application
– associated transmit FIFO is half or completely empty (IN endpoints)
– ACK response received
– NAK response received
– STALL response received
– USB transaction error due to CRC failure, timeout, bit stuff error, false EOP
– babble error
– frame overrun
– data toggle error
entries) = 512 bytes of USB bulk traffic can be scheduled by the application and
autonomously executed by the host at the maximum full-speed data rate without any
application intervention.
● To post an out periodic (nonperiodic) transaction request to the host scheduler the
application has to:
– configure the transfer parameters on an available host channel
– enable the configured channel
– check that there is at least 1 entry available in the periodic (nonperiodic) request
queue by reading the HPTXSTS bit in the OTG_FS_GNPTXSTS register
– check that there is enough FIFO space in the periodic (nonperiodic) Tx FIFO (see
Section 26.11.2: Host Tx FIFOs) by reading the HPTXSTS (GNPTXSTS) register.
This step may not be necessary if the application submits the host transaction
request upon reception of the periodic (nonperiodic) Tx FIFO half or completely
empty interrupt
– push the data payload to the associated FIFO address (push register). There is
one push register for each enabled host channel. The data payload is
automatically redirected to the periodic or nonperiodic Tx FIFO according to the
host channel EPTYP bitfield in the OTG_FS_HCCHARx register. When the last
32-bit word data are written to the FIFO, an active entry is inserted at the bottom of
the periodic (nonperiodic) request queue and the transaction request is scheduled
for execution
● To post an IN periodic (nonperiodic) transaction request to the host scheduler the
application has to:
– configure the transfer parameters on an available host channel
– enable the configured channel with the channel enable bit in the host channel
characteristics register (CHENA bit in OTG_FS_HCCHARx). This inserts an active
entry at the bottom of the periodic (nonperiodic) request queue and the
transaction request is scheduled for execution
STM32F105xx
STM32F107xx
ITR1 SOF
PA11 D-
pulse
PA12 D+
VSS
ai17120
AIU
PSRAM PFC
MAC
WPC
PIU
SIE
FS serial interface
ai15608
1. BIUS = bus interface unit, AIU = application interface unit, PFC = packet FIFO controller, MAC = media
access controller, WPC = wakeup and power controller, PIU = PHY interface unit, SIE = serial interface
engine.
The USB system features 1.25 Kbyte of dedicated RAM with a sophisticated FIFO control
mechanism. The packet FIFO controller (PFC) module in the OTG_FS Core organizes RAM
space into Tx-FIFOs into which the application pushes the data to be temporarily stored
before the USB transmission, and into a single Rx FIFO where the data received from the
USB are temporarily stored before retrieval (popped) by the application. The number of
instructed FIFOs and how these are architectured inside the RAM depends on the device’s
role. In peripheral mode an additional Tx-FIFO is instructed for each active IN endpoint. Any
FIFO size is software configured to better meet the application requirements.
ai15611
Rx packets RXFSIZ[31:16]
Any channel DFIFO pop
access from AHB Rx FIFO control
Rx start address
fixed to 0
MAC push A1 = 0
ai15610
data are also stored into the FIFO. The size of the receive FIFO is configured in the receive
FIFO size register (GRXFSIZ).
The single receive FIFO architecture makes it highly efficient for the USB host to fill in the
receive data buffer:
● all IN configured host channels share the same RAM buffer (shared FIFO)
● the OTG FS Core can fill in the receive FIFO up to the limit for any sequence of IN
tokens driven by the host software
The application receives the Rx FIFO not-empty interrupt as long as there is at least one
packet available for download. It reads the packet information from the receive status read
and pop register and finally pops the data off the receive FIFO.
OTG_FS to fill in the available RAM space at best regardless of the current USB sequence.
With these features:
● The application gains good margins to calibrate its intervention in order to optimize the
CPU bandwidth usage:
– it can accumulate large amounts of transmission data in advance compared to
when they are effectively sent over the USB
– it benefits of a large time margin to download data from the single receive FIFO
● The USB Core is able to maintain its full operating rate, that is to provide maximum full-
speed bandwidth with a great margin of autonomy versus application intervention:
– it has a large reserve of transmission data at its disposal to autonomously manage
the sending of data over the USB
– it has a lot of empty space available in the receive buffer to autonomously fill it in
with the data coming from the USB
As the OTG_FS Core is able to fill in the 1.25 Kbyte RAM buffer very efficiently, and as
1.25 Kbyte of transmit/receive data is more than enough to cover a full speed frame, the
USB system is able to withstand the maximum full-speed data rate for up to one USB frame
(1 ms) without any CPU intervention.
OR
Global interrupt
mask (Bit 0)
AHB configuration
register
AND
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17:10 9 8 7:3 2 1 0
OTG
interrupt
Device all endpoints register
interrupt register
31:16 15:0 Device all endpoints
OUT endpoints IN endpoints interrupt mask register
ai15616
1. The core interrupt register bits are shown in OTG_FS core interrupt register (OTG_FS_GINTSTS) on
page 732.
Reserved
2 0000h
DFIFO
debug read/
Direct access to data FIFO RAM
write to this
for debugging (128 Kbyte)
region
3 FFFFh
ai15615
OTG_FS_OTGCTL 0x000 OTG_FS control and status register (OTG_FS_GOTGCTL) on page 722
Table 181. Core global control and status registers (CSRs) (continued)
Address
Acronym Register name
offset
OTG_FS_GRXSTSR 0x01C OTG_FS Receive status debug read/OTG status read and pop registers
OTG_FS_GRXSTSP 0x020 (OTG_FS_GRXSTSR/OTG_FS_GRXSTSP) on page 739
OTG_FS_GRXFSIZ 0x024 OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ) on page 740
OTG_FS_HFIR 0x404 OTG_FS Host frame interval register (OTG_FS_HFIR) on page 745
0x500
0x520 OTG_FS host channel-x characteristics register (OTG_FS_HCCHARx)
OTG_FS_HCCHARx
... (x = 0..7, where x = Channel_number) on page 751
0x6E0h
OTG_FS host channel-x interrupt register (OTG_FS_HCINTx) (x = 0..7,
OTG_FS_HCINTx 508h
where x = Channel_number) on page 752
OTG_FS host channel-x interrupt mask register (OTG_FS_HCINTMSKx)
OTG_FS_HCINTMSKx 50Ch
(x = 0..7, where x = Channel_number) on page 753
OTG_FS host channel-x transfer size register (OTG_FS_HCTSIZx)
OTG_FS_HCTSIZx 510h
(x = 0..7, where x = Channel_number) on page 754
0x920
0x940 OTG device endpoint-x control register (OTG_FS_DIEPCTLx) (x = 1..3,
OTG_FS_DIEPCTLx
... where x = Endpoint_number) on page 764
0xAE0
0xB20
0xB40
... OTG device endpoint-x control register (OTG_FS_DIEPCTLx) (x = 1..3,
OTG_FS_DOEPCTLx
0xCC0 where x = Endpoint_number) on page 764
0xCE0
0xCFD
Table 185. Power and clock gating control and status registers
Register name Acronym Offset address: 0xE00–0xFFF
Reserved 0xE05–0xFFF
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HSHNPEN
HNGSCS
SRQSCS
DHNPEN
CIDSTS
HNPRQ
BSVLD
ASVLD
DBCT
SRQ
r r r r rw rw rw r rw r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HNSSCHG
ADTOCHG
SRSSCHG
HNGDET
DBCDNE
SEDET
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PTXFELVL
TXFELVL
GINT
Reserved Reserved
rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NPTXRWEN
HNPCAP
SRPCAP
CTXPKT
FDMOD
FHMOD
TRDT TOCAL
Reserved Reserved
r/rw
r/rw
rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RXFFLSH
TXFFLSH
AHBIDL
HSRST
CSRST
FCRST
Reserved
TXFNUM
Reserved
r rw rs rs rs rs rs
Bit 3 Reserved
Bit 2 FCRST: Host frame counter reset
The application writes this bit to reset the frame number counter inside the core. When the
frame counter is reset, the subsequent SOF sent out by the core has a frame number of 0.
Note: Only accessible in Host mode.
Bit 1 HSRST: HCLK soft reset
The application uses this bit to flush the control logic in the AHB Clock domain. Only AHB Clock
Domain pipelines are reset.
FIFOs are not flushed with this bit.
All state machines in the AHB clock domain are reset to the Idle state after terminating the
transactions on the AHB, following the protocol.
CSR control bits used by the AHB clock domain state machines are cleared.
To clear this interrupt, status mask bits that control the interrupt status and are generated by
the AHB clock domain state machine are cleared.
Because interrupt status bits are not cleared, the application can get the status of any core
events that occurred after it set this bit.
This is a self-clearing bit that the core clears after all necessary logic is reset in the core. This
can take several clocks, depending on the core’s current state.
Note: Accessible in both Device and Host modes.
Bit 0 CSRST: Core soft reset
Resets the HCLK and PCLK domains as follows:
Clears the interrupts and all the CSR register bits except for the following bits:
– RSTPDMODL bit in OTG_FS_PCGCCTL
– GAYEHCLK bit in OTG_FS_PCGCCTL
– PWRCLMP bit in OTG_FS_PCGCCTL
– STPPCLK bit in OTG_FS_PCGCCTL
– FSLSPCS bit in OTG_FS_HCFG
– DSPD bit in OTG_FS_DCFG
All module state machines (except for the AHB slave unit) are reset to the Idle state, and all
the transmit FIFOs and the receive FIFO are flushed.
Any transactions on the AHB Master are terminated as soon as possible, after completing the
last data phase of an AHB transfer. Any transactions on the USB are terminated immediately.
The application can write to this bit any time it wants to reset the core. This is a self-clearing bit
and the core clears this bit after all the necessary logic is reset in the core, which can take
several clocks, depending on the current state of the core. Once this bit has been cleared, the
software must wait at least 3 PHY clocks before accessing the PHY domain (synchronization
delay). The software must also check that bit 31 in this register is set to 1 (AHB Master is Idle)
before starting any operation.
Typically, the software reset is used during software development and also when you
dynamically change the PHY selection bits in the above listed USB configuration registers.
When you change the PHY, the corresponding clock for the PHY is selected and used in the
PHY domain. Once a new clock is selected, the PHY domain has to be reset for proper
operation.
Note: Accessible in both Device and Host modes.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
IPXFR/INCOMPISOOUT
BOUTNAKEFF
ENUMDNE
GINAKEFF
USBSUSP
ISOODRP
CIDSCHG
HPRTINT
Reserved
IISOIXFR
USBRST
DISCINT
WKUINT
SRQINT
OTGINT
OEPINT
RXFLVL
ESUSP
PTXFE
IEPINT
HCINT
CMOD
EOPF
MMIS
SOF
Reserved
Reserved
Reserved
NPTXFE
rc_w1
rc_w1
rc_w1 r r r Res. rc_w1 r r rc_w1 r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
IPXFRM/IISOOXFRM
GONAKEFFM
ENUMDNEM
GINAKEFFM
USBSUSPM
ISOODRPM
CIDSCHGM
IISOIXFRM
NPTXFEM
RXFLVLM
ESUSPM
FSUSPM
USBRST
PTXFEM
DISCINT
EPMISM
OTGINT
OEPINT
EOPFM
MMISM
SRQIM
IEPINT
PRTIM
SOFM
WUIM
HCIM
Reserved
Reserved
Reserved
Reserved
Reserved
rw rw rw rw rw rw r rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Bit 23 Reserved
Bit 22 FSUSPM: Data fetch suspended mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
Bit 21 IPXFRM: Incomplete periodic transfer mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Host mode.
IISOOXFRM: Incomplete isochronous OUT transfer mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
Bit 20 IISOIXFRM: Incomplete isochronous IN transfer mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
Bit 19 OEPINT: OUT endpoints interrupt mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
Bit 18 IEPINT: IN endpoints interrupt mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
Bit 17 EPMISM: Endpoint mismatch interrupt mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
Bit 16 Reserved
Bit 15 EOPFM: End of periodic frame interrupt mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
Bit 14 ISOODRPM: Isochronous OUT packet dropped interrupt mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
Bit 13 ENUMDNEM: Enumeration done mask
0: Masked interrupt
1: Unmasked interrupt
Note: Only accessible in Device mode.
OTG_FS Receive status debug read/OTG status read and pop registers
(OTG_FS_GRXSTSR/OTG_FS_GRXSTSP)
Address offset for Read: 0x01C
Address offset for Pop: 0x020
Reset value: 0x0000 0000
A read to the Receive status debug read register returns the contents of the top of the
Receive FIFO. A read to the Receive status read and pop register additionally pops the top
data entry out of the RxFIFO.
The receive status contents must be interpreted differently in Host and Device modes. The
core ignores the receive status pop/read when the receive FIFO is empty and returns a
value of 0x0000 0000. The application must only pop the Receive Status FIFO when the
Receive FIFO non-empty bit of the Core interrupt register (RXFLVL bit in
OTG_FS_GINTSTS) is asserted.
Host mode:
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PKTSTS DPID BCNT CHNUM
Reserved
r r r r
Device mode:
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RXFD
Reserved
r/rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NPTXFD NPTXFSA
r/rw r/rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
r r r
Bit 31 Reserved
Bits 30:24 NPTXQTOP: Top of the non-periodic transmit request queue
Entry in the non-periodic Tx request queue that is currently being processed by the MAC.
Bits [30:27]: Channel/endpoint number
Bits [26:25]:
– 00: IN/OUT token
– 01: Zero-length transmit packet (device IN/host OUT)
– 11: Channel halt command
Bit [24]: Terminate (last entry for selected channel/endpoint)
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SOFOUTEN
VBUSBSEN
VBUSASEN
.PWRDWN
Reserved
Reserved Reserved
rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PRODUCT_ID
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PTXFSIZ PTXSA
r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r
w w w w w w w w w w w w w w w w w w w w w w w w w w w w w w w w
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
INEPTXFD INEPTXSA
r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r r/r
w w w w w w w w w w w w w w w w w w w w w w w w w w w w w w w w
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FSLSPCS
FSLSS
Reserved
r rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FRIVL
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FTREM FRNUM
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PTXQTOP PTXQSAV PTXFSAVL
r r r r r r r r r r r r r r r r rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HAINT
Reserved
r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HAINTM
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
POCCHNG
PENCHNG
PSUSP
PCDET
PCSTS
PLSTS
PPWR
POCA
PRES
PENA
PRST
Reserved
PSPD PTCTL
Reserved
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
DAD EPNUM MPSIZ
rs rs rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FRMOR
DTERR
BBERR
TXERR
STALL
XFRC
CHH
NAK
ACK
Reserved
Reserved
Reserved
rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_
w1 w1 w1 w1 w1 w1 w1 w1 w1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FRMORM
DTERRM
BBERRM
TXERRM
STALLM
XFRCM
CHHM
NAKM
ACKM
NYET
Reserved
Reserved
rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Bit 31 Reserved
Bits 30:29 DPID: Data PID
The application programs this field with the type of PID to use for the initial transaction. The
host maintains this field for the rest of the transfer.
00: DATA0
01: DATA2
10: DATA1
11: MDATA (non-control)/SETUP (control)
Bits 28:19 PKTCNT: Packet count
This field is programmed by the application with the expected number of packets to be
transmitted (OUT) or received (IN).
The host decrements this count on every successful transmission or reception of an OUT/IN
packet. Once this count reaches zero, the application is interrupted to indicate normal
completion.
Bits 18:0 XFRSIZ: Transfer size
For an OUT, this field is the number of data bytes the host sends during the transfer.
For an IN, this field is the buffer size that the application has reserved for the transfer. The
application is expected to program this field as an integer multiple of the maximum packet size
for IN transactions (periodic and non-periodic).
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NZLSOHSK
PFIVL
DSPD
Reserved
DAD
Reserved
rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
POPRGDNE
CGONAK
SGONAK
GONSTS
RWUSIG
CGINAK
SGINAK
GINSTS
TCTL
SDIS
Reserved
rw w w w w rw rw rw r r rw rw
Table 186 contains the minimum duration (according to device state) for which the Soft
disconnect (SDIS) bit must be set for the USB host to detect a device disconnect. To
accommodate clock jitter, it is recommended that the application add some extra delay to
the specified minimum duration.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ENUMSPD
SUSPSTS
EERR
FNSOF
Reserved Reserved
r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ITTXFEMSK
INEPNMM
INEPNEM
TXFURM
XFRCM
EPDM
Reserved
Reserved
TOM
BIM
Reserved
rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
B2BSTUP
OTEPDM
XFRCM
STUPM
OPEM
EPDM
BOIM
Reserved
Reserved
Reserved
Reserved
rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OEPINT IEPINT
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OEPM IEPM
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
VBUSDT
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DVBUSP
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
INEPTXFEM
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
USBAEP
NAKSTS
EPENA
EPDIS
STALL
CNAK
SNAK
Reserved
Reserved
Reserved
TXFNUM EPTYP MPSIZ
Reserved
rs r w w rw rw rw rw rs r r r r rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
CNAK
SNAK
Stall
Reserved
TXFNUM MPSIZ
Reserved
rw/
rs rs w w w w rw rw rw rw rw rw r r rw rw rw rw rw rw rw rw rw rw rw rw
rs
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
USBAEP
NAKSTS
EPENA
EPDIS
SNPM
CNAK
SNAK
Reserved
Reserved
Stall
EPTYP MPSIZ
Reserved Reserved
w r w w rs rw r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
Stall
MPSIZ
Reserved Reserved
rw/
rs rs w w w w rw rw rw r r rw rw rw rw rw rw rw rw rw rw rw rw
rs
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
EPDISD
INEPNE
ITTXFE
XFRC
TXFE
TOC
Reserved
Reserved
Reserved
rc_
rc_ rc_ rc_ rc_
r w1
w1 w1 w1 w1
/rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
B2BSTUP
OTEPDIS
EPDISD
XFRC
STUP
Reserved
Reserved
Reserved
Reserved
rc_
rc_ rc_ rc_ rc_
w1
w1 w1 w1 w1
/rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PKTCNT XFRSIZ
Reserved Reserved
rw rw rw rw rw rw rw rw rw
PKTCNT
Reserved
STUPC
XFRSIZ
NT Reserved Reserved
rw rw rw rw rw rw rw rw rw rw
Bit 31 Reserved
Bits 30:29 STUPCNT: SETUP packet count
This field specifies the number of back-to-back SETUP data packets the endpoint can receive.
01: 1 packet
10: 2 packets
11: 3 packets
Bits 28:20 Reserved
Bit 19 PKTCNT: Packet count
This field is decremented to zero after a packet is written into the RxFIFO.
Bits 18:7 Reserved
Bits 6:0 XFRSIZ: Transfer size
Indicates the transfer size in bytes for endpoint 0. The core interrupts the application only after
it has exhausted the transfer size amount of data. The transfer size can be set to the maximum
packet size of the endpoint, to be interrupted at the end of each packet.
The core decrements this field every time a packet is read from the RxFIFO and written to the
external memory.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MCNT PKTCNT XFRSIZ
Reserved
rw/ rw/
r/r r/r rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
w w
Bit 31 Reserved
Bits 30:29 MCNT: Multi count
For periodic IN endpoints, this field indicates the number of packets that must be transmitted
per frame on the USB. The core uses this field to calculate the data PID for isochronous IN
endpoints.
01: 1 packet
10: 2 packets
11: 3 packets
Bit 28:19 PKTCNT: Packet count
Indicates the total number of USB packets that constitute the Transfer Size amount of data for
this endpoint.
This field is decremented every time a packet (maximum size or short packet) is read from the
TxFIFO.
Bits 18:0 XFRSIZ: Transfer size
This field contains the transfer size in bytes for the current endpoint. The core only interrupts
the application after it has exhausted the transfer size amount of data. The transfer size can be
set to the maximum packet size of the endpoint, to be interrupted at the end of each packet.
The core decrements this field every time a packet from the external memory is written to the
TxFIFO.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
INEPTFSAV
Reserved
r r r r r r r r r r r r r r r r
31:16 Reserved
15:0 INEPTFSAV: IN endpoint TxFIFO space avail ()
Indicates the amount of free space available in the Endpoint TxFIFO.
Values are in terms of 32-bit words:
0x0: Endpoint TxFIFO is full
0x1: 1 word available
0x2: 2 words available
0xn: n words available (where 0 < n < 512)
0x200: 512 words available
Others: Reserved
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RXDPID/S
Reserved
PKTCNT XFRSIZ
TUPCNT
rw/r/ rw/r/
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
rw rw
Bit 31 Reserved
Bits 30:29 RXDPID: Received data PID
Applies to isochronous OUT endpoints only.
This is the data PID received in the last packet for this endpoint.
00: DATA0
01: DATA2
10: DATA1
11: MDATA
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
GATEHCLK
PHYSUSP
STPPCLK
Reserved
Reserved
rw rw rw
The table below gives the USB OTG register map and reset values.
Table 187. OTG_FS register map and reset values
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
HSHNPEN
HNGSCS
SRQSCS
DHNPEN
CIDSTS
HNPRQ
BSVLD
ASVLD
DBCT
OTG_FS_GOT
SRQ
0x000 GCTL Reserved Reserved Reserved
Reset value 0 0 0 1 0 0 0 0 0 0
HNSSCHG
ADTOCHG
SRSSCHG
DBCDNE
HNGDET
SEDET
Reserved
OTG_FS_GOT
0x004 GINT Reserved Reserved Res.
Reset value 0 0 0 0 0 0
PTXFELVL
TXFELVL
GINT
OTG_FS_GAH
0x008 BCFG Reserved Reserved
Reset value 0 0 0
NPTXRWEN
HNPCAP
SRPCAP
CTXPKT
FDMOD
FHMOD
OTG_FS_GUS
TRDT TOCAL
0x00C BCFG Reserved Reserved
Reset value 0 0 1 0 1 0 0 0 0 0
RXFFLSH
TXFFLSH
Reserved
AHBIDL
HSRST
CSRST
FCRST
OTG_FS_GRST
TXFNUM
0x010 CTL Reserved
Reset value 1 0 0 0 0 0 0 0 0 0 0
IPXFR/INCOMPISOOUT
BOUTNAKEFF
ENUMDNE
GINAKEFF
USBSUSP
CIDSCHG
ISOODRP
HPRTINT
IISOIXFR
USBRST
DISCINT
WKUINT
NPTXFE
SRQINT
OTGINT
OEPINT
RXFLVL
ESUSP
IEPINT
PTXFE
CMOD
HCINT
Reserved
Reserved
Reserved
Reserved
EOPF
MMIS
OTG_FS_GINT
SOF
0x014 STS
Reset value 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
IPXFRM/IISOOXFRM
GONAKEFFM
ENUMDNEM
GINAKEFFM
USBSUSPM
CIDSCHGM
ISOODRPM
IISOIXFRM
NPTXFEM
RXFLVLM
ESUSPM
FSUSPM
USBRST
PTXFEM
DISCINT
EPMISM
OTGINT
OEPINT
EOPFM
MMISM
SRQIM
IEPINT
PRTIM
Reserved
Reserved
Reserved
Reserved
Reserved
SOFM
WUIM
HCIM
OTG_FS_GINT
0x018 MSK
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_GRXS
TSR (Host PKTSTS DPID BCNT CHNUM
Reserved
mode)
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x01C
OTG_FS_GRXS
TSR (Device FRMNUM PKTSTS DPID BCNT EPNUM
Reserved
mode)
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_GRXS
TSR (Host PKTSTS DPID BCNT CHNUM
Reserved
mode)
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0x020
OTG_FS_GRXS
TSPR (Device FRMNUM PKTSTS DPID BCNT EPNUM
Reserved
mode)
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_GRXF
RXFD
0x024 SIZ Reserved
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
OTG_FS_GNPT
NPTXFD NPTXFSA
0x028 XFSIZ
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
OTG_FS_GNPT
NPTXQTOP NPTQXSAV NPTXFSAV
Res.
0x02C XSTS
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
SOFOUTEN
VBUSBSEN
VBUSASEN
.PWRDWN
Reserved
OTG_FS_GCCF
0x038 G Reserved Reserved
Reset value 0 0 0 0
OTG_FS_CID PRODUCT_ID
0x03C
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HPTX
PTXFSIZ PTXSA
0x100 FSIZ
Reset value 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0
OTG_FS_DIEP
INEPTXFD INEPTXSA
0x104 TXF1
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
INEPTXFD INEPTXSA
0x108 TXF2
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
INEPTXFD INEPTXSA
0x10C TXF3
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
INEPTXFD INEPTXSA
0x110 TXF4
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
FSLSPCS
FSLSS
OTG_FS_HCFG
0x400 Reserved
Reset value 0 0 0
OTG_FS_HFIR FRIVL
0x404 Reserved
Reset value 1 1 1 0 1 0 1 0 0 1 1 0 0 0 0 0
OTG_FS_HFNU
FTREM FRNUM
0x408 M
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
OTG_FS_HPTX
PTXQTOP PTXQSAV PTXFSAVL
0x410 STS
Reset value 0 0 0 0 0 0 0 0 Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
OTG_FS_HAIN
HAINT
0x414 T Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HAIN
HAINTM
0x418 TMSK Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
POCCHNG
PENCHNG
Reserved
PCDET
PSUSP
PCSTS
PLSTS
PPWR
POCA
PRES
PENA
PRST
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x500 HAR0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x520 HAR1
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x540 HAR2
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x560 HAR3
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x580 HAR4
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x5A0 HAR5
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x5C0 HAR6
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x5E0 HAR7
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x600 HAR8
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x620 HAR9
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x640 HAR10
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x660 HAR11
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x680 HAR12
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x6A0 HAR13
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x6C0 HAR14
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ODDFRM
CHENA
EPTYP
LSDEV
CHDIS
EPDIR
Reserved
Reserved
OTG_FS_HCC
DAD EPNUM MPSIZ
0x6E0 HAR15
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FRMOR
DTERR
BBERR
TXERR
Reserved
Reserved
STALL
XFRC
OTG_FS_HCIN
CHH
NAK
ACK
0x508 T0 Reserved
Reset value 0 0 0 0 0 0 0 0 0
0x6E8
0x6A8
0x5E8
0x5A8
0x6C8
0x5C8
0x50C
Offset
780/995
T9
T8
T7
T6
T5
T4
T3
T2
T1
T15
T14
T13
T12
T11
T10
TMSK0
Register
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
31
30
29
28
27
26
25
USB on-the-go full-speed (OTG_FS)
24
23
22
21
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
20
19
18
17
13
12
11
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
DTERRM DTERR DTERR DTERR DTERR DTERR DTERR DTERR DTERR DTERR DTERR DTERR DTERR DTERR DTERR DTERR 10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
FRMORM FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR FRMOR 9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
BBERRM BBERR BBERR BBERR BBERR BBERR BBERR BBERR BBERR BBERR BBERR BBERR BBERR BBERR BBERR BBERR 8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
TXERRM TXERR TXERR TXERR TXERR TXERR TXERR TXERR TXERR TXERR TXERR TXERR TXERR TXERR TXERR TXERR 7
0
NYET Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved 6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
ACKM ACK ACK ACK ACK ACK ACK ACK ACK ACK ACK ACK ACK ACK ACK ACK 5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NAKM NAK NAK NAK NAK NAK NAK NAK NAK NAK NAK NAK NAK NAK NAK NAK 4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
STALLM STALL STALL STALL STALL STALL STALL STALL STALL STALL STALL STALL STALL STALL STALL STALL 3
Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved 2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
CHHM CHH CHH CHH CHH CHH CHH CHH CHH CHH CHH CHH CHH CHH CHH CHH 1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
XFRCM XFRC XFRC XFRC XFRC XFRC XFRC XFRC XFRC XFRC XFRC XFRC XFRC XFRC XFRC XFRC 0
RM0008
0x68C
0x66C
0x64C
0x62C
0x60C
0x58C
0x56C
0x54C
0x52C
0x6AC
0x5AC
0x5EC
0x6CC
0x5CC
Offset
RM0008
TMSK9
TMSK8
TMSK7
TMSK6
TMSK5
TMSK4
TMSK3
TMSK2
TMSK1
TMSK14
TMSK13
TMSK12
TMSK11
TMSK10
Register
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
Reset value
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
OTG_FS_HCIN
31
30
29
28
27
26
25
24
23
22
21
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
20
19
18
17
13
12
11
0
0
0
0
0
0
0
0
0
0
0
0
0
0
DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM DTERRM 10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM FRMORM 9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM BBERRM 8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM TXERRM 7
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NYET NYET NYET NYET NYET NYET NYET NYET NYET NYET NYET NYET NYET NYET 6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
ACKM ACKM ACKM ACKM ACKM ACKM ACKM ACKM ACKM ACKM ACKM ACKM ACKM ACKM 5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
NAKM NAKM NAKM NAKM NAKM NAKM NAKM NAKM NAKM NAKM NAKM NAKM NAKM NAKM 4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
STALLM STALLM STALLM STALLM STALLM STALLM STALLM STALLM STALLM STALLM STALLM STALLM STALLM STALLM 3
Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved 2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
CHHM CHHM CHHM CHHM CHHM CHHM CHHM CHHM CHHM CHHM CHHM CHHM CHHM CHHM 1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM XFRCM 0
USB on-the-go full-speed (OTG_FS)
781/995
USB on-the-go full-speed (OTG_FS) RM0008
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
FRMORM
DTERRM
BBERRM
TXERRM
STALLM
XFRCM
Reserved
CHHM
NAKM
ACKM
NYET
OTG_FS_HCIN
0x6EC TMSK15 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved
DPID PKTCNT XFRSIZ
IZ0
0x510
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ1
0x530
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ2
0x550
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ3
0x570
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ4
0x590
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ5
0x5B0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
0x5D0 IZ6
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
0x5F0 IZ7
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ8
0x610
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
0x630 IZ9
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ10
0x650
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ11
0x670
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ12
0x690
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ13
0x6B0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ14
0x6D0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_HCTS
DPID PKTCNT XFRSIZ
IZ15
0x6F0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
NZLSOHSK
Reserved
PFIVL
DSPD
DAD
OTG_FS_DCFG
0x800 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
POPRGDNE
CGONAK
SGONAK
GONSTS
RWUSIG
CGINAK
SGINAK
GINSTS
TCTL
SDIS
OTG_FS_DCTL
0x804 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
ENUMSPD
SUSPSTS
EERR
OTG_FS_DSTS FNSOF
0x808 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ITTXFEMSK
INEPNMM
INEPNEM
Reserved
TXFURM
XFRCM
Reserved
EPDM
OTG_FS_DIEP
TOM
BIM
0x810 MSK Reserved
Reset value 0 0 0 0 0 0 0 0 0
B2BSTUP
OTEPDM
Reserved
Reserved
XFRCM
STUPM
Reserved
OPEM
EPDM
BOIM
OTG_FS_DOEP
0x814 MSK Reserved
Reset value 0 0 0 0 0 0 0 0 0
OTG_FS_DAIN
OEPINT IEPINT
0x818 T
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DAIN
OEPM IEPM
0x81C TMSK
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DVBU
VBUSDT
0x828 SDIS Reserved
Reset value 0 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1
OTG_FS_DVBU
DVBUSP
0x82C SPULSE Reserved
Reset value 0 1 0 1 1 0 1 1 1 0 0 0
OTG_FS_DIEP
INEPTXFEM
0x834 EMPMSK Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
USBAEP
NAKSTS
EPENA
EPDIS
Reserved
Reserved
Reserved
CNAK
SNAK
TXFNUM
0x900 CTL0 P Reserved Z
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
TG_FS_DTXFS
INEPTFSAV
0x918 TS0 Reserved
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0x920 CTL1 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TG_FS_DTXFS
INEPTFSAV
0x938 TS1 Reserved
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0x940 CTL2 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TG_FS_DTXFS
INEPTFSAV
0x958 TS2 Reserved
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0x960 CTL3 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TG_FS_DTXFS
INEPTFSAV
0x978 TS3 Reserved
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0x980 CTL4 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TG_FS_DTXFS
INEPTFSAV
0x998 TS4 Reserved
Reset value 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0x9A0 CTL5 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0x9C0 CTL6 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0x9E0 CTL7 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
Reserved
EPDIS
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0xA00 CTL8 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0xA20 CTL9 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0xA40 CTL10 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
Reserved
EPDIS
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0xA60 CTL11 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
Reserved
EPDIS
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0xA80 CTL12 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0xAA0 CTL13 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0xAC0 CTL14 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
Reserved
CNAK
SNAK
OTG_FS_DIEP
Stall
TXFNUM MPSIZ
0xAE0 CTL15 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
USBAEP
NAKSTS
EPENA
Reserved
Reserved
EPDIS
SNPM
CNAK
SNAK
Reset value 0 0 0 0 0 0 0 0 0 1 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xB20 CTL1 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xB40 CTL2 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xB60 CTL3 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xB80 CTL4 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xBA0 CTL5 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xBC0 CTL6 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xBE0 CTL7 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xC00 CTL8 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xC20 CTL9 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xC40 CTL10 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xC60 CTL11 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xC80 CTL12 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xCA0 CTL13 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xCC0 CTL14 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SD0PID/SEVNFRM
EONUM/DPID
SODDFRM
USBAEP
NAKSTS
EPENA
EPTYP
EPDIS
SNPM
CNAK
SNAK
OTG_FS_DOEP
Stall
MPSIZ
0xCE0 CTL15 Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
Reset value 1 0 0 0 0 0
INEPNE
EPDISD
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
Reset value 1 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0x988 NT4 Reserved
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0x9A8 NT5 Reserved
Reset value 1 0 0 0 0 0
INEPNE
EPDISD
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0x9C8 NT6 Reserved
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0x9E8 NT7 Reserved
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0xA08 NT8 Reserved
Reset value 1 0 0 0 0 0
INEPNE
EPDISD
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0xA28 NT9 Reserved
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0xA48 NT10 Reserved
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0xA68 NT11 Reserved
Reset value 1 0 0 0 0 0
INEPNE
EPDISD
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0xA88 NT12 Reserved
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
0xAA8 NT13 Reserved
Reset value 1 0 0 0 0 0
INEPNE
EPDISD
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
Reset value 1 0 0 0 0 0
EPDISD
INEPNE
ITTXFE
Reserved
Reserved
XFRC
TXFE
OTG_FS_DIEPI
TOC
Reset value 1 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xB08 INT0 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xB28 INT1 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xB48 INT2 Reserved
Reset value 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xB68 INT3 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xB88 INT4 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xBA8 INT5 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xBC8 INT6 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xBE8 INT7 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xC08 INT8 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xC28 INT9 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xC48 INT10 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xC68 INT11 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xC88 INT12 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xCA8 INT13 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xCC8 INT14 Reserved
Reset value 0 0 0 0 0
B2BSTUP
OTEPDIS
EPDISD
Reserved
Reserved
Reserved
XFRC
STUP
OTG_FS_DOEP
0xCE8 INT15 Reserved
Reset value 0 0 0 0 0
OTG_FS_DIEP PKTC
XFRSIZ
0x910 TSIZ0 Reserved NT Reserved
Reset value 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
OTG_FS_DIEP
Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved
MCNT PKTCNT XFRSIZ
TSIZ1
0x930
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ2
0x950
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ3
0x970
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ4
0x990
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ5
0x9B0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ6
0x9D0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ7
0x9F0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ8
0xA10
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
0xA30 TSIZ9
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
0xA50 TSIZ10
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ11
0xA70
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
0xA90 TSIZ12
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ13
0xAB0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ14
0xAD0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OTG_FS_DIEP
MCNT PKTCNT XFRSIZ
TSIZ15
0xAF0
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PKTCNT
OTG_FS_DOEP STUP
XFRSIZ
0xB10 TSIZ0 CNT Reserved Reserved
Reset value 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xB30 TSIZ1
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xB50 TSIZ2
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xB70 TSIZ3
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xB90 TSIZ4
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xBB0 TSIZ5
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xBD0 TSIZ6
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xBF0 TSIZ7
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xC10 TSIZ8
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xC30 TSIZ9
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xC50 TSIZ10
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xC70 TSIZ11
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xC90 TSIZ12
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xCB0 TSIZ13
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xCD0 TSIZ14
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
STUPCNT
RXDPID/
Reserved
OTG_FS_DOEP
PKTCNT XFRSIZ
0xCF0 TSIZ15
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
GATEHCLK
PHYSUSP
STPPCLK
Reserved
OTG_FS_PCG
0xE00 CCTL Reserved
Reset value
Halting a channel
The application can disable any channel by programming the OTG_FS_HCCHARx register
with the CHDIS and CHENA bits set to 1. This enables the OTG_FS host to flush the posted
requests (if any) and generates a channel halted interrupt. The application must wait for the
CHH interrupt in OTG_FS_HCINTx before reallocating the channel for other transactions.
The OTG_FS host does not interrupt the transaction that has already been started on the
USB.
Before disabling a channel, the application must ensure that there is at least one free space
available in the non-periodic request queue (when disabling a non-periodic channel) or the
periodic request queue (when disabling a periodic channel). The application can simply
flush the posted requests when the Request queue is full (before disabling the channel), by
programming the OTG_FS_HCCHARx register with the CHDIS bit set to 1, and the CHENA
bit cleared to 0.
The application is expected to disable a channel on any of the following conditions:
1. When an XFRC interrupt in OTG_FS_HCINTx is received during a non-periodic IN
transfer or high-bandwidth interrupt IN transfer (Slave mode only)
2. When an STALL, TXERR, BBERR or DTERR interrupt in OTG_FS_HCINTx is received
for an IN or OUT channel (Slave mode only). For high-bandwidth interrupt INs in Slave
mode, once the application has received a DTERR interrupt it must disable the channel
and wait for a channel halted interrupt. The application must be able to receive other
interrupts (DTERR, Nak, Data, TXERR) for the same channel before receiving the halt.
Operational model
The application must initialize a channel before communicating to the connected device.
This section explains the sequence of operation to be performed for different types of USB
transactions.
● Writing the transmit FIFO
The OTG_FS host automatically writes an entry (OUT request) to the periodic/non-
periodic request queue, along with the last DWORD write of a packet. The application
must ensure that at least one free space is available in the periodic/non-periodic
request queue before starting to write to the transmit FIFO. The application must
always write to the transmit FIFO in DWORDs. If the packet size is non-DWORD
aligned, the application must use padding. The OTG_FS host determines the actual
packet size based on the programmed maximum packet size and transfer size.
Start
Read GNPTXSTS/
HPTXFSIZ registers for
available FIFO and
queue spaces
W ait for
TXFELVL or PTXFELVL 1 MPS
interrupt in No or LPS FIFO space
OTG_FS_GAHBCFG Yes
available?
Yes
W rite 1 packet
data to
Transmit FIFO
More packets
to send?
No
Start
No
RXFLVL
interrupt ?
Yes
PKTSTS
No
0b0010?
No
Yes
Yes
BCNT > 0?
ai15674
ch_2 D AT A0
MPS
3
AC K
set _ch_en
(ch _2) IN
4
D AT A0
5
RXFLVL interrupt
ACK
1 ch_1
read_rx_sts
read_rx_fifo
MPS
O UT
ch_2
set _ch_en
(ch _2) ch_2 D AT A1
MPS
ch_2
7 ACK
XFRC interrupt
6
De-allocate IN
(ch_1)
D AT A1
RXFLVL interrupt
1 6 ACK
read_rx_stsre
MPS
ad_rx_fifo
Disable
(ch _2) 9
RXFLVL interrupt
read_rx_sts 11 10
CHH interrupt
r
De-allocate 12
(ch _2) 13
ai15675
The channel-specific interrupt service routine for bulk and control OUT/SETUP
transactions in Slave mode is shown in the following code samples.
● Interrupt service routine for bulk/control OUT/SETUP and bulk/control IN
transactions
a) Bulk/Control OUT/SETUP
Unmask (NAK/TXERR/STALL/XFRC)
if (XFRC)
{
Reset Error Count
Mask ACK
De-allocate Channel
}
else if (STALL)
{
Transfer Done = 1
Unmask CHH
Disable Channel
}
else if (NAK or TXERR )
{
Rewind Buffer Pointers
Unmask CHH
Disable Channel
if (TXERR)
{
Increment Error Count
Unmask ACK
}
else
{
Reset Error Count
}
}
else if (CHH)
{
Mask CHH
if (Transfer Done or (Error_count == 3))
{
De-allocate Channel
}
else
{
Re-initialize Channel
}
}
else if (ACK)
{
Reset Error Count
Mask ACK
}
The application is expected to write the data packets into the transmit FIFO as and
when the space is available in the transmit FIFO and the Request queue. The
application can make use of the NPTXFE interrupt in OTG_FS_GINTSTS to find the
transmit FIFO space.
b) Bulk/Control IN
Unmask (TXERR/XFRC/BBERR/STALL/DTERR)
if (XFRC)
{
Reset Error Count
Unmask CHH
Disable Channel
Reset Error Count
Mask ACK
}
else if (TXERR or BBERR or STALL)
{
Unmask CHH
Disable Channel
if (TXERR)
{
Increment Error Count
Unmask ACK
}
}
else if (CHH)
{
Mask CHH
if (Transfer Done or (Error_count == 3))
{
De-allocate Channel
}
else
{
Re-initialize Channel
}
}
else if (ACK)
{
Reset Error Count
Mask ACK
}
else if (DTERR)
{
Reset Error Count
}
The application is expected to write the requests as and when the Request queue space is
available and until the XFRC interrupt is received.
● Bulk and control IN transactions
A typical bulk or control IN pipelined transaction-level operation is shown in Figure 273.
See channel 2 (ch_2). The assumptions are:
– The application is attempting to receive two maximum-packet-size packets
(transfer size = 1 024 bytes).
– The receive FIFO can contain at least one maximum-packet-size packet and two
status DWORDs per packet (72 bytes for FS).
– The non-periodic request queue depth = 4.
ch_2 D AT A0
MPS
3
AC K
set _ch_en
(ch _2) IN
4
D AT A0
5
RXFLVL interrupt
ACK
1 ch_1
read_rx_sts
read_rx_fifo
MPS
O UT
ch_2
set _ch_en
(ch _2) ch_2 D AT A1
MPS
ch_2
7 ACK
XFRC interrupt
6
De-allocate IN
(ch_1)
D AT A1
RXFLVL interrupt
1 6 ACK
read_rx_stsre
MPS
ad_rx_fifo
Disable
(ch _2) 9
RXFLVL interrupt
read_rx_sts 11 10
CHH interrupt
r
De-allocate 12
(ch _2) 13
ai15675
f) The core generates the RXFLVL interrupt for the transfer completion status entry
in the receive FIFO.
g) The application must read and ignore the receive packet status when the receive
packet status is not an IN data packet (PKTSTS in GRXSTSR 0b0010).
h) The core generates the XFRC interrupt as soon as the receive packet status is
read.
i) In response to the XFRC interrupt, disable the channel and stop writing the
OTG_FS_HCCHAR2 register for further requests. The core writes a channel
disable request to the non-periodic request queue as soon as the
OTG_FS_HCCHAR2 register is written.
j) The core generates the RXFLVL interrupt as soon as the halt status is written to
the receive FIFO.
k) Read and ignore the receive packet status.
l) The core generates a CHH interrupt as soon as the halt status is popped from the
receive FIFO.
m) In response to the CHH interrupt, de-allocate the channel for other transfers.
n) Handling non-ACK responses
● Control transactions in slave mode
Setup, Data, and Status stages of a control transfer must be performed as three
separate transfers. Setup-, Data- or Status-stage OUT transactions are performed
similarly to the bulk OUT transactions explained previously. Data- or Status-stage IN
transactions are performed similarly to the bulk IN transactions explained previously.
For all three stages, the application is expected to set the EPTYP field in
OTG_FS_HCCHAR1 to Control. During the Setup stage, the application is expected to
set the PID field in OTG_FS_HCTSIZ1 to SETUP.
● Interrupt OUT transactions
A typical interrupt OUT operation in Slave mode is shown in Figure 274. The
assumptions are:
– The application is attempting to send one packet in every frame (up to 1 maximum
packet size), starting with the odd frame (transfer size = 1 024 bytes)
– The periodic transmit FIFO can hold one packet (1 KB)
– Periodic request queue depth = 4
The sequence of operations is as follows:
a) Initialize and enable channel 1. The application must set the ODDFRM bit in
OTG_FS_HCCHAR1.
b) Write the first packet for channel 1. For a high-bandwidth interrupt transfer, the
application must write the subsequent packets up to MCNT (maximum number of
packets to be transmitted in the next frame times) before switching to another
channel.
c) Along with the last DWORD write of each packet, the OTG_FS host writes an entry
to the periodic request queue.
d) The OTG_FS host attempts to send an OUT token in the next (odd) frame.
e) The OTG_FS host generates an XFRC interrupt as soon as the last packet is
transmitted successfully.
f) In response to the XFRC interrupt, reinitialize the channel for the next transfer.
OU T Odd
(micro)
DATA0
frame
M PS
5
6 XFRC interrupt ACK
init _reg(ch_1) 4 IN
write_tx_fifo
(ch_1) 1 5
MPS DATA0
RXFLVL interrupt
ACK
read_rx_sts
read_rx_fifo
1
6 MPS
RXFLVL interrupt
read_rx_sts ch_1
7 8
XFRC interrupt
ch_2
init_reg(ch _2)
9
set_ch_en
(ch_2)
Even
OU T (micro)
XFRC interrupt frame
DATA1
init _reg(ch_1)
MPS
write_tx_fifo 1
ACK
(ch_1) MPS
IN
DATA1
ai15676
Disable Channel
if (STALL)
{
Transfer Done = 1
}
}
else
if (NAK or TXERR)
{
Rewind Buffer Pointers
Reset Error Count
Mask ACK
Unmask CHH
Disable Channel
}
else
if (CHH)
{
Mask CHH
if (Transfer Done or (Error_count == 3))
{
De-allocate Channel
}
else
{
Re-initialize Channel (in next b_interval - 1 Frame)
}
}
else
if (ACK)
{
Reset Error Count
Mask ACK
}
The application is expected to write the data packets into the transmit FIFO when the
space is available in the transmit FIFO and the Request queue up to the count
specified in the MCNT field before switching to another channel. The application uses
the NPTXFE interrupt in OTG_FS_GINTSTS to find the transmit FIFO space.
b) Interrupt IN
Unmask (NAK/TXERR/XFRC/BBERR/STALL/FRMOR/DTERR)
if (XFRC)
{
Reset Error Count
Mask ACK
if (OTG_FS_HCTSIZx.PKTCNT == 0)
{
De-allocate Channel
}
else
{
Transfer Done = 1
Unmask CHH
Disable Channel
}
}
else
if (STALL or FRMOR or NAK or DTERR or BBERR)
{
Mask ACK
Unmask CHH
Disable Channel
if (STALL or BBERR)
{
Reset Error Count
Transfer Done = 1
}
else
if (!FRMOR)
{
Reset Error Count
}
}
else
if (TXERR)
{
Increment Error Count
Unmask ACK
Unmask CHH
Disable Channel
}
else
if (CHH)
{
Mask CHH
if (Transfer Done or (Error_count == 3))
{
De-allocate Channel
}
else
Re-initialize Channel (in next b_interval - 1 /Frame)
}
}
else
if (ACK)
{
Reset Error Count
Mask ACK
}
The application is expected to write the requests for the same channel when the
Request queue space is available up to the count specified in the MCNT field before
switching to another channel (if any).
● Interrupt IN transactions
The assumptions are:
– The application is attempting to receive one packet (up to 1 maximum packet size)
in every frame, starting with odd (transfer size = 1 024 bytes).
– The receive FIFO can hold at least one maximum-packet-size packet and two
status DWORDs per packet (1 031 bytes).
– Periodic request queue depth = 4.
● Normal interrupt IN operation
The sequence of operations is as follows:
a) Initialize channel 2. The application must set the ODDFRM bit in
OTG_FS_HCCHAR2.
b) Set the CHENA bit in OTG_FS_HCCHAR2 to write an IN request to the periodic
request queue. For a high-bandwidth interrupt transfer, the application must write
the OTG_FS_HCCHAR2 register MCNT (maximum number of expected packets
in the next frame times) before switching to another channel.
c) The OTG_FS host writes an IN request to the periodic request queue for each
OTG_FS_HCCHAR2 register write with the CHENA bit set.
d) The OTG_FS host attempts to send an IN token in the next (odd) frame.
e) As soon as the IN packet is received and written to the receive FIFO, the OTG_FS
host generates an RXFLVL interrupt.
f) In response to the RXFLVL interrupt, read the received packet status to determine
the number of bytes received, then read the receive FIFO accordingly. The
application must mask the RXFLVL interrupt before reading the receive FIFO, and
unmask after reading the entire packet.
g) The core generates the RXFLVL interrupt for the transfer completion status entry
in the receive FIFO. The application must read and ignore the receive packet
status when the receive packet status is not an IN data packet (PKTSTS in
GRXSTSR 0b0010).
h) The core generates an XFRC interrupt as soon as the receive packet status is
read.
i) In response to the XFRC interrupt, read the PKTCNT field in OTG_FS_HCTSIZ2.
If the PKTCNT bit in OTG_FS_HCTSIZ2 is not equal to 0, disable the channel
before re-initializing the channel for the next transfer, if any). If PKTCNT bit in
OTG_FS_HCTSIZ2 = 0, reinitialize the channel for the next transfer. This time, the
application must reset the ODDFRM bit in OTG_FS_HCCHAR2.
OU T Odd
(micro)
DATA0
frame
M PS
5
6 XFRC interrupt ACK
init _reg(ch_1) 4 IN
write_tx_fifo
(ch_1) 1 5
MPS DATA0
RXFLVL interrupt
ACK
read_rx_sts
read_rx_fifo
1
6 MPS
RXFLVL interrupt
read_rx_sts ch_1
7 8
XFRC interrupt
ch_2
init_reg(ch _2)
9
set_ch_en
(ch_2)
Even
OU T (micro)
XFRC interrupt frame
DATA1
init _reg(ch_1)
MPS
write_tx_fifo 1
ACK
(ch_1) MPS
IN
DATA1
ai15676
if (CHH)
{
Mask CHH
De-allocate Channel
}
Code sample: Isochronous IN
Unmask (TXERR/XFRC/FRMOR/BBERR)
if (XFRC or FRMOR)
{
if (XFRC and (OTG_FS_HCTSIZx.PKTCNT == 0))
{
Reset Error Count
De-allocate Channel
}
else
{
Unmask CHH
Disable Channel
}
}
else
if (TXERR or BBERR)
{
Increment Error Count
Unmask CHH
Disable Channel
}
else
if (CHH)
{
Mask CHH
if (Transfer Done or (Error_count == 3))
{
De-allocate Channel
}
else
{
Re-initialize Channel
}
}
● Isochronous IN transactions
The assumptions are:
– The application is attempting to receive one packet (up to 1 maximum packet size)
in every frame starting with the next odd frame (transfer size = 1 024 bytes).
– The receive FIFO can hold at least one maximum-packet-size packet and two
status DWORDs per packet (1 031 bytes).
– Periodic request queue depth = 4.
The sequence of operations is as follows:
a) Initialize channel 2. The application must set the ODDFRM bit in
OTG_FS_HCCHAR2.
b) Set the CHENA bit in OTG_FS_HCCHAR2 to write an IN request to the periodic
request queue. For a high-bandwidth isochronous transfer, the application must
write the OTG_FS_HCCHAR2 register MCNT (maximum number of expected
packets in the next frame times) before switching to another channel.
c) The OTG_FS host writes an IN request to the periodic request queue for each
OTG_FS_HCCHAR2 register write with the CHENA bit set.
d) The OTG_FS host attempts to send an IN token in the next odd frame.
e) As soon as the IN packet is received and written to the receive FIFO, the OTG_FS
host generates an RXFLVL interrupt.
f) In response to the RXFLVL interrupt, read the received packet status to determine
the number of bytes received, then read the receive FIFO accordingly. The
application must mask the RXFLVL interrupt before reading the receive FIFO, and
unmask it after reading the entire packet.
g) The core generates an RXFLVL interrupt for the transfer completion status entry in
the receive FIFO. This time, the application must read and ignore the receive
packet status when the receive packet status is not an IN data packet (PKTSTS bit
in OTG_FS_GRXSTSR 0b0010).
h) The core generates an XFRC interrupt as soon as the receive packet status is
read.
i) In response to the XFRC interrupt, read the PKTCNT field in OTG_FS_HCTSIZ2.
If PKTCNT 0 in OTG_FS_HCTSIZ2, disable the channel before re-initializing the
channel for the next transfer, if any. If PKTCNT = 0 in OTG_FS_HCTSIZ2,
reinitialize the channel for the next transfer. This time, the application must reset
the ODDFRM bit in OTG_FS_HCCHAR2.
● Selecting the queue depth
Choose the periodic and non-periodic request queue depths carefully to match the
number of periodic/non-periodic endpoints accessed.
The non-periodic request queue depth affects the performance of non-periodic
transfers. The deeper the queue (along with sufficient FIFO size), the more often the
core is able to pipeline non-periodic transfers. If the queue size is small, the core is able
to put in new requests only when the queue space is freed up.
The core’s periodic request queue depth is critical to perform periodic transfers as
scheduled. Select the periodic queue depth, based on the number of periodic transfers
scheduled in a microframe. In Slave mode, however, the application must also take into
account the disable entry that must be put into the queue. So, if there are two non-high-
bandwidth periodic endpoints, the periodic request queue depth must be at least 4. If at
least one high-bandwidth endpoint is supported, the queue depth must be 8. If the
periodic request queue depth is smaller than the periodic transfers scheduled in a
microframe, a frame overrun condition occurs.
● Handling babble conditions
OTG_FS controller handles two cases of babble: packet babble and port babble.
Packet babble occurs if the device sends more data than the maximum packet size for
the channel. Port babble occurs if the core continues to receive data from the device at
EOF2 (the end of frame 2, which is very close to SOF).
When OTG_FS controller detects a packet babble, it stops writing data into the Rx
buffer and waits for the end of packet (EOP). When it detects an EOP, it flushes already
written data in the Rx buffer and generates a Babble interrupt to the application.
When OTG_FS controller detects a port babble, it flushes the RxFIFO and disables the
port. The core then generates a Port disabled interrupt (HPRTINT in
OTG_FS_GINTSTS, PENCHNG in OTG_FS_HPRT). On receiving this interrupt, the
application must determine that this is not due to an overcurrent condition (another
cause of the Port Disabled interrupt) by checking POCA in OTG_FS_HPRT, then
perform a soft reset. The core does not send any more tokens after it has detected a
port babble condition.
Endpoint activation
This section describes the steps required to activate a device endpoint or to configure an
existing device endpoint to a new type.
1. Program the characteristics of the required endpoint into the following fields of the
OTG_FS_DIEPCTLx register (for IN or bidirectional endpoints) or the
OTG_FS_DOEPCTLx register (for OUT or bidirectional endpoints).
– Maximum packet size
– USB active endpoint = 1
– Endpoint start data toggle (for interrupt and bulk endpoints)
– Endpoint type
– TxFIFO number
2. Once the endpoint is activated, the core starts decoding the tokens addressed to that
endpoint and sends out a valid handshake for each valid token received for the
endpoint.
Endpoint deactivation
This section describes the steps required to deactivate an existing endpoint.
1. In the endpoint to be deactivated, clear the USB active endpoint bit in the
OTG_FS_DIEPCTLx register (for IN or bidirectional endpoints) or the
OTG_FS_DOEPCTLx register (for OUT or bidirectional endpoints).
2. Once the endpoint is deactivated, the core ignores tokens addressed to that endpoint,
which results in a timeout on the USB.
Note: 1 The application must meet the following conditions to set up the device core to handle traffic:
NPTXFEM and RXFLVLM in GINTMSK must be cleared.
Y rd_data.BCNT = 0 rcv_out_pkt ()
dword_cnt =
packet mem[0:dword_cnt-1] = BCNT[11:2]
C +
store in rd_rxfifo(rd_data.EPNUM, (BCNT[1] | BCNT[1])
memory dword_cnt )
ai15677
● SETUP transactions
This section describes how the core handles SETUP packets and the application’s
sequence for handling SETUP transactions.
● Application requirements
1. To receive a SETUP packet, the STUPCNT field (OTG_FS_DOEPTSIZx) in a control
OUT endpoint must be programmed to a non-zero value. When the application
programs the STUPCNT field to a non-zero value, the core receives SETUP packets
and writes them to the receive FIFO, irrespective of the NAK status and EPENA bit
setting in OTG_FS_DOEPCTLx. The STUPCNT field is decremented every time the
control endpoint receives a SETUP packet. If the STUPCNT field is not programmed to
a proper value before receiving a SETUP packet, the core still receives the SETUP
packet and decrements the STUPCNT field, but the application may not be able to
determine the correct number of SETUP packets received in the Setup stage of a
control transfer.
– STUPCNT = 3 in OTG_FS_DOEPTSIZx
2. The application must always allocate some extra space in the Receive data FIFO, to be
able to receive up to three SETUP packets on a control endpoint.
– The space to be reserved is 10 DWORDs. Three DWORDs are required for the
first SETUP packet, 1 DWORD is required for the Setup stage done DWORD and
6 DWORDs are required to store two extra SETUP packets among all control
endpoints.
– 3 DWORDs per SETUP packet are required to store 8 bytes of SETUP data and 4
bytes of SETUP status (Setup packet pattern). The core reserves this space in the
receive data.
– FIFO to write SETUP data only, and never uses this space for data packets.
3. The application must read the 2 DWORDs of the SETUP packet from the receive FIFO.
4. The application must read and discard the Setup stage done DWORD from the receive
FIFO.
● Internal data flow
5. When a SETUP packet is received, the core writes the received data to the receive
FIFO, without checking for available space in the receive FIFO and irrespective of the
endpoint’s NAK and STALL bit settings.
– The core internally sets the IN NAK and OUT NAK bits for the control IN/OUT
endpoints on which the SETUP packet was received.
6. For every SETUP packet received on the USB, 3 DWORDs of data are written to the
receive FIFO, and the STUPCNT field is decremented by 1.
– The first DWORD contains control information used internally by the core
– The second DWORD contains the first 4 bytes of the SETUP command
– The third DWORD contains the last 4 bytes of the SETUP command
7. When the Setup stage changes to a Data IN/OUT stage, the core writes an entry
(Setup stage done DWORD) to the receive FIFO, indicating the completion of the Setup
stage.
8. On the AHB side, SETUP packets are emptied by the application.
9. When the application pops the Setup stage done DWORD from the receive FIFO, the
core interrupts the application with an STUP interrupt (OTG_FS_DOEPINTx),
indicating it can process the received SETUP packet.
– The core clears the endpoint enable bit for control OUT endpoints.
rem_supcnt =
rd_reg(DOEPTSIZx)
2-stage
ai15678
3. When the application pops the Global OUT NAK pattern DWORD from the receive
FIFO, the core sets the GONAKEFF interrupt (OTG_FS_GINTSTS).
4. Once the application detects this interrupt, it can assume that the core is in Global OUT
NAK mode. The application can clear this interrupt by clearing the SGONAK bit in
OTG_FS_DCTL.
Application programming sequence
1. To stop receiving any kind of data in the receive FIFO, the application must set the
Global OUT NAK bit by programming the following field:
– SGONAK = 1 in OTG_FS_DCTL
2. Wait for the assertion of the GONAKEFF interrupt in OTG_FS_GINTSTS. When
asserted, this interrupt indicates that the core has stopped receiving any type of data
except SETUP packets.
3. The application can receive valid OUT packets after it has set SGONAK in
OTG_FS_DCTL and before the core asserts the GONAKEFF interrupt
(OTG_FS_GINTSTS).
4. The application can temporarily mask this interrupt by writing to the GINAKEFFM bit in
GINTMSK.
– GINAKEFFM = 0 in GINTMSK
5. Whenever the application is ready to exit the Global OUT NAK mode, it must clear the
SGONAK bit in OTG_FS_DCTL. This also clears the GONAKEFF interrupt
(OTG_FS_GINTSTS).
– OTG_FS_DCTL = 1 in CGONAK
6. If the application has masked this interrupt earlier, it must be unmasked as follows:
– GINAKEFFM = 1 in GINTMSK
● Disabling an OUT endpoint
The application must use this sequence to disable an OUT endpoint that it has enabled.
Application programming sequence:
1. Before disabling any OUT endpoint, the application must enable Global OUT NAK
mode in the core.
– SGONAK = 1 in OTG_FS_DCTL
2. Wait for the GONAKEFF interrupt (OTG_FS_GINTSTS)
3. Disable the required OUT endpoint by programming the following fields:
– EPDIS = 1 in OTG_FS_DOEPCTLx
– SNAK = 1 in OTG_FS_DOEPCTLx
4. Wait for the EPDISD interrupt (OTG_FS_DOEPINTx), which indicates that the OUT
endpoint is completely disabled. When the EPDISD interrupt is asserted, the core also
clears the following bits:
– EPDIS = 0 in OTG_FS_DOEPCTLx
– EPENA = 0 in OTG_FS_DOEPCTLx
5. The application must clear the Global OUT NAK bit to start receiving data from other
non-disabled OUT endpoints.
– SGONAK = 0 in OTG_FS_DCTL
5. At the end of every packet write on the AHB to external memory, the transfer size for
the endpoint is decremented by the size of the written packet.
6. The OUT data transfer completed pattern for an OUT endpoint is written to the receive
FIFO on one of the following conditions:
– The transfer size is 0 and the packet count is 0
– The last OUT data packet written to the receive FIFO is a short packet
(0 packet size < maximum packet size)
7. When either the application pops this entry (OUT data transfer completed), a transfer
completed interrupt is generated for the endpoint and the endpoint enable is cleared.
Application programming sequence:
1. Program the OTG_FS_DOEPTSIZx register for the transfer size and the corresponding
packet count.
2. Program the OTG_FS_DOEPCTLx register with the endpoint characteristics, and set
the EPENA and CNAK bits.
– EPENA = 1 in OTG_FS_DOEPCTLx
– CNAK = 1 in OTG_FS_DOEPCTLx
3. Wait for the RXFLVL interrupt (in OTG_FS_GINTSTS) and empty the data packets from
the receive FIFO.
– This step can be repeated many times, depending on the transfer size.
4. Asserting the XFRC interrupt (OTG_FS_DOEPINTx) marks a successful completion of
the non-isochronous OUT data transfer.
5. Read the OTG_FS_DOEPTSIZx register to determine the size of the received data
payload.
● Generic isochronous OUT data transfer
This section describes a regular isochronous OUT data transfer.
Application requirements:
1. All the application requirements for non-isochronous OUT data transfers also apply to
isochronous OUT data transfers.
2. For isochronous OUT data transfers, the transfer size and packet count fields must
always be set to the number of maximum-packet-size packets that can be received in a
single frame and no more. Isochronous OUT data transfers cannot span more than 1
frame.
3. The application must read all isochronous OUT data packets from the receive FIFO
(data and status) before the end of the periodic frame (EOPF interrupt in
OTG_FS_GINTSTS).
4. To receive data in the following frame, an isochronous OUT endpoint must be enabled
after the EOPF (OTG_FS_GINTSTS) and before the SOF (OTG_FS_GINTSTS).
Internal data flow:
1. The internal data flow for isochronous OUT endpoints is the same as that for non-
isochronous OUT endpoints, but for a few differences.
2. When an isochronous OUT endpoint is enabled by setting the Endpoint Enable and
clearing the NAK bits, the Even/Odd frame bit must also be set appropriately. The core
receives data on an isochronous OUT endpoint in a particular frame only if the
following condition is met:
– EONUM (in OTG_FS_DOEPCTLx) = SOFFN[0] (in OTG_FS_DSTS)
3. When the application completely reads an isochronous OUT data packet (data and
status) from the receive FIFO, the core updates the RXDPID field in
OTG_FS_DOEPTSIZx with the data PID of the last isochronous OUT data packet read
from the receive FIFO.
Application programming sequence:
1. Program the OTG_FS_DOEPTSIZx register for the transfer size and the corresponding
packet count
2. Program the OTG_FS_DOEPCTLx register with the endpoint characteristics and set
the Endpoint Enable, ClearNAK, and Even/Odd frame bits.
– EPENA = 1
– CNAK = 1
– EONUM = (0: Even/1: Odd)
3. In Slave mode, wait for the RXFLVL interrupt (in OTG_FS_GINTSTS) and empty the
data packets from the receive FIFO
– This step can be repeated many times, depending on the transfer size.
4. The assertion of the XFRC interrupt (in OTG_FS_DOEPINTx) marks the completion of
the isochronous OUT data transfer. This interrupt does not necessarily mean that the
data in memory are good.
5. This interrupt cannot always be detected for isochronous OUT transfers. Instead, the
application can detect the IISOOXFRM interrupt in OTG_FS_GINTSTS.
6. Read the OTG_FS_DOEPTSIZx register to determine the size of the received transfer
and to determine the validity of the data received in the frame. The application must
treat the data received in memory as valid only if one of the following conditions is met:
– RXDPID = D0 (in OTG_FS_DOEPTSIZx) and the number of USB packets in
which this payload was received = 1
– RXDPID = D1 (in OTG_FS_DOEPTSIZx) and the number of USB packets in
which this payload was received = 2
– RXDPID = D2 (in OTG_FS_DOEPTSIZx) and the number of USB packets in
which this payload was received = 3
The number of USB packets in which this payload was received =
Application programmed initial packet count – Core updated final packet count
The application can discard invalid data packets.
● Incomplete isochronous OUT data transfers
This section describes the application programming sequence when isochronous OUT data
packets are dropped inside the core.
Internal data flow:
1. For isochronous OUT endpoints, the XFRC interrupt (in OTG_FS_DOEPINTx) may not
always be asserted. If the core drops isochronous OUT data packets, the application
could fail to detect the XFRC interrupt (OTG_FS_DOEPINTx) under the following
circumstances:
– When the receive FIFO cannot accommodate the complete ISO OUT data packet,
the core drops the received ISO OUT data
– When the isochronous OUT data packet is received with CRC errors
– When the isochronous OUT token received by the core is corrupted
– When the application is very slow in reading the data from the receive FIFO
2. When the core detects an end of periodic frame before transfer completion to all
isochronous OUT endpoints, it asserts the incomplete Isochronous OUT data interrupt
(IISOOXFRM in OTG_FS_GINTSTS), indicating that an XFRC interrupt (in
OTG_FS_DOEPINTx) is not asserted on at least one of the isochronous OUT
endpoints. At this point, the endpoint with the incomplete transfer remains enabled, but
no active transfers remain in progress on this endpoint on the USB.
Application programming sequence:
1. Asserting the IISOOXFRM interrupt (OTG_FS_GINTSTS) indicates that in the current
frame, at least one isochronous OUT endpoint has an incomplete transfer.
2. If this occurs because isochronous OUT data is not completely emptied from the
endpoint, the application must ensure that the application empties all isochronous OUT
data (data and status) from the receive FIFO before proceeding.
– When all data are emptied from the receive FIFO, the application can detect the
XFRC interrupt (OTG_FS_DOEPINTx). In this case, the application must re-
enable the endpoint to receive isochronous OUT data in the next frame.
3. When it receives an IISOOXFRM interrupt (in OTG_FS_GINTSTS), the application
must read the control registers of all isochronous OUT endpoints
(OTG_FS_DOEPCTLx) to determine which endpoints had an incomplete transfer in the
current microframe. An endpoint transfer is incomplete if both the following conditions
are met:
– EONUM bit (in OTG_FS_DOEPCTLx) = SOFFN[0] (in OTG_FS_DSTS)
– EPENA = 1 (in OTG_FS_DOEPCTLx)
4. The previous step must be performed before the SOF interrupt (in OTG_FS_GINTSTS)
is detected, to ensure that the current frame number is not changed.
5. For isochronous OUT endpoints with incomplete transfers, the application must discard
the data in the memory and disable the endpoint by setting the EPDIS bit in
OTG_FS_DOEPCTLx.
6. Wait for the EPDIS interrupt (in OTG_FS_DOEPINTx) and enable the endpoint to
receive new data in the next frame.
– Because the core can take some time to disable the endpoint, the application may
not be able to receive the data in the next frame after receiving bad isochronous
data.
● Stalling a non-isochronous OUT endpoint
This section describes how the application can stall a non-isochronous endpoint.
1. Put the core in the Global OUT NAK mode.
2. Disable the required endpoint
– When disabling the endpoint, instead of setting the SNAK bit in
OTG_FS_DOEPCTL, set STALL = 1 (in OTG_FS_DOEPCTL).
The STALL bit always takes precedence over the NAK bit.
3. When the application is ready to end the STALL handshake for the endpoint, the STALL
bit (in OTG_FS_DOEPCTLx) must be cleared.
4. If the application is setting or clearing a STALL for an endpoint due to a
SetFeature.Endpoint Halt or ClearFeature.Endpoint Halt command, the STALL bit must
be set or cleared before the application sets up the Status stage transfer on the control
endpoint.
Examples
This section describes and depicts some fundamental transfer types and scenarios.
● Slave mode bulk OUT transaction
Figure 278 depicts the reception of a single Bulk OUT Data packet from the USB to the AHB
and describes the events involved in the process.
init_ out_ ep
XFRSIZ = 512 bytes
1 PKTCNT = 1
2 wr_reg (DOEPTSIZx)
O UT EPENA= 1
CNAK = 1
3 wr_reg(D OEPCTLx)
512 bytes
4 6
xact _1
AC K RXFLVL iintr
D OE P C idle until intr
T L x.N A
5 PKTCN K = 1
T0
XFRSIZ
r =0 rcv_out _pkt()
On new xfer
OU T XF or RxFIFO
int r RC not empty
7
NA K
idle until intr
8
ai15679
IN data transfers
● Packet write
This section describes how the application writes data packets to the endpoint FIFO in Slave
mode when dedicated transmit FIFOs are enabled.
1. The application can either choose the polling or the interrupt mode.
– In polling mode, the application monitors the status of the endpoint transmit data
FIFO by reading the OTG_FS_DTXFSTSx register, to determine if there is enough
space in the data FIFO.
– In interrupt mode, the application waits for the TXFE interrupt (in
OTG_FS_DIEPINTx) and then reads the OTG_FS_DTXFSTSx register, to
determine if there is enough space in the data FIFO.
– To write a single non-zero length data packet, there must be space to write the
entire packet in the data FIFO.
– To write zero length packet, the application must not look at the FIFO space.
2. Using one of the above mentioned methods, when the application determines that
there is enough space to write a transmit packet, the application must first write into the
endpoint control register, before writing the data into the data FIFO. Typically, the
application, must do a read modify write on the OTG_FS_DIEPCTLx register to avoid
modifying the contents of the register, except for setting the Endpoint Enable bit.
The application can write multiple packets for the same endpoint into the transmit FIFO, if
space is available. For periodic IN endpoints, the application must write packets only for one
microframe. It can write packets for the next periodic transaction only after getting transfer
complete for the previous transaction.
● Setting IN endpoint NAK
Internal data flow:
1. When the application sets the IN NAK for a particular endpoint, the core stops
transmitting data on the endpoint, irrespective of data availability in the endpoint’s
transmit FIFO.
2. Non-isochronous IN tokens receive a NAK handshake reply
– Isochronous IN tokens receive a zero-data-length packet reply
3. The core asserts the INEPNE (IN endpoint NAK effective) interrupt in
OTG_FS_DIEPINTx in response to the SNAK bit in OTG_FS_DIEPCTLx.
4. Once this interrupt is seen by the application, the application can assume that the
endpoint is in IN NAK mode. This interrupt can be cleared by the application by setting
the CNAK bit in OTG_FS_DIEPCTLx.
Application programming sequence:
1. To stop transmitting any data on a particular IN endpoint, the application must set the
IN NAK bit. To set this bit, the following field must be programmed.
– SNAK = 1 in OTG_FS_DIEPCTLx
2. Wait for assertion of the INEPNE interrupt in OTG_FS_DIEPINTx. This interrupt
indicates that the core has stopped transmitting data on the endpoint.
3. The core can transmit valid IN data on the endpoint after the application has set the
NAK bit, but before the assertion of the NAK Effective interrupt.
4. The application can mask this interrupt temporarily by writing to the INEPNEM bit in
DIEPMSK.
– INEPNEM = 0 in DIEPMSK
5. To exit Endpoint NAK mode, the application must clear the NAK status bit (NAKSTS) in
OTG_FS_DIEPCTLx. This also clears the INEPNE interrupt (in OTG_FS_DIEPINTx).
– CNAK = 1 in OTG_FS_DIEPCTLx
6. If the application masked this interrupt earlier, it must be unmasked as follows:
– INEPNEM = 1 in DIEPMSK
● IN endpoint disable
Use the following sequence to disable a specific IN endpoint that has been previously
enabled.
Application programming sequence:
1. The application must stop writing data on the AHB for the IN endpoint to be disabled.
2. The application must set the endpoint in NAK mode.
– SNAK = 1 in OTG_FS_DIEPCTLx
3. Wait for the INEPNE interrupt in OTG_FS_DIEPINTx.
4. Set the following bits in the OTG_FS_DIEPCTLx register for the endpoint that must be
disabled.
– EPDIS = 1 in OTG_FS_DIEPCTLx
– SNAK = 1 in OTG_FS_DIEPCTLx
5. Assertion of the EPDISD interrupt in OTG_FS_DIEPINTx indicates that the core has
completely disabled the specified endpoint. Along with the assertion of the interrupt,
the core also clears the following bits:
– EPENA = 0 in OTG_FS_DIEPCTLx
– EPDIS = 0 in OTG_FS_DIEPCTLx
6. The application must read the OTG_FS_DIEPTSIZx register for the periodic IN EP, to
calculate how much data on the endpoint were transmitted on the USB.
7. The application must flush the data in the Endpoint transmit FIFO, by setting the
following fields in the OTG_FS_GRSTCTL register:
– TXFNUM (in OTG_FS_GRSTCTL) = Endpoint transmit FIFO number
– TXFFLSH in (OTG_FS_GRSTCTL) = 1
The application must poll the OTG_FS_GRSTCTL register, until the TXFFLSH bit is cleared
by the core, which indicates the end of flush operation. To transmit new data on this
endpoint, the application can re-enable the endpoint at a later point.
handshake, the packet count for the endpoint is decremented by one, until the packet
count is zero. The packet count is not decremented on a timeout.
5. For zero length packets (indicated by an internal zero length flag), the core sends out a
zero-length packet for the IN token and decrements the packet count field.
6. If there are no data in the FIFO for a received IN token and the packet count field for
that endpoint is zero, the core generates an “IN token received when TxFIFO is empty”
(ITTXFE) Interrupt for the endpoint, provided that the endpoint NAK bit is not set. The
core responds with a NAK handshake for non-isochronous endpoints on the USB.
7. The core internally rewinds the FIFO pointers and no timeout interrupt is generated.
8. When the transfer size is 0 and the packet count is 0, the transfer complete (XFRC)
interrupt for the endpoint is generated and the endpoint enable is cleared.
Application programming sequence:
1. Program the OTG_FS_DIEPTSIZx register with the transfer size and corresponding
packet count.
2. Program the OTG_FS_DIEPCTLx register with the endpoint characteristics and set the
CNAK and EPENA (Endpoint Enable) bits.
3. When transmitting non-zero length data packet, the application must poll the
OTG_FS_DTXFSTSx register (where x is the FIFO number associated with that
endpoint) to determine whether there is enough space in the data FIFO. The
application can optionally use TXFE (in OTG_FS_DIEPINTx) before writing the data.
● Generic periodic IN data transfers
This section describes a typical periodic IN data transfer.
Application requirements:
1. Application requirements 1, 2, 3, and 4 of Generic non-periodic IN data transfers on
page 825 also apply to periodic IN data transfers, except for a slight modification of
requirement 2.
– The application can only transmit multiples of maximum-packet-size data packets
or multiples of maximum-packet-size packets, plus a short packet at the end. To
transmit a few maximum-packet-size packets and a short packet at the end of the
transfer, the following conditions must be met:
transfer size[EPNUM] = x × MPSIZ[EPNUM] + sp
(where x is an integer 0, and 0 sp < MPSIZ[EPNUM])
If (sp > 0), packet count[EPNUM] = x + 1
Otherwise, packet count[EPNUM] = x;
MCNT[EPNUM] = packet count[EPNUM]
– The application cannot transmit a zero-length data packet at the end of a transfer.
It can transmit a single zero-length data packet by itself. To transmit a single zero-
length data packet:
– transfer size[EPNUM] = 0
packet count[EPNUM] = 1
MCNT[EPNUM] = packet count[EPNUM]
2. The application can only schedule data transfers one frame at a time.
– (MCNT – 1) × MPSIZ XFERSIZ MCNT × MPSIZ
– PKTCNT = MCNT (in OTG_FS_DIEPTSIZx)
– If XFERSIZ < MCNT × MPSIZ, the last data packet of the transfer is a short
packet.
– Note that: MCNT is in OTG_FS_DIEPTSIZx, MPSIZ is in OTG_FS_DIEPCTLx,
PKTCNT is in OTG_FS_DIEPTSIZx and XFERSIZ is in OTG_FS_DIEPTSIZx
3. The complete data to be transmitted in the frame must be written into the transmit FIFO
by the application, before the IN token is received. Even when 1 DWORD of the data to
be transmitted per frame is missing in the transmit FIFO when the IN token is received,
the core behaves as when the FIFO is empty. When the transmit FIFO is empty:
– A zero data length packet would be transmitted on the USB for isochronous IN
endpoints
– A NAK handshake would be transmitted on the USB for interrupt IN endpoints
4. For a high-bandwidth IN endpoint with three packets in a frame, the application can
program the endpoint FIFO size to be 2 × max_pkt_size and have the third packet
loaded in after the first packet has been transmitted on the USB.
Internal data flow:
1. The application must set the transfer size and packet count fields in the endpoint-
specific registers and enable the endpoint to transmit the data.
2. The application must also write the required data to the associated transmit FIFO for
the endpoint.
3. Every time the application writes a packet to the transmit FIFO, the transfer size for that
endpoint is decremented by the packet size. The data are fetched from application
memory until the transfer size for the endpoint becomes 0.
4. When an IN token is received for a periodic endpoint, the core transmits the data in the
FIFO, if available. If the complete data payload (complete packet, in dedicated FIFO
mode) for the frame is not present in the FIFO, then the core generates an IN token
received when TxFIFO empty interrupt for the endpoint.
– A zero-length data packet is transmitted on the USB for isochronous IN endpoints
– A NAK handshake is transmitted on the USB for interrupt IN endpoints
5. The packet count for the endpoint is decremented by 1 under the following conditions:
– For isochronous endpoints, when a zero- or non-zero-length data packet is
transmitted
– For interrupt endpoints, when an ACK handshake is transmitted
– When the transfer size and packet count are both 0, the transfer completed
interrupt for the endpoint is generated and the endpoint enable is cleared.
6. At the “Periodic frame Interval” (controlled by PFIVL in OTG_FS_DCFG), when the
core finds non-empty any of the isochronous IN endpoint FIFOs scheduled for the
current frame non-empty, the core generates an IISOIXFR interrupt in
OTG_FS_GINTSTS.
application receives this interrupt, it must set the STALL bit in the corresponding endpoint
control register, and clear this interrupt.
1 2 3 4 5 6 7 8
HCLK
PCLK
tkn_rcvd
dsynced_tkn_rcvd
spr_read
spr_addr A1
spr_rdata D1
srcbuf_push
srcbuf_rdata D1
5 Clocks
ai15680
Suspend 6
DRV_VBUS 1
2 5
VBUS_VALID
4 7
D+ 3 Data line pulsing Connect
D- Low
ai15681
B_VALID 2
DISCHRG_VBUS
4
SESS_END
5 8
DP
Data line pulsing Connect
DM
Low
7
VBUS pulsing
CHRG_VBUS
ai15682
Suspend 2 4 5 6 8
DM Traffic
DPPULLDOWN
DMPULLDOWN
ai15683
1. DPPULLDOWN = signal from core to PHY to enable/disable the pull-down on the DP line inside the PHY.
DMPULLDOWN = signal from core to PHY to enable/disable the pull-down on the DM line inside the PHY.
1. The OTG_FS controller sends the B-device a SetFeature b_hnp_enable descriptor to
enable HNP support. The B-device’s ACK response indicates that the B-device
supports HNP. The application must set Host Set HNP Enable bit in the OTG Control
and status register to indicate to the OTG_FS controller that the B-device supports
HNP.
2. When it has finished using the bus, the application suspends by writing the Port
suspend bit in the Host port control and status register.
3. When the B-device observes a USB suspend, it disconnects, indicating the initial
condition for HNP. The B-device initiates HNP only when it must switch to the host role;
otherwise, the bus continues to be suspended.
The OTG_FS controller sets the Host negotiation detected interrupt in the OTG
interrupt status register, indicating the start of HNP.
The OTG_FS controller deasserts the DM pull down and DM pull down in the PHY to
indicate a device role. The PHY enables the OTG_FS_DP pull-up resistor to indicate a
connect for B-device.
The application must read the current mode bit in the OTG Control and status register
to determine Device mode operation.
4. The B-device detects the connection, issues a USB reset, and enumerates the
OTG_FS controller for data traffic.
5. The B-device continues the host role, initiating traffic, and suspends the bus when
done.
The OTG_FS controller sets the early suspend bit in the Core interrupt register after 3
ms of bus idleness. Following this, the OTG_FS controller sets the USB Suspend bit in
the Core interrupt register.
6. In Negotiated mode, the OTG_FS controller detects the suspend, disconnects, and
switches back to the host role. The OTG_FS controller asserts the DM pull down and
DM pull down in the PHY to indicate its assumption of the host role.
7. The OTG_FS controller sets the Connector ID status change interrupt in the OTG
Interrupt Status register. The application must read the connector ID status in the OTG
Control and Status register to determine the OTG_FS controller operation as an A-
device. This indicates the completion of HNP to the application. The application must
read the Current mode bit in the OTG control and status register to determine Host
mode operation.
8. The B-device connects, completing the HNP process.
Suspend 2 4 5 6 8
DM Traffic
DPPULLDOWN
DMPULLDOWN
ai15684
1. DPPULLDOWN = signal from core to PHY to enable/disable the pull-down on the DP line inside the PHY.
DMPULLDOWN = signal from core to PHY to enable/disable the pull-down on the DM line inside the PHY.
1. The A-device sends the SetFeature b_hnp_enable descriptor to enable HNP support.
The OTG_FS controller’s ACK response indicates that it supports HNP. The application
must set the Device HNP enable bit in the OTG Control and status register to indicate
HNP support.
The application sets the HNP request bit in the OTG Control and status register to
indicate to the OTG_FS controller to initiate HNP.
2. When it has finished using the bus, the A-device suspends by writing the Port suspend
bit in the Host port control and status register.
The OTG_FS controller sets the Early suspend bit in the Core interrupt register after 3
ms of bus idleness. Following this, the OTG_FS controller sets the USB suspend bit in
the Core interrupt register.
The OTG_FS controller disconnects and the A-device detects SE0 on the bus,
indicating HNP. The OTG_FS controller asserts the DP pull down and DM pull down in
the PHY to indicate its assumption of the host role.
● Option to filter all error frames on reception and not forward them to the application in
Store-and-Forward mode
● Option to forward under-sized good frames
● Supports statistics by generating pulses for frames dropped or corrupted (due to
overflow) in the Receive FIFO
● Supports Store and Forward mechanism for transmission to the MAC core
● Automatic generation of PAUSE frame control or back pressure signal to the MAC core
based on Receive FIFO-fill (threshold configurable) level
● Handles automatic retransmission of Collision frames for transmission
● Discards frames on late collision, excessive collisions, excessive deferral and underrun
conditions
● Software control to flush Tx FIFO
● Calculates and inserts IPv4 header checksum and TCP, UDP, or ICMP checksum in
frames transmitted in Store-and-Forward mode
● Supports internal loopback on the MII for debugging
TX RX Media RMII
DMA Interface
DMA DMA Access
Select
FIFO FIFO Control
AHB Bus
MAC 802.3
MII
MDC
AHB Slave interface
DMA Operation
MAC MDIO
Control Mode
Control
& Status Register
Registers
Registers
ai15620
The application can select one of the 32 PHYs and one of the 32 registers within any PHY
and send control data or receive status information. Only one register in one PHY can be
addressed at any given time.
Both the MDC clock line and the MDIO data line are implemented as alternate function I/O
in the microcontroller:
● MDC: a periodic clock that provides the timing reference for the data transfer at the
maximum frequency of 2.5 MHz. The minimum high and low times for MDC must be
160 ns each, and the minimum period for MDC must be 400 ns. In idle state the SMI
management interface drives the MDC clock signal low.
● MDIO: data input/output bitstream to transfer status information to/from the PHY device
synchronously with the MDC clock signal
STM32
802.3 MAC
MDC
External
MDIO PHY
ai15621
Preamble
Start Operation PADDR RADDR TA Data (16 bits) Idle
(32 bits)
drives high-impedance on the MDIO line for the 2 bits of TA. The PHY device must
drive a high-impedance state on the first bit of TA, a zero bit on the second one.
For a write transaction, the MAC controller drives a <10> pattern during the TA field.
The PHY device must drive a high-impedance state for the 2 bits of TA.
● Data: the data field is 16-bit. The first bit transmitted and received must be bit 15 of the
ETH_MIID register.
● Idle: the MDIO line is driven in high-impedance state. All three-state drivers must be
disabled and the PHY’s pull-up resistor keeps the line at logic one.
MDC
Start
Preamble of OP PHY address Register address Turn data
code around
frame
MDC
Start
Preamble of OP PHY address Register address Turn data
code around
frame
TX _CLK
STM32 TXD[3:0]
TX_ER
TX_EN
802.3 MAC
RX_CLK
RXD[3:0]
RX_ER External
RX_DV PHY
CRS
COL
MDC
MDIO
ai15622
● MII_TX_CLK: continuous clock that provides the timing reference for the TX data
transfer. The nominal frequency is: 2.5 MHz at 10 Mbit/s speed; 25 MHz at 100 Mbit/s
speed.
● MII_RX_CLK: continuous clock that provides the timing reference for the RX data
transfer. The nominal frequency is: 2.5 MHz at 10 Mbit/s speed; 25 MHz at 100 Mbit/s
speed.
● MII_TX_EN: transmission enable indicates that the MAC is presenting nibbles on the
MII for transmission. It must be asserted synchronously (MII_TX_CLK) with the first
nibble of the preamble and must remain asserted while all nibbles to be transmitted are
presented to the MII.
● MII_TXD[3:0]: transmit data is a bundle of 4 data signals driven synchronously by the
MAC sublayer and qualified (valid data) on the assertion of the MII_TX_EN signal.
MII_TXD[0] is the least significant bit, MII_TXD[3] is the most significant bit. While
MII_TX_EN is deasserted the transmit data must have no effect upon the PHY.
● MII_CRS: carrier sense is asserted by the PHY when either the transmit or receive
medium is non idle. It shall be deasserted by the PHY when both the transmit and
receive media are idle. The PHY must ensure that the MII_CS signal remains asserted
throughout the duration of a collision condition. This signal is not required to transition
synchronously with respect to the TX and RX clocks. In full duplex mode the state of
this signal is don’t care for the MAC sublayer.
● MII_COL: collision detection must be asserted by the PHY upon detection of a collision
on the medium and must remain asserted while the collision condition persists. This
signal is not required to transition synchronously with respect to the TX and RX clocks.
In full duplex mode the state of this signal is don’t care for the MAC sublayer.
● MII_RXD[3:0]: reception data is a bundle of 4 data signals driven synchronously by the
PHY and qualified (valid data) on the assertion of the MII_RX_DV signal. MII_RXD[0] is
the least significant bit, MII_RXD[3] is the most significant bit. While MII_RX_EN is
deasserted and MII_RX_ER is asserted, a specific MII_RXD[3:0] value is used to
transfer specific information from the PHY (see Table 192).
● MII_RX_DV: receive data valid indicates that the PHY is presenting recovered and
decoded nibbles on the MII for reception. It must be asserted synchronously
(MII_RX_CLK) with the first recovered nibble of the frame and must remain asserted
through the final recovered nibble. It must be deasserted prior to the first clock cycle
that follows the final nibble. In order to receive the frame correctly, the MII_RX_DV
signal must encompass the frame, starting no later than the SFD field.
● MII_RX_ER: receive error must be asserted for one or more clock periods
(MII_RX_CLK) to indicate to the MAC sublayer that an error was detected somewhere
in the frame. This error condition must be qualified by MII_RX_DV assertion as
described in Table 192.
STM32
802.3 MAC
TX _CLK
External
PHY
25 MHz
RX _CLK
HSE
MCO
25 MHz
ai15623
STM32 TXD[1:0]
TX_EN
802.3 MAC
RXD[1:0]
External
CRS_DV PHY
MDC
MDIO
REF_CLK
Clock source
ai15624
STM32
802.3 MAC
External
PHY
25 MHz
PLL
REF_CLK
MCO
50 MHz
ai15625
MAC
0 MII
50 MHz Sync. divider
/2 for 100 Mb/s 1 RMII(1)
/20 for 10 Mb/s
MII_RX_CLK as AF 0 25 MHz MACRXCLK AHB
(25 MHz or 2.5 MHz) GPIO and AF 25 MHz or 2.5 MHz RX
1 or 2.5 MHz
controller
RMII_REF_CK as AF
(50 MHz)
RMII
HCLK HCLK
must be greater
than 25 MHz
ai15650
1. The MII/RMII selection is controlled through bit 23, MII_RMII_SEL, in the AFIO_MAPR register.
To save a pin, the two input clock signals, RMII_REF_CK and MII_RX_CLK, are multiplexed
on the same GPIO pin.
Figure 294 and Figure 295 describe the frame structure (untagged and tagged) that
includes the following fields:
● Preamble: 7-byte field used for synchronization purposes (PLS circuitry)
Hexadecimal value: 55-55-55-55-55-55-55
Bit pattern: 01010101 01010101 01010101 01010101 01010101 01010101 01010101
(right-to-left bit transmission)
● Start frame delimiter (SFD): 1-byte field used to indicate the start of a frame.
Hexadecimal value: D5
Bit pattern: 11010101 (right-to-left bit transmission)
● Destination and Source Address fields: 6-byte fields to indicate the destination and
source station addresses as follows (see Figure 293):
– Each address is 48 bits in length
– The first LSB bit (I/G) in the destination address field is used to indicate an
individual (I/G = 0) or a group address (I/G = 1). A group address could identify
none, one or more, or all the stations connected to the LAN. In the source address
the first bit is reserved and reset to 0.
– The second bit (U/L) distinguishes between locally (U/L = 1) or globally (U/L = 0)
administered addresses. For broadcast addresses this bit is also 1.
– Each byte of each address field must be transmitted least significant bit first.
The address designation is based on the following types:
● Individual address: this is the physical address associated with a particular station on
the network.
● Group address. A multidestination address associated with one or more stations on a
given network. There are two kinds of multicast address:
– Multicast-group address: an address associated with a group of logically related
stations.
– Broadcast address: a distinguished, predefined multicast address (all 1’s in the
destination address field) that always denotes all the stations on a given LAN.
● QTag Prefix: 4-byte field inserted between the Source address field and the MAC Client
Length/Type field. This field is an extension of the basic frame (untagged) to obtain the
tagged MAC frame. The untagged MAC frames do not include this field. The extensions
for tagging are as follows:
– 2-byte constant Length/Type field value consistent with the Type interpretation
(greater than 0x0600) equal to the value of the 802.1Q Tag Protocol Type (0x8100
hexadecimal). This constant field is used to distinguish tagged and untagged MAC
frames.
– 2-byte field containing the Tag control information field subdivided as follows: a 3-
bit user priority, a canonical format indicator (CFI) bit and a 12-bit VLAN Identifier.
The length of the tagged MAC frame is extended by 4 bytes by the QTag Prefix.
● MAC client length/type: 2-byte field with different meaning (mutually exclusive),
depending on its value:
– If the value is less than or equal to maxValidFrame (0d1500) then this field
indicates the number of MAC client data bytes contained in the subsequent data
field of the 802.3 frame (length interpretation).
– If the value is greater than or equal to MinTypeValue (0d1536 decimal, 0x0600)
then this field indicates the nature of the MAC client protocol (Type interpretation)
related to the Ethernet frame.
Regardless of the interpretation of the length/type field, if the length of the data field is
less than the minimum required for proper operation of the protocol, a PAD field is
added after the data field but prior to the FCS (frame check sequence) field. The
length/type field is transmitted and received with the higher-order byte first.
For length/type field values in the range between maxValidLength and minTypeValue
(boundaries excluded), the behavior of the MAC sublayer is not specified: they may or
may not be passed by the MAC sublayer.
● Data and PAD fields: n-byte data field. Full data transparency is provided, it means that
any arbitrary sequence of byte values may appear in the data field. The size of the PAD,
if any, is determined by the size of the data field. Max and min length of the data and
PAD field are:
– Maximum length = 1500 bytes
– Minimum length for untagged MAC frames = 46 bytes
– Minimum length for tagged MAC frames = 42 bytes
When the data field length is less than the minimum required, the PAD field is added to
match the minimum length (42 bytes for tagged frames, 46 bytes for untagged frames).
● Frame check sequence: 4-byte field that contains the cyclic redundancy check (CRC)
value. The CRC computation is based on the following fields: source address,
destination address, QTag prefix, length/type, LLC data and PAD (that is, all fields
except the preamble, SFD). The generating polynomial is the following:
32 26 23 22 16 12 11 10 8 7 5 4 2
G x = x +x +x +x +x +x +x +x +x +x +x +x +x +x+1
7 bytes Preamble
1 byte SFD
MSB LSB
MSB LSB
Bit transmission order (r ight to left)
ai15630
Each byte of the MAC frame, except the FCS field, is transmitted low-order bit first.
An invalid MAC frame is defined by one of the following conditions:
● The frame length is inconsistent with the expected value as specified by the length/type
field. If the length/type field contains a type value, then the frame length is assumed to
be consistent with this field (no invalid frame)
● The frame length is not an integer number of bytes (extra bits)
● The CRC value computed on the incoming frame does not match the included FCS
The CRC generator calculates the 32-bit CRC for the FCS field of the Ethernet frame. The
encoding is defined by the following polynomial.
32 26 23 22 16 12 11 10 8 7 5 4 2
G x = x +x +x +x +x +x +x +x +x +x +x +x +x +x+1
Transmit protocol
The MAC controls the operation of Ethernet frame transmission. It performs the following
functions to meet the IEEE 802.3/802.3z specifications. It:
● generates the preamble and SFD
● generates the jam pattern in Half-duplex mode
● controls the Jabber timeout
● controls the flow for Half-duplex mode (back pressure)
● generates the transmit frame status
● contains time stamp snapshot logic in accordance with IEEE 1588
When a new frame transmission is requested, the MAC sends out the preamble and SFD,
followed by the data. The preamble is defined as 7 bytes of 0b10101010 pattern, and the
SFD is defined as 1 byte of 0b10101011 pattern. The collision window is defined as 1 slot
time (512 bit times for 10/100 Mbit/s Ethernet). The jam pattern generation is applicable only
to Half-duplex mode, not to Full-duplex mode.
In MII mode, if a collision occurs at any time from the beginning of the frame to the end of
the CRC field, the MAC sends a 32-bit jam pattern of 0x5555 5555 on the MII to inform all
other stations that a collision has occurred. If the collision is seen during the preamble
transmission phase, the MAC completes the transmission of the preamble and SFD and
then sends the jam pattern.
A jabber timer is maintained to cut off the transmission of Ethernet frames if more than 2048
(default) bytes have to be transferred. The MAC uses the deferral mechanism for flow
control (back pressure) in Half-duplex mode. When the application requests to stop
receiving frames, the MAC sends a JAM pattern of 32 bytes whenever it senses the
reception of a frame, provided that transmit flow control is enabled. This results in a collision
and the remote station backs off. The application requests flow control by setting the BPA bit
(bit 0) in the ETH_MACFCR register. If the application requests a frame to be transmitted,
then it is scheduled and transmitted even when back pressure is activated. Note that if back
pressure is kept activated for a long time (and more than 16 consecutive collision events
occur) then the remote stations abort their transmissions due to excessive collisions. If IEEE
1588 time stamping is enabled for the transmit frame, this block takes a snapshot of the
system time when the SFD is put onto the transmit MII bus.
Transmit scheduler
The MAC is responsible for scheduling the frame transmission on the MII. It maintains the
interframe gap between two transmitted frames and follows the truncated binary exponential
backoff algorithm for Half-duplex mode. The MAC enables transmission after satisfying the
IFG and backoff delays. It maintains an idle period of the configured interframe gap (IFG bits
in the ETH_MACCR register) between any two transmitted frames. If frames to be
transmitted arrive sooner than the configured IFG time, the MII waits for the enable signal
from the MAC before starting the transmission on it. The MAC starts its IFG counter as soon
as the carrier signal of the MII goes inactive. At the end of the programmed IFG value, the
MAC enables transmission in Full-duplex mode. In Half-duplex mode and when IFG is
configured for 96 bit times, the MAC follows the rule of deference specified in Section
4.2.3.2.1 of the IEEE 802.3 specification. The MAC resets its IFG counter if a carrier is
detected during the first two-thirds (64-bit times for all IFG values) of the IFG interval. If the
carrier is detected during the final one third of the IFG interval, the MAC continues the IFG
count and enables the transmitter after the IFG interval. The MAC implements the truncated
binary exponential backoff algorithm when it operates in Half-duplex mode.
frame is being transmitted. As soon as the first frame has been transferred and the
status is received from the MAC, it is pushed to the DMA. If the DMA has already
completed sending the second packet to the FIFO, the second transmission must wait
for the status of the first packet before proceeding to the next frame.
2 You must make sure the Transmit FIFO is deep enough to store a complete frame before
that frame is transferred to the MAC Core transmitter. If the FIFO depth is less than the input
Ethernet frame size, the payload (TCP/UDP/ICMP) checksum insertion function is bypassed
and only the frame’s IPv4 Header checksum is modified, even in Store-and-forward mode.
The transmit checksum offload supports two types of checksum calculation and insertion.
This checksum can be controlled for each frame by setting the CIC bits (Bits 28:27 in
TDES1, described in TDES1: Transmit descriptor Word1 on page 889).
See IETF specifications RFC 791, RFC 793, RFC 768, RFC 792, RFC 2460 and RFC 4443
for IPv4, TCP, UDP, ICMP, IPv6 and ICMPv6 packet header specifications, respectively.
● IP header checksum
In IPv4 datagrams, the integrity of the header fields is indicated by the 16-bit header
checksum field (the eleventh and twelfth bytes of the IPv4 datagram). The checksum
offload detects an IPv4 datagram when the Ethernet frame’s Type field has the value
0x0800 and the IP datagram’s Version field has the value 0x4. The input frame’s
checksum field is ignored during calculation and replaced by the calculated value. IPv6
headers do not have a checksum field; thus, the checksum offload does not modify
IPv6 header fields. The result of this IP header checksum calculation is indicated by the
IP Header Error status bit in the Transmit status (Bit 16). This status bit is set whenever
the values of the Ethernet Type field and the IP header’s Version field are not
consistent, or when the Ethernet frame does not have enough data, as indicated by the
IP header Length field. In other words, this bit is set when an IP header error is
asserted under the following circumstances:
a) For IPv4 datagrams:
– The received Ethernet type is 0x0800, but the IP header’s Version field does not
equal 0x4
– The IPv4 Header Length field indicates a value less than 0x5 (20 bytes)
– The total frame length is less than the value given in the IPv4 Header Length field
b) For IPv6 datagrams:
– The Ethernet type is 0x86DD but the IP header Version field does not equal 0x6
– The frame ends before the IPv6 header (40 bytes) or extension header (as given
in the corresponding Header Length field in an extension header) has been
completely received. Even when the checksum offload detects such an IP header
error, it inserts an IPv4 header checksum if the Ethernet Type field indicates an
IPv4 payload.
● TCP/UDP/ICMP checksum
The TCP/UDP/ICMP checksum processes the IPv4 or IPv6 header (including
extension headers) and determines whether the encapsulated payload is TCP, UDP or
ICMP.
Note that:
a) For non-TCP, -UDP, or -ICMP/ICMPv6 payloads, this checksum is bypassed and
nothing further is modified in the frame.
b) Fragmented IP frames (IPv4 or IPv6), IP frames with security features (such as an
authentication header or encapsulated security payload), and IPv6 frames with
routing headers are bypassed and not processed by the checksum.
The checksum is calculated for the TCP, UDP, or ICMP payload and inserted into its
corresponding field in the header. It can work in the following two modes:
– In the first mode, the TCP, UDP, or ICMPv6 pseudo-header is not included in the
checksum calculation and is assumed to be present in the input frame’s checksum
field. The checksum field is included in the checksum calculation, and then
replaced by the final calculated checksum.
– In the second mode, the checksum field is ignored, the TCP, UDP, or ICMPv6
pseudo-header data are included into the checksum calculation, and the
checksum field is overwritten with the final calculated value.
Note that: for ICMP-over-IPv4 packets, the checksum field in the ICMP packet must
always be 0x0000 in both modes, because pseudo-headers are not defined for such
packets. If it does not equal 0x0000, an incorrect checksum may be inserted into the
packet.
The result of this operation is indicated by the payload checksum error status bit in the
Transmit Status vector (bit 12). The payload checksum error status bit is set when
either of the following is detected:
– the frame has been forwarded to the MAC Transmitter in Store-and-forward mode
without the end of frame being written to the FIFO
– the packet ends before the number of bytes indicated by the payload length field in
the IP header is received.
When the packet is longer than the indicated payload length, the bytes are ignored as
stuff bytes, and no error is reported. When the first type of error is detected, the TCP,
UDP or ICMP header is not modified. For the second error type, still, the calculated
checksum is inserted into the corresponding header field.
LSB MSB
D0 D1 Bibit stream
LSB D0
D1
MII_TXD[3:0]
D2
MSB D3
MII_TX_CLK
MII_TX_EN
MII_TXD[3:0] PR EA MB LE
MII_CS
MII_COL
Low
ai15631
MII_TX_CLK
MII_TX_EN
MII_CS
MII_COL
ai15651
MII_RX_CLK
MII_TX_EN
MII_TXD[3:0]
RMII_REF_CLK
RMII_TX_EN
RMII_TXD[1:0]
ai15652
Receive protocol
The received frame preamble and SFD are stripped. Once the SFD has been detected, the
MAC starts sending the Ethernet frame data to the receive FIFO, beginning with the first
byte following the SFD (destination address). If IEEE 1588 time stamping is enabled, a
snapshot of the system time is taken when any frame's SFD is detected on the MII. Unless
the MAC filters out and drops the frame, this time stamp is passed on to the application.
If the received frame length/type field is less than 0x600 and if the MAC is programmed for
the auto CRC/pad stripping option, the MAC sends the data of the frame to RxFIFO up to
the count specified in the length/type field, then starts dropping bytes (including the FCS
field). If the Length/Type field is greater than or equal to 0x600, the MAC sends all received
Ethernet frame data to Rx FIFO, regardless of the value on the programmed auto-CRC strip
option. The MAC watchdog timer is enabled by default, that is, frames above 2048 bytes (DA
+ SA + LT + Data + pad + FCS) are cut off. This feature can be disabled by programming the
watchdog disable (WD) bit in the MAC configuration register. However, even if the watchdog
timer is disabled, frames greater than 16 KB in size are cut off and a watchdog timeout
status is given.
32 26 23 22 16 12 11 10 8 7 5 4 2
G x = x +x +x +x +x +x +x +x +x +x +x +x +x +x+1
Regardless of the auto-pad/CRC strip, the MAC receives the entire frame to compute the
CRC check for the received frame.
Meanwhile, if another Pause frame is detected with a zero Pause time value, the MAC
resets the Pause time and manages this new pause request.
If the received control frame matches neither the type field (0x8808), the opcode (0x00001),
nor the byte length (64 bytes), or if there is a CRC error, the MAC does not generate a
Pause.
In the case of a pause frame with a multicast destination address, the MAC filters the frame
based on the address match.
For a pause frame with a unicast destination address, the MAC filtering depends on whether
the DA matched the contents of the MAC address 0 register and whether the UPDF bit in
ETH_MACFCR is set (detecting a pause frame even with a unicast destination address).
The PCF register bits (bits [7:6] in ETH_MACFFR) control filtering for control frames in
addition to address filtering.
Error handling
If the Rx FIFO is full before it receives the EOF data from the MAC, an overflow is declared
and the whole frame is dropped, and the overflow counter in the (ETH_DMAMFBOCR
register) is incremented. The status indicates a partial frame due to overflow. The Rx FIFO
can filter error and undersized frames, if enabled (using the FEF and FUGF bits in
ETH_DMAOMR).
If the Receive FIFO is configured to operate in Store-and-forward mode, all error frames can
be filtered and dropped.
In Cut-through mode, if a frame's status and length are available when that frame's SOF is
read from the Rx FIFO, then the complete erroneous frame can be dropped. The DMA can
flush the error frame being read from the FIFO, by enabling the receive frame flash bit. The
data transfer to the application (DMA) is then stopped and the rest of the frame is internally
read and dropped. The next frame transfer can then be started, if available.
RMII_RXD[1:0]
LSB MSB
D0 D1 Di-bit stream
LSB D0
D1
MII_RXD[3:0]
D2
MSB D3
MII_RX_CLK
MII_RX_DV
MII_RX_ERR
ai15634
MII_RX_CLK
MII_RX_DV
MII_RX_ERR
ai15635
MII_RX_CLK
MII_RX_DV
MII_RXD[3:0] XX XX XX XX 0E XX XX XX XX
MII_RX_ERR
ai15636
TSTS
TSTI
AND
TSTIM
Interrupt
OR
PMTS
PMTI
AND
PMTIM
ai15637
When the SAF bit is set, the result of the SA and DA filters is AND’ed to decide whether the
frame needs to be forwarded. This means that either of the filter fail result will drop the
frame. Both filters have to pass the frame for the frame to be forwarded to the application.
1 X X X X X X Pass
Broadcast 0 X X X X X 0 Pass
0 X X X X X 1 Fail
1 X X X X X X Pass all frames
0 X 0 0 X X X Pass on perfect/group filter match
0 X 0 1 X X X Fail on perfect/Group filter match
0 0 1 0 X X X Pass on hash filter match
Unicast
0 0 1 1 X X X Fail on hash filter match
Pass on hash or perfect/Group filter
0 1 1 0 X X X
match
0 1 1 1 X X X Fail on hash or perfect/Group filter match
1 X X X X X X Pass all frames
X X X X X 1 X Pass all frames
Pass on Perfect/Group filter match and
0 X X 0 0 0 X
drop PAUSE control frames if PCF = 0x
Pass on hash filter match and drop
0 0 X 0 1 0 X
PAUSE control frames if PCF = 0x
Pass on hash or perfect/Group filter
Multicast 0 1 X 0 1 0 X match and drop PAUSE control frames if
PCF = 0x
Fail on perfect/Group filter match and
0 X X 1 0 0 X
drop PAUSE control frames if PCF = 0x
Fail on hash filter match and drop PAUSE
0 0 X 1 1 0 X
control frames if PCF = 0x
Fail on hash or perfect/Group filter match
0 1 X 1 1 0 X and drop PAUSE control frames if PCF =
0x
Received frames are considered “good” if none of the following errors exists:
+ CRC error
+ Runt Frame (shorter than 64 bytes)
+ Alignment error (in 10/ 100 Mbit/s only)
+ Length error (non-Type frames only)
+ Out of Range (non-Type frames only, longer than maximum size)
+ MII_RXER Input error
The maximum frame size depends on the frame type, as follows:
+ Untagged frame maxsize = 1518
+ VLAN Frame maxsize = 1522
Wakeup frame filter reg5 Filter 3 Offset Filter 2 Offset Filter 1 Offset Filter 0 Offset
ai15647
wakeup frame is more than 512 bytes long, if the frame has a valid CRC value, it is
considered valid. Wakeup frame detection is updated in the ETH_MACPMTCSR register for
every remote wakeup frame received. If enabled, a PMT interrupt is generated to indicate
the reception of a remote wakeup frame.
6. Turn-off the application and transmit clock inputs to the core (and other relevant clocks
in the system) to reduce power and enter Sleep mode.
7. On receiving a valid wakeup frame, the Ethernet peripheral exits Power-down mode.
8. On receiving the interrupt, the system must enable the application and transmit clock
inputs to the Ethernet.
9. Read the ETH_MACPMTCSR register to clear the interrupt, then enable the MAC and
resume normal operation.
t1 Sync message
Data at
slave clock
t2m t2 t2
Follow_up message
containing value of t1
t1, t2
t4
Delay_Resp message
containing value of t4
ai15669
1. The master broadcasts PTP Sync messages to all its nodes. The Sync message
contains the master’s reference time information. The time at which this message
leaves the master’s system is t1. For Ethernet ports, this time has to be captured at the
MII.
2. A slave receives the Sync message and also captures the exact time, t2, using its
timing reference.
3. The master then sends the slave a Follow_up message, which contains the t1
information for later use.
4. The slave sends the master a Delay_Req message, noting the exact time, t3, at which
this frame leaves the MII.
5. The master receives this message and captures the exact time, t4, at which it enters its
system.
6. The master sends the t4 information to the slave in the Delay_Resp message.
7. The slave uses the four values of t1, t2, t3, and t4 to synchronize its local timing
reference to the master’s timing reference.
Most of the protocol implementation occurs in the software, above the UDP layer. As
described above, however, hardware support is required to capture the exact time when
specific PTP packets enter or leave the Ethernet port at the MII. This timing information has
to be captured and returned to the software for a proper, high-accuracy implementation of
PTP.
Figure 307. System time update using the Fine correction method
Addend register
Addend update
+
Accumulator register
Constant value
Increment Subsecond
register
+
Subsecond register
Second register
ai15670
The system time update logic requires a 50 MHz clock frequency to achieve 20 ns accuracy.
The frequency division is the ratio of the reference clock frequency to the required clock
frequency. Hence, if the reference clock (HCLK) is, let us say, 66 MHz, the ratio is calculated
as 66 MHz/50 MHz = 1.32. Hence, the default addend value to be set in the register is
232/1.32, which is equal to 0xC1F0 7C1F.
If the reference clock drifts lower, to 65 MHz for example, the ratio is 65/50 or 1.3 and the
value to set in the addend register is 232/1.30 equal to 0xC4EC 4EC4. If the clock drifts
higher, to 67 MHz for example, the addend register must be set to 0xBF0 B7672. When the
clock drift is zero, the default addend value of 0xC1F0 7C1F (232/1.32) should be
programmed.
In Figure 307, the constant value used to increment the subsecond register is 0d43. This
makes an accuracy of 20 ns in the system time (in other words, it is incremented by 20 ns
steps).
The software has to calculate the drift in frequency based on the Sync messages, and to
update the Addend register accordingly. Initially, the slave clock is set with
FreqCompensationValue0 in the Addend register. This value is as follows:
FreqCompensationValue0 = 232 / FreqDivisionRatio
If MasterToSlaveDelay is initially assumed to be the same for consecutive Sync messages,
the algorithm described below must be applied. After a few Sync cycles, frequency lock
occurs. The slave clock can then determine a precise MasterToSlaveDelay value and re-
synchronize with the master using the new value.
Programming steps for system time update in the Coarse correction method
To synchronize or update the system time in one process (coarse correction method),
perform the following steps:
1. Write the offset (positive or negative) in the Time stamp update high and low registers.
2. Set bit 3 (TSSTU) in the Time stamp control register.
3. The value in the Time stamp update registers is added to or subtracted from the system
time when the TSSTU bit is cleared.
Programming steps for system time update in the Fine correction method
To synchronize or update the system time to reduce system-time jitter (fine correction
method), perform the following steps:
1. With the help of the algorithm explained in Section : System Time correction methods,
calculate the rate by which you want to speed up or slow down the system time
increments.
2. Update the time stamp.
3. Wait the time you want the new value of the Addend register to be active. You can do
this by activating the Time stamp trigger interrupt after the system time reaches the
target value.
4. Program the required target time in the Target time high and low registers. Unmask the
Time stamp interrupt by clearing bit 9 in the ETH_MACIMR register.
5. Set Time stamp control register bit 4 (TSARU).
6. When this trigger causes an interrupt, read the ETH_MACSR register.
7. Reprogram the Time stamp addend register with the old value and set ETH_TPTSCR
bit 5 again.
ai15671
PPS output
Ethernet MAC
ai15672
Buffer 1 Buffer 1
Descriptor 0 Descriptor 0
Buffer 2
Buffer 1
Descriptor 1
Buffer 2 Buffer 1
Descriptor 1
Buffer 1
Descriptor 2
Buffer 2
Descriptor 2 Buffer 1
Buffer 1
Descriptor n
Buffer 2
Next descriptor
ai15638
INCR4, INCR8, INCR16 and SINGLE transactions. Otherwise (no fixed-length burst), it
transfers data using INCR (undefined length) and SINGLE transactions.
The Receive DMA initiates a data transfer only when sufficient data for the configured burst
is available in Receive FIFO or when the end of frame (when it is less than the configured
burst length) is detected in the Receive FIFO. The DMA indicates the start address and the
number of transfers required to the AHB master interface. When the AHB interface is
configured for fixed-length burst, then it transfers data using the best combination of INCR4,
INCR8, INCR16 and SINGLE transactions. If the end of frame is reached before the fixed-
burst ends on the AHB interface, then dummy transfers are performed in order to complete
the fixed-length burst. Otherwise (FB bit in ETH_DMABMR is reset), it transfers data using
INCR (undefined length) and SINGLE transactions.
When the AHB interface is configured for address-aligned beats, both DMA engines ensure
that the first burst transfer the AHB initiates is less than or equal to the size of the configured
PBL. Thus, all subsequent beats start at an address that is aligned to the configured PBL.
The DMA can only align the address for beats up to size 16 (for PBL > 16), because the
AHB interface does not support more than INCR16.
databus width. If a descriptor is marked as last, then the buffer may not be full (as indicated
by the buffer size in RDES1). To compute the amount of valid data in this final buffer, the
driver must read the frame length (FL bits in RDES0[29:16]) and subtract the sum of the
buffer sizes of the preceding buffers in this frame. The receive DMA always transfers the
start of next frame with a new descriptor.
Note: Even when the start address of a receive buffer is not aligned to the system databus width
the system should allocate a receive buffer of a size aligned to the system bus width. For
example, if the system allocates a 1024 byte (1 KB) receive buffer starting from address
0x1000, the software can program the buffer start address in the receive descriptor to have
a 0x1002 offset. The receive DMA writes the frame to this buffer with dummy data in the first
two locations (0x1000 and 0x1001). The actual frame is written from location 0x1002. Thus,
the actual useful space in this buffer is 1022 bytes, even though the buffer size is
programmed as 1024 bytes, due to the start address offset.
(Re-)fetch next
descriptor
TxDMA suspended No
Own
bit set?
Yes
(AHB) Yes
error?
No
No
Frame xfer
complete?
Yes
Close intermediate
descriptor Wait for Tx status
No
(AHB) Yes
error?
ai15639
1. The DMA operates as described in steps 1–6 of the TxDMA (default mode).
2. Without closing the previous frame’s last descriptor, the DMA fetches the next
descriptor.
3. If the DMA owns the acquired descriptor, the DMA decodes the transmit buffer address
in this descriptor. If the DMA does not own the descriptor, the DMA goes into Suspend
mode and skips to Step 7.
4. The DMA fetches the Transmit frame from the STM32F107xx memory and transfers the
frame until the end of frame data are transferred, closing the intermediate descriptors if
this frame is split across multiple descriptors.
5. The DMA waits for the transmission status and time stamp of the previous frame. When
the status is available, the DMA writes the time stamp to TDES2 and TDES3, if such
time stamp was captured (as indicated by a status bit). The DMA then writes the status,
with a cleared OWN bit, to the corresponding TDES0, thus closing the descriptor. If
time stamping was not enabled for the previous frame, the DMA does not alter the
contents of TDES2 and TDES3.
6. If enabled, the Transmit interrupt is set, the DMA fetches the next descriptor, then
proceeds to Step 3 (when Status is normal). If the previous transmission status shows
an underflow error, the DMA goes into Suspend mode (Step 7).
7. In Suspend mode, if a pending status and time stamp are received by the DMA, it
writes the time stamp (if enabled for the current frame) to TDES2 and TDES3, then
writes the status to the corresponding TDES0. It then sets relevant interrupts and
returns to Suspend mode.
8. The DMA can exit Suspend mode and enter the Run state (go to Step 1 or Step 2
depending on pending status) only after receiving a Transmit Poll demand
(ETH_DMATPDR register).
Figure 312 shows the basic flowchart in OSF mode.
(Re-)fetch next
descriptor
(AHB) Yes
Poll error?
demand
No
Previous frame
status available Transfer data from
buffer(s)
(AHB) Yes
Write time stamp to
error? Time stamp Yes TDES2 & TDES3
present? for previous frame
No
No
(AHB) No (AHB)
No
error? error?
Yes
Yes
ai15640
indicates the last buffer of the frame. After the last buffer of the frame has been transmitted,
the DMA writes back the final status information to the transmit descriptor 0 (TDES0) word
of the descriptor that has the last segment set in transmit descriptor 0 (TDES0[29]). At this
time, if Interrupt on Completion (TDES0[30]) is set, Transmit Interrupt (in ETH_DMASR
register [0]) is set, the next descriptor is fetched, and the process repeats. Actual frame
transmission begins after the Transmit FIFO has reached either a programmable transmit
threshold (ETH_DMAOMR register[16:14]), or a full frame is contained in the FIFO. There is
also an option for the Store and forward mode (ETH_DMAOMR register[21]). Descriptors
are released (OWN bit TDES0[31] is cleared) when the DMA finishes transferring the frame.
Tx DMA descriptors
The descriptor structure consists of four 32-bit words as shown in Figure 313. The bit
descriptions of TDES0, TDES1, TDES2 and TDES3 are given below.
O T T
Ctrl T Res. Ctrl Reserved T
TDES 0 W Status [16:0]
[30:26] S 24 [23:20] [19:18] S
N
E S
TDES 3 Buffer 2 address [31:0] or Next descriptor address [31:0] / Time stamp high [31:0]
ai15642b
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
O
TT TE TC TT IH IP LC LC
W IC LS FS DC DP CIC ES JT FF NC EC VF CC ED UF DB
SE Res R H Res. SS E E A O
N
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TBS2 TBS1
Reserved Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31:29 Reserved
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TBAP1/TTSL
rw
Bits 31:0 TBAP1 / TTSL: Transmit buffer 1 address pointer / Transmit frame time stamp low
These bits take on two different functions: the application uses them to indicate to the DMA the
location of data in memory. And then after transferring all these data, the DMA may then use
these bits to pass back time stamp data.
TBAP: When the software makes this descriptor available to the DMA (at the moment that the
OWN bit is set to 1 in TDES0), these bits indicate the physical address of Buffer 1. There is no
limitation on the buffer address alignment. See Host data buffer alignment on page 880 for further
details on buffer address alignment.
TTSL: Before it clears the OWN bt in TDES0, the DMA updates this field with the 32 least
significant bits of the time stamp captured for the corresponding transmit frame (overwriting the
value for TBAP1). This field has the time stamp only if time stamping is activated for this frame
(see TTSE, TDES0 bit 25) and if the Last segment control bit (LS) in the descriptor is set.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TBAP2/TTSH
rw
Bits 31:0 TBAP2 / TTSH: Transmit buffer 2 address pointer (Next descriptor address) / Transmit frame
time stamp high
These bits take on two different functions: the application uses them to indicate to the DMA the
location of data in memory. And then after transferring all these data, the DMA may then use
these bits to pass back time stamp data.
TBAP2: When the software makes this descriptor available to the DMA (at the moment when
the OWN bit is set to 1 in TDES0), these bits indicate the physical address of Buffer 2 when a
descriptor ring structure is used. If the Second address chained (TDES1 [24]) bit is set, this
address contains the pointer to the physical memory where the next descriptor is present. The buffer
address pointer must be aligned to the bus width only when TDES1 [24] is set. (LSBs are ignored
internally.)
TTSH: Before it clears the OWN bit in TDES0, the DMA updates this field with the 32 most
significant bits of the time stamp captured for the corresponding transmit frame (overwriting the
value for TBAP2). This field has the time stamp only if time stamping is activated for this frame
(see TDES0 bit 25, TTSE) and if the Last segment control bit (LS) in the descriptor is set.
Figure 314. Transmit descriptor field format with IEEE1588 time stamp enabled
31 0
O T T
Ctrl T Res. Ctrl Reserved T
TDES 0 W Status [16:0]
[30:26] S 24 [23:20] [19:18] S
N
E S
TDES 3 Buffer 2 address [31:0] or Next descriptor address [31:0] / Time stamp high [31:0](1)
ai15642
1. The DMA updates TDES2 and TDES3 with the time stamp value before clearing the OWN bit in TDES0:
TDES2 is updated with the lower 32 time stamp bits (the sub-second field, called TTSL in subsequent
section TDES2: Transmit descriptor Word2) and TDES3 is updated with the upper 32 time stamp bits (the
Seconds field, called TTSH in subsequent sections TDES3: Transmit descriptor Word3)
● TDES0: Transmit descriptor Word0: Transmit time stamp control and status
The value of this field should be preserved by the DMA at the time of closing the
descriptor.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
O
TT TE TC TT IH IP LC LC
W IC LS FS DC DP CIC ES JT FF NC EC VF CC ED UF DB
SE Res R H Res. SS E E A O
N
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TTSL
rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TTSH
rw
enabled time stamping through CSR, when a valid time stamp value is not available for the
frame (for example, because the receive FIFO was full before the time stamp could be
written to it), the DMA writes all ones to RDES2 and RDES3. Otherwise (that is, if time
stamping is not enabled), RDES2 and RDES3 remain unchanged.
(AHB)
RxDMA suspended Yes
error?
No
Yes
Frame transfer
No Own bit set?
complete?
No Yes
Frame data
Yes Flush disabled ? No
available ?
No Yes
Flush the
Write data to buffer(s) Wait for frame data
remaining frame
(AHB)
Yes
error?
No
(AHB)
Yes
error?
No
No
Yes Yes Yes
No
(AHB)
No
error?
Yes
ai15643
Rx DMA descriptors
The descriptor structure consists of four 32-bit words (16 bytes). These are shown in
Figure 316. The bit descriptions of RDES0, RDES1, RDES2 and RDES3 are given below.
RDES 1 CT Reserved Buffer 2 byte count CTRL Res. Buffer 1 byte count
RL [30:29] [28:16] [15:14] [12:0]
ai15644
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
IPHCE
VLAN
OWN
RWT
AFM
LCO
PCE
SAF
OE
DE
RE
DE
CE
ES
FS
LE
LS
FT
FL
rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
RCH
RER
DIC
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RBP1 / RTSL
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Bits 31:0 RBAP1 / RTSL: Receive buffer 1 address pointer / Receive frame time stamp low
These bits take on two different functions: the application uses them to indicate to the DMA
where to store the data in memory, and then after transferring all the data the DMA may use
these bits to pass back time stamp data.
RBAP1: When the software makes this descriptor available to the DMA (at the moment that the
OWN bit is set to 1 in RDES0), these bits indicate the physical address of Buffer 1. There are no
limitations on the buffer address alignment except for the following condition: the DMA uses the
configured value for its address generation when the RDES2 value is used to store the start of
frame. Note that the DMA performs a write operation with the RDES2[3/2/1:0] bits as 0 during the
transfer of the start of frame but the frame data is shifted as per the actual Buffer address pointer. The
DMA ignores RDES2[3/2/1:0] (corresponding to bus width of 128/64/32) if the address pointer is to a
buffer where the middle or last part of the frame is stored.
RTSL: Before it clears the OWN bt in RDES0, the DMA updates this field with the 32 least
significant bits of the time stamp captured for the corresponding receive frame (overwriting the
value for RBAP1). This field has the time stamp only if time stamping is activated for this frame
and if the Last segment control bit (LS) in the descriptor is set.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RBP2 / RTSH
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Bits 31:0 RBAP2 / RTSH: Receive buffer 2 address pointer (next descriptor address) / Receive frame
time stamp high
These bits take on two different functions: the application uses them to indicate to the DMA the
location of where to store the data in memory, and then after transferring all the data the DMA
may use these bits to pass back time stamp data.
RBAP1: When the software makes this descriptor available to the DMA (at the moment that the
OWN bit is set to 1 in RDES0), these bits indicate the physical address of buffer 2 when a
descriptor ring structure is used. If the second address chained (RDES1 [24]) bit is set, this address
contains the pointer to the physical memory where the next descriptor is present. If RDES1 [24] is
set, the buffer (next descriptor) address pointer must be bus width-aligned (RDES3[3, 2, or 1:0]
= 0, corresponding to a bus width of 128, 64 or 32. LSBs are ignored internally.) However, when
RDES1 [24] is reset, there are no limitations on the RDES3 value, except for the following condition:
the DMA uses the configured value for its buffer address generation when the RDES3 value is used to
store the start of frame. The DMA ignores RDES3[3, 2, or 1:0] (corresponding to a bus width of 128,
64 or 32) if the address pointer is to a buffer where the middle or last part of the frame is stored.
RTSH: Before it clears the OWN bt in RDES0, the DMA updates this field with the 32 most
significant bits of the time stamp captured for the corresponding receive frame (overwriting the
value for RBAP2). This field has the time stamp only if time stamping is activated and if the Last
segment control bit (LS) in the descriptor is set.
Figure 317. Receive descriptor fields format with IEEE1588 time stamp enabled
31 0
O
RDES 0 W Status [30:0]
N
RDES 1 CT Reserved Buffer 2 byte count CTRL Res. Buffer 1 byte count
RL [30:29] [28:16] [15:14] [12:0]
RDES 3 Buffer 2 address [31:0] or Next descriptor address [31:0] / Time stamp high[31:0](1)
ai15645
1. The DMA updates RDES2 and RDES3 with the time stamp value before clearing the OWN bit in RDES0:
RDES2 is updated with the lower 32 time stamp bits (the sub-second field, called RTSL in the RDES2:
Receive descriptor Word2 section) and RDES3 is updated with the upper 32 time stamp bits (the Seconds
field, called RTSH in the RDES3: Receive descriptor Word3 section).
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RTSL
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RTSH
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
STM32F107xx buffer. The driver must scan all descriptors, from the last recorded position to
the first one owned by the DMA.
An interrupt is generated only once for simultaneous, multiple events. The driver must scan
the ETH_DMASR register for the cause of the interrupt. The interrupt is not generated again
unless a new interrupting event occurs, after the driver has cleared the appropriate bit in the
ETH_DMASR register. For example, the controller generates a Receive interrupt
(ETH_DMASR register[6]) and the driver begins reading the ETH_DMASR register. Next,
receive buffer unavailable (ETH_DMASR register[7]) occurs. The driver clears the Receive
interrupt. Even then, a new interrupt is generated, due to the active or pending Receive
buffer unavailable interrupt.
FBES
AND
TPSS FBEIE
AND TJTS AIS
TPSSIE
AND AND
ROS TJTIE
AISE
AND
TUS ROIE
AND
TUIE RBU OR
AND RPSS
RWTS RBUIE
AND
AND RPSSIE
RWTIE
ETS
AND
ETIE
AI15646
When an Ethernet wakeup event mapped on EXTI Line19 occurs and the MAC PMT
interrupt is enabled and the EXTI Line19 interrupt, with detection on rising edge, is also
enabled, both interrupts are generated.
A watchdog timer (see ETH_DMARSWTR register) is given for flexible control of the RS bit
(ETH_DMASR register). When this watchdog timer is programmed with a non-zero value, it
gets activated as soon as the RxDMA completes a transfer of a received frame to system
memory without asserting the Receive Status because it is not enabled in the corresponding
Receive descriptor (RDES1[31]). When this timer runs out as per the programmed value,
the RS bit is set and the interrupt is asserted if the corresponding RIE is enabled in the
ETH_DMAIER register. This timer is disabled before it runs out, when a frame is transferred
to memory and the RS is set because it is enabled for that descriptor.
Note: Reading the PMT control and status register automatically clears the Wakeup Frame
Received and Magic Packet Received PMT interrupt flags. However, since the registers for
these flags are in the CLK_RX domain, there may be a significant delay before this update is
visible by the firmware. The delay is especially long when the RX clock is slow (in 10 Mbit
mode) and when the AHB bus is high-frequency.
Since interrupt requests from the PMT to the CPU are based on the same registers in the
CLK_RX domain, the CPU may spuriously call the interrupt routine a second time even after
reading PMT_CSR. Thus, it may be necessary that the firmware polls the Wakeup Frame
Received and Magic Packet Received bits and exits the interrupt service routine only when
they are found to be at ‘0’.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
APCS
IPCO
Reserved
Reserved
Reserved
Reserved
ROD
CSD
FES
WD
DM
RD
DC
LM
RE
TE
JD
BL
IFG
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DAIF
SAIF
PAM
HPF
PCF
BFD
SAF
HM
PM
HU
RA
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HTH
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HTL
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
PA MR CR MW MB
Reserved rc_
rw rw rw rw rw rw rw rw rw rw rw rw rw rw
w1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MD
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ZQPD
UPFD
RFCE
TFCE
FCB/
Reserved
PT PLT
BPA
Reserved
rc_w1
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
/rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
VLANTC
VLANTI
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
Figure 319. Ethernet MAC remote wakeup frame filter register (ETH_MACRWUFFR)
Wakeup frame filter reg5 Filter 3 Offset Filter 2 Offset Filter 1 Offset Filter 0 Offset
ai15648
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
WFFRPR
WFR
MPR
WFE
MPE
GU
PD
Reserved
Reserved
Reserved
rc_ rc_
rs Res. rw rw rw rs
r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TSTS MMCTS MMCRS MMCS PMTS
Reserved Reserved Reserved
rc_r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TSTIM PMTIM
Reserved Reserved Reserved
rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MO
MACA0H
Reserved
1 rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MACA0L
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
AE SA MBC MACA1H
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MACA1L
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
AE SA MBC MACA2H
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MACA2L
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
AE SA MBC MACA3H
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MACA3L
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ROR
MCF
CSR
CR
Reserved
rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RGUFS
RFCES
RFAES
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TGFMSCS
TGFSCS
TGFS
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RGUFM
RFCEM
RFAEM
Reserved Reserved Reserved
rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TGFMSCM
TGFSCM
TGFM
rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TGFSCC
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
Ethernet MMC transmitted good frames after more than a single collision
counter register (ETH_MMCTGFMSCCR)
Address offset: 0x0150
Reset value: 0x0000 0000
This register contains the number of successfully transmitted frames after more than a
single collision in Half-duplex mode.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TGFMSCC
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
Bits 31:0 TGFMSCC: Transmitted good frames more single collision counter
Transmitted good frames after more than a single collision counter
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TGFC
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RFCEC
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RFAEC
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RGUFC
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TTSARU
TSFCU
TSSTU
TSITE
TSSTI
TSE
Reserved
rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
STSSI
Reserved
rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
STS
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
STPNS
STSS
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TSUS
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TSUPNS
TSUSS
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TSA
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TTSH
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TTSL
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
FPM
USP
AAB
SR
DA
FB
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TPD
rw_wt
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RPD
rw_wt
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SRL
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
STL
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
ETH_DMASR register[16:0] clears them and writing 0 has no effect. Each field (bits [16:0])
can be masked by masking the appropriate bit in the ETH_DMAIER register.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10
MMCS 9 8 7 6 5 4 3 2 1 0
RWTS
PMTS
RBUS
RPSS
TBUS
FBES
TPSS
TSTS
TJTS
ROS
RPS
ERS
EBS
TUS
TPS
ETS
NIS
AIS
RS
Reserved
Reserved
Reserved
TS
rc- rc- rc- rc- rc- rc- rc- rc- rc- rc- rc- rc- rc- rc- rc-
r r r r r r r r r r r r
w1 w1 w1 w1 w1 w1 w1 w1 w1 w1 w1 w1 w1 w1 w1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DTCEFD
FUGF
DFRF
Reserved
Reserved
Reserved
OSF
RTC
RSF
TTC
TSF
FEF
FTF
SR
ST
Reserved Reserved Reserved
rw rw rw rw rs rw rw rw rw rw rw rw rw rw rw
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
RWTIE
RBUIE
RPSIE
TBUIE
FBEIE
TPSIE
TJTIE
Reserved
ROIE
NISE
ERIE
AISE
TUIE
ETIE
RIE
TIE
Reserved
rw rw rw rw rw rw rw rw rw rw rw rw rw rw rw
The Ethernet interrupt is generated only when the TSTS or PMTS bits of the DMA Status
register is asserted with their corresponding interrupt are unmasked, or when the NIS/AIS
Status bit is asserted and the corresponding Interrupt Enable bits (NISE/AISE) are enabled.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OMFC
OFOC
MFA
MFC
Reserved
rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_ rc_
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HTDAP
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HRDAP
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HTBAP
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HRBAP
r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r r
9
8
7
6
5
4
3
2
1
0
Reserved
Reserved
Reserved
Reserved
APCS
IPCO
ROD
CSD
FES
WD
DM
RD
DC
RE
LM
TE
JD
BL
ETH_MACCR IFG
0x00 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MACFF
DAIF
PAM
HPF
PCF
BFD
SAF
HM
PM
HU
RA
0x04 R Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MACHT
HTH[31:0]
0x08 HR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MACHT
HTL[31:0]
0x0C LR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MACMII M M
Reserved
PA MR CR
AR W B
0x10 Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MACMII
MD
0x14 DR Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
FCB/BPA
Reserved
ZQPD
UPFD
RFCE
TFCE
ETH_MACFC
PT PLT
0x18 R Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
VLANTC
ETH_MACVL
VLANTI
0x1C ANTR Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MACRW
Frame filter reg0\Frame filter reg1\Frame filter reg2\Frame filter reg3\Frame filter reg4\...\Frame filter reg7
0x28 UFFR
Reset value 0
WFFRPR
Reserved
Reserved
ETH_MACPM WFR
MPR
WFE
MPE
GU
PD
0x2C TCSR Reserved
Reset value 0 0 0 0 0 0 0
MMCRS
MMCTS
MMCS
Reserved
PMTS
TSTS
ETH_MACSR
0x38 Not applicable Reserved Reserved
Reset value 0 0 0 0 0
PMTIM
TSTIM
ETH_MACIM
0x3C R Not applicable Reserved Reserved Reserved
Reset value 0 0
ETH_MACA0
MO
Reserved MACA0H
0x40 HR
Reset value 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ETH_MACA0
MACA0L
0x44 LR
Reset value 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ETH_MACA1
AE SA MBC[6:0] MACA1H
0x48 HR Reserved
Reset value 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ETH_MACA1
MACA1L
0x4C LR
Reset value 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ETH_MACA2
AE SA MBC MACA2H
0x50 HR Reserved
Reset value 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ETH_MACA2
MACA2L
0x54 LR
Reset value 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
ETH_MACA3
AE SA MBC MACA3H
0x58 HR Reserved
Reset value 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ETH_MACA3
MACA3L
0x5C LR
Reset value 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
ROR
MCF
CSR
CR
ETH_MMCCR
0x100 Reserved
Reset value 0 0 0 0
RGUFS
RFCES
RFAES
ETH_MMCRI
0x104 R Reserved Reserved Reserved
Reset value 0 0 0
TGFMSCS
TGFSCS
TGFS
ETH_MMCTI
0x108 R Reserved Reserved Reserved
Reset value 0 0 0
RGUFM
RFCEM
RFAEM
ETH_MMCRI
0x10C MR Reserved Reserved Reserved
Reset value 0 0 0
TGFMSCM
TGFSCM
TGFM
ETH_MMCTI
0x110 MR Reserved Reserved Reserved
Reset value 0 0 0
ETH_MMCTG
TGFSCC
0x14C FSCCR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MMCTG
TGFMSCC
0x150 FMSCCR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MMCTG
TGFC
0x168 FCR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MMCRF
RFCEC
0x194 CECR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MMCRF
RFAEC
0x198 AECR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_MMCR
RGUFC
0x1C4 GUFCR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TTSARU
TSFCU
TSSTU
TSITE
TSSTI
ETH_PTPTS
TSE
0x700 CR Reserved
Reset value 0 0 0 0 0 0
ETH_PTPSSI
STSSI
0x704 R Reserved
Reset value 0 0 0 0 0 0 0 0
ETH_PTPTS
STS[31:0]
0x708 HR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
STPNS
ETH_PTPTSL
STSS
0x70C R
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_PTPTS
TSUS
0x710 HUR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
TSUPNS
ETH_PTPTSL
TSUSS
0x714 UR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
Offset Register
9
8
7
6
5
4
3
2
1
0
ETH_PTPTS
TSA
0x718 AR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_PTPTT
TTSH
0x71C HR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_PTPTTL
TTSL
0x720 R
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
EDFE
ETH_DMABM
FPM
USP
AAB
SR
DA
FB
RDP RTPR PBL DSL
0x1000 R Reserved
Reset value 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1
ETH_DMATP
TPD
0x1004 DR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_DMARP
RPD
0x1008 DR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_DMARD
SRL
0x100C LAR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_DMATD
STL
0x1010 LAR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
MMCS
Reserved
DTCEFD Reserved
Reserved
RWTS
PMTS
RBUS
RPSS
TBUS
FBES
TPSS
TSTS
TJTS
ROS
RPS
ERS
EBS
TUS
TPS
ETS
NIS
AIS
RS
TS
ETH_DMASR
0x1014
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Reserved
Reserved
Reserved
FUGF
DFRF
ETH_DMAOM
OSF
RTC
RSF
TTC
TSF
FEF
FTF
SR
ST
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
RWTIE
RBUIE
RPSIE
Reserved
TBUIE
FBEIE
TPSIE
TJTIE
ROIE
NISE
ERIE
AISE
TUIE
ETH_DMAIE
ETIE
RIE
TIE
0x101C R Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
OMFC
OFOC
ETH_DMAMF
MFA
MFC
0x1020 BOCR Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_DMACH
HTDAP
0x1048 TDR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_DMACH
HRDAP
0x104C RDR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_DMACH
HTBAP
0x1050 TBAR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ETH_DMACH
HRBAP
0x1054 RBAR
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
F_SIZE
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
U_ID(15:0)
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
U_ID(31:16)
r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
U_ID(63:48)
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
U_ID(47:32)
r r r r r r r r r r r r r r r r
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
U_ID(95:80)
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
U_ID(79:64)
r r r r r r r r r r r r r r r r
29.1 Overview
The STM32F10xxx is built around a Cortex-M3 core which contains hardware extensions for
advanced debugging features. The debug extensions allow the core to be stopped either on
a given instruction fetch (breakpoint) or data access (watchpoint). When stopped, the core’s
internal state and the system’s external state may be examined. Once examination is
complete, the core and the system may be restored and program execution resumed.
The debug features are used by the debugger host when connecting to and debugging the
STM32F10xxx MCU.
Two interfaces for debug are available:
● Serial wire
● JTAG debug port
Cortex-M3 Data
System
Core interface
JTMS/
SWDIO External private
peripheral bus (PPB)
JTDI
Bridge ETM
JTDO/
TRACESWO SWJ-DP AHB-AP
TRACESWO
NJTRST Internal private NVIC Trace port
peripheral bus (PPB) TRACECK
JTCK/ TPIU
SWCLK
DWT TRACED[3:0]
FPB
DBGMCU
ITM
ai17113
Note: The debug features embedded in the Cortex-M3 core are a subset of the ARM CoreSight
Design Kit.
The ARM Cortex-M3 core provides integrated on-chip debug support. It is comprised of:
● SWJ-DP: Serial wire / JTAG debug port
● AHP-AP: AHB access port
● ITM: Instrumentation trace macrocell
● FPB: Flash patch breakpoint
● DWT: Data watchpoint trigger
● TPUI: Trace port unit interface (available on larger packages, where the corresponding
pins are mapped)
● ETM: Embedded Trace Macrocell (available on larger packages, where the
corresponding pins are mapped)
It also includes debug features dedicated to STM32F10xxx:
● Flexible debug pinout assignment
● MCU debug box (support for low-power modes, control over peripheral clocks, etc.)
Note: For further information on debug functionality supported by the ARM Cortex-M3 core, refer
to the Cortex-M3-r1p1Technical Reference Manual (see Related documents on page 1) and
to the CoreSight Design Kit-r1p0TRM.
SWJ-DP
JTDO TDO
TDO
TDI
JTDI TDI
nTRST
JNTRST nTRST
JTAG-DP
TCK
TMS
nPOTRST
From
SWD/JTAG power-on
select nPOTRST reset
DBGRESETn
SWDITMS
DBGDI
JTMS/SWDIO
SWDO
DBGDO
SW-DP
SWDOEN
DBGDOEN
SWCLKTCK
JTCK/SWCLK DBGCLK
Figure 321 shows that the asynchronous TRACE output (TRACESWO) is multiplexed with
TDO. This means that the asynchronous trace can only be used with SW-DP, not JTAG-DP.
JTAG-DP and enables the SW-DP. This way it is possible to activate the SWDP using only
the SWCLK and SWDIO pins.
This sequence is:
1. Send more than 50 TCK cycles with TMS (SWDIO) =1
2. Send the 16-bit sequence on TMS (SWDIO) = 0111100111100111 (MSB transmitted
first)
3. Send more than 50 TCK cycles with TMS (SWDIO) =1
Three control bits allow the configuration of the SWJ-DP pin assignments. These bits are
reset by the System Reset.
● AFIO_MAPR (@ 0x40010004 in STM32F10xxx MCU)
– READ: APB - No Wait State
– WRITE: APB - 1 Wait State if the write buffer of the AHB-APB bridge is full.
Bit 26:24= SWJ_CFG[2:0]
Set and cleared by software.
These bits are used to configure the number of pins assigned to the SWJ debug port.
The goal is to release as much as possible the number of pins to be used as General
Purpose I/Os if using a small size for the debug port.
The default state after reset is “000” (whole pins assigned for a full JTAG-DP
connection). Only one of the 3 bits can be set (it is forbidden to set more than one bit).
Note: When the APB bridge write buffer is full, it takes one extra APB cycle when writing the
AFIO_MAPR register. This is because the deactivation of the JTAGSW pins is done in two
cycles to guarantee a clean level on the nTRST and TCK input signals of the core.
● Cycle 1: the JTAGSW input signals to the core are tied to 1 or 0 (to 1 for nTRST, TDI
and TMS, to 0 for TCK)
● Cycle 2: the GPI/O controller takes the control signals of the SWJTAG I/O pins (like
controls of direction, pull-up/down, Schmitt trigger activation, etc.).
Once a JTAG I/O is released by the user software, the GPIO controller takes control again.
The reset states of the GPIO control registers put the I/Os in the equivalent state:
● JNTRST: Input pull-up
● JTDI: Input pull-up
● JTMS/SWDIO: Input pull-up
● JTCK/SWCLK: Input pull-down
● JTDO: Input floating
The software can then use these I/Os as standard GPIOs.
Note: The JTAG IEEE standard recommends to add pull-ups on TDI, TMS and nTRST but there is
no special recommendation for TCK. However, for STM32F10xxx, an integrated pull-down is
used for JTCK.
Having embedded pull-ups and pull-downs removes the need to add external resistors.
29.4.4 Using serial wire and releasing the unused debug pins as GPIOs
To use the serial wire DP to release some GPIOs, the user software must set
SWJ_CFG=010 just after reset. This release PA15, PB3 and PB4 which now become
available as GPIOs.
When debugging, the host performs the following actions:
● Under system RESET, all SWJ pins are assigned (JTAG-DP + SW-DP)
● Under system RESET, the debugger host sends the JTAG sequence to switch from the
JTAG-DP to the SW-DP.
● Still under system RESET, the debugger sets a breakpoint on vector reset
● The System Reset is released and the Core halts.
● All the debug communications from this point are done using the SW-DP. The other
JTAG pins can then be reassigned as GPIOs by the user software.
Note: For user software designs, note that:
To release the debug pins, remember that they will be first configured either in input-pull-up
(nTRST, TMS, TDI) or pull-down (TCK) or output tristate (TDO) for a certain duration after
reset until the instant when the user software releases the pins.
When debug pins (JTAG or SW or TRACE) are mapped, changing the corresponding I/O pin
configuration in the IOPORT controller has no effect.
Note: Important: Once Serial-Wire is selected using the dedicated ARM JTAG sequence, the
boundary scan TAP is automatically disabled (JTMS forced high).
STM32F10xxx
JNTRST
JTMS
SW-DP
Selected
Boundary scan
TAP Cortex-M3 TAP
IR is 5-bit wide IR is 4-bit wide
JTDO
ai14981
DBGMCU_IDCODE
Address: 0xE0042000
Only 32-bits access supported. Read-only.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
REV_ID
r r r r r r r r r r r r r r r r
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DEV_ID
Reserved
r r r r r r r r r r r r
BYPASS
1111
[1 bit]
IDCODE ID CODE
1110
[32 bits] 0x3BA00477 (ARM Cortex-M3 r1p1-01rel0 ID Code)
Table 201. 32-bit debug port registers addressed through the shifted value A[3:2]
Address A(3:2) value Description
0x0 00 Reserved
DP CTRL/STAT register. Used to:
– Request a system or debug power-up
0x4 01 – Configure the transfer operation for AP accesses
– Control the pushed compare and pushed verify operations.
– Read some status flags (overrun, power-up acknowledges)
DP SELECT register: Used to select the current access port and the
active 4-words register window.
– Bits 31:24: APSEL: select the current AP
0x8 10 – Bits 23:8: reserved
– Bits 7:4: APBANKSEL: select the active 4-words register window on the
current AP
– Bits 3:0: reserved
DP RDBUFF register: Used to allow the debugger to get the final result
0xC 11 after a sequence of operations (without requesting new JTAG-DP
operation)
Refer to the Cortex-M3 r1p1 TRM for a detailed description of DPACC and APACC registers.
The packet request is always followed by the turnaround time (default 1 bit) where neither
the host nor target drive the line.
001: FAULT
0..2 ACK 010: WAIT
100: OK
The ACK Response must be followed by a turnaround time only if it is a READ transaction or
if a WAIT or FAULT acknowledge has been received.
WDATA or
0..31 Write or Read data
RDATA
32 Parity Single parity of the 32 data bits
The DATA transfer must be followed by a turnaround time only if it is a READ transaction.
Note: Note that the SW-DP state machine is inactive until the target reads this ID code.
● The SW-DP state machine is in RESET STATE either after power-on reset, or after the
DP has switched from JTAG to SWD or after the line is high for more than 50 cycles
● The SW-DP state machine is in IDLE STATE if the line is low for at least two cycles after
RESET state.
● After RESET state, it is mandatory to first enter into an IDLE state AND to perform a
READ access of the DP-SW ID CODE register. Otherwise, the target will issue a
FAULT acknowledge response on another transactions.
Further details of the SW-DP state machine can be found in the Cortex-M3 r1p1 TRM and
the CoreSight Design Kit r1p0 TRM.
Purpose is to:
– request a system or debug power-up
– configure the transfer operation for AP
accesses
01 Read/Write 0 DP-CTRL/STAT
– control the pushed compare and pushed
verify operations.
– read some status flags (overrun, power-up
acknowledges)
Purpose is to configure the physical serial
WIRE
01 Read/Write 1 port protocol (like the duration of the
CONTROL
turnaround time)
Enables recovery of the read data from a
READ
10 Read corrupted debugger transfer, without
RESEND
repeating the original AP transfer.
The purpose is to select the current access
10 Write SELECT
port and the active 4-words register window
This read buffer is useful because AP
accesses are posted (the result of a read AP
request is available on the next AP
READ transaction).
11 Read/Write
BUFFER
This read buffer captures data from the AP,
presented as the result of a previous read,
without initiating a new transaction
29.9 AHB-AP (AHB access port) - valid for both JTAG-DP or SW-
DP
Features:
● System access is independent of the processor status.
● Either SW-DP or JTAG-DP accesses AHB-AP.
● The AHB-AP is an AHB master into the Bus Matrix. Consequently, it can access all the
data buses (Dcode Bus, System Bus, internal and external PPB bus) but the ICode
bus.
● Bitband transactions are supported.
● AHB-AP transactions bypass the FPB.
The address of the 32-bits AHP-AP resisters are 6-bits wide (up to 64 words or 256 bytes)
and consists of:
c) Bits [8:4] = the bits[7:4] APBANKSEL of the DP SELECT register
d) Bits [3:2] = the 2 address bits of A(3:2) of the 35-bit packet request for SW-DP.
The AHB-AP of the Cortex-M3 includes 9 x 32-bits registers:
Note: Important: these registers are not reset by a system reset. They are only reset by a power-
on reset.
Refer to the Cortex-M3 r1p1 TRM for further details.
To Halt on reset, it is necessary to:
● enable the bit0 (VC_CORRESET) of the Debug and Exception Monitor Control
Register
● enable the bit0 (C_DEBUGEN) of the Debug Halting Control and Status Register.
For this, the DWT must be configured to trigger the ITM: the bit CYCCNTENA (bit0) of the
DWT Control Register must be set. In addition, the bit2 (SYNCENA) of the ITM Trace
Control Register must be set.
Note: If the SYNENA bit is not set, the DWT generates Synchronization triggers to the TPIU which
will send only TPIU synchronization packets and not ITM synchronization packets.
An overflow packet consists is a special timestamp packets which indicates that data has
been written but the FIFO was full.
Example of configuration
To output a simple value to the TPIU:
● Configure the TPIU and assign TRACE I/Os by configuring the DBGMCU_CR (refer to
Section 29.17.2: TRACE pin assignment and Section 29.16.3: Debug MCU
configuration register)
● Write 0xC5ACCE55 to the ITM Lock Access Register to unlock the write access to the
ITM registers
● Write 0x00010005 to the ITM Trace Control Register to enable the ITM with Sync
enabled and an ATB ID different from 0x00
● Write 0x1 to the ITM Trace Enable Register to enable the Stimulus Port 0
● Write 0x1 to the ITM Trace Privilege Register to unmask stimulus ports 7:0
● Write the value to output in the Stimulus Port Register 0: this can be done by software
(using a printf function)
For this, the debugger host must first set some debug configuration registers to change the
low-power mode behavior:
● In Sleep mode, DBG_SLEEP bit of DBGMCU_CR register must be previously set by
the debugger. This will feed HCLK with the same clock that is provided to FCLK
(system clock previously configured by the software).
● In STOP mode, the bit DBG_STOP must be previously set by the debugger. This will
enable the internal RC oscillator clock to feed FCLK and HCLK in STOP mode.
DBGMCU_CR
Address: 0xE004 2004
Only 32-bit access supported
POR Reset: 0x0000 0000 (not reset by system reset)
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
DGB_C DBG_ DBG_ DBG_ DBG_ DBG_I2C2
AN2_ST TIM7_ TIM6_ TIM5_ TIM8_ _SMBUS_
Reserved OP STOP STOP STOP STOP TIMEOUT
rw rw rw rw rw rw
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DBG_I2C1 DBG_ DBG_ DBG_ DBG_ DBG_ DBG_ DBG_ TRACE_ DBG_
TRACE_ DBG_ DBG_
_SMBUS_ CAN1_ TIM4_ TIM3_ TIM2_ TIM1_ WWDG_ IWDG MODE STAND
IOEN Reserved STOP SLEEP
TIMEOUT STOP STOP STOP STOP STOP STOP STOP [1:0] BY
rw rw rw rw rw rw rw rw rw rw rw rw rw rw
29.17.1 Introduction
The TPIU acts as a bridge between the on-chip trace data from the ITM and the ETM.
The output data stream encapsulates the trace source ID, that is then captured by a Trace
Port Analyzer (TPA).
The core embeds a simple TPIU, especially designed for low-cost debug (consisting of a
special version of the CoreSight TPIU).
TPIU
TRACECLKIN
Asynchronous
ETM
FIFO
TRACECK
TPIU Trace out
formatter (serializer) TRACEDATA
[3:0]
ITM Asynchronous
FIFO
TRACESWO
ai17114
● Synchronous mode
The synchronous mode requires from 2 to 6 extra pins depending on the data trace
size and is only available in the larger packages. In addition it is available in JTAG mode
and in Serial Wire mode and provides better bandwidth output capabilities than
asynchronous trace.
TRACE_
No Trace (default
0 XX Released (1)
state)
Asynchronous Released
1 00 TRACESWO
Trace (usable as GPIO)
Synchronous Trace TRACEC TRACED
1 01
1 bit K [0]
Synchronous Trace TRACEC TRACED TRACED[
1 10 Released (1)
2 bit K [0] 1]
Synchronous Trace TRACEC TRACED TRACED[ TRACED[ TRACED[
1 11
4 bit K [0] 1] 2] 3]
1. When Serial Wire mode is used, it is released. But when JTAG is used, it is assigned to JTDO.
Note: By default, the TRACECLKIN input clock of the TPIU is tied to GND. It is assigned to HCLK
two clock cycles after the bit TRACE_IOEN has been set.
The debugger must then program the Trace Mode by writing the PROTOCOL[1:0] bits in the
SPP_R (Selected Pin Protocol) register of the TPIU.
● PROTOCOL=00: Trace Port Mode (synchronous)
● PROTOCOL=01 or 10: Serial Wire (Manchester or NRZ) Mode (asynchronous mode).
Default state is 01
It then also configures the TRACE port size by writing the bits [3:0] in the CPSPS_R
(Current Sync Port Size Register) of the TPIU:
● 0x1 for 1 pin (default state)
● 0x2 for 2 pins
● 0x8 for 4 pins
registers DWT Control Register (bits SYNCTAP[11:10]) and the DWT Current PC Sampler
Cycle Count Register.
The TPUI Frame synchronization packet (0x7F_FF_FF_FF) is emitted:
● after each TPIU reset release. This reset is synchronously released with the rising
edge of the TRACECLKIN clock. This means that this packet is transmitted when the
TRACE_IOEN bit in the DBGMCU_CFG register is set. In this case, the word
0x7F_FF_FF_FF is not followed by any formatted packet.
● at each DWT trigger (assuming DWT has been previously configured). Two cases
occur:
– If the bit SYNENA of the ITM is reset, only the word 0x7F_FF_FF_FF is emitted
without any formatted stream which follows.
– If the bit SYNENA of the ITM is set, then the ITM synchronization packets will
follow (0x80_00_00_00_00_00), formatted by the TPUI (trace source ID added).
9
8
7
6
5
4
3
2
1
0
0xE0042000
DBGMCU_
REV_ID DEV_ID
IDCODE Reserved
Reset value(1) X X X X X X X X X X X X X X X X X X X X X X X X X X X X
DBG_I2C2_SMBUS_TIMEOUT
DBG_I2C1_SMBUS_TIMEOUT
DBG_WWDG_STOP
TRACE_MODE[1:0]
DGB_CAN2_STOP
DBG_CAN1_STOP
DBG_TIM7_STOP
DBG_TIM6_STOP
DBG_TIM5_STOP
DBG_TIM8_STOP
DBG_TIM4_STOP
DBG_TIM3_STOP
DBG_TIM2_STOP
DBG_TIM1_STOP
DBG_IWDGSTOP
DBG_STANDBY
TRACE_IOEN
DBG_SLEEP
DBG_STOP
0xE0042004
Reserved
DBGMCU_CR
Reserved
Reset value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1. The reset value is product dependent. For more information, refer to Section 29.6.1: MCU device ID code.
30 Revision history
In Section 6: Low-, medium- and high-density reset and clock control (RCC)
on page 74:
– LSI calibration on page 80 added
– Figure 7: Reset circuit on page 75 updated
– APB2 peripheral reset register (RCC_APB2RSTR) on page 89 updated
– APB1 peripheral reset register (RCC_APB1RSTR) on page 91 updated
– AHB peripheral clock enable register (RCC_AHBENR) updated
– APB2 peripheral clock enable register (RCC_APB2ENR) updated
– APB1 peripheral clock enable register (RCC_APB1ENR) on page 97
updated (see Section Table 15.: RCC register map and reset values).
– LSERDYIE definition modified in Clock interrupt register (RCC_CIR)
– HSITRIM[4:0] definition modified in Clock control register (RCC_CR)
In Section 8: General-purpose and alternate-function I/Os (GPIOs and
AFIOs) on page 138:
– GPIO ports F and G added
– In Section 8.3: Alternate function I/O and debug configuration (AFIO) on
page 152 remapping for High-density devices added, note modified under
Section 8.3.2, Section 8.3.3 on page 153 modified
– AF remap and debug I/O configuration register (AFIO_MAPR) on
page 159 updated
Updated in Section 9: Interrupts and events on page 169:
– number of maskable interrupt channels
– number of GPIOs (see Figure 21: External interrupt/event GPIO mapping)
22-May-2008 4 In Section 10: DMA controller (DMA) on page 182:
continued continued – number of DMA controllers and configurable DMA channels updated
– Figure 22: DMA block diagram in connectivity line devices on page 183
updated, notes added
– Note updated in Section 10.3.2: Arbiter on page 184
– Note updated in Section 10.3.6: Interrupts on page 187
– Figure 23: DMA1 request mapping on page 188 updated
– DMA2 controller on page 189 added
In Section 11: Analog-to-digital converter (ADC) on page 198:
– ADC3 added (Figure 25: Single ADC block diagram on page 200 updated,
Table 65: External trigger for injected channels for ADC3 added, etc.)
Section 12: Digital-to-analog converter (DAC) on page 233 added.
In Section 13: Advanced-control timers (TIM1&TIM8) on page 253:
– Advanced control timer TIM8 added (see Figure 51: Advanced-control
timer block diagram on page 255)
– TS[2:0] modified in Section 13.4.3: TIM1&TIM8 slave mode control
register (TIMx_SMCR) on page 297.
In Section 14: General-purpose timer (TIMx) on page 319:
– TIM5 added
– Figure 99: General-purpose timer block diagram on page 321 updated.
Table 76: TIMx Internal trigger connection on page 359 modified.
Section 15: Basic timers (TIM6&TIM7) on page 375 added.
RTC clock sources specified in Section 16.2: RTC main features on
page 388. Section 16.1: RTC introduction modified.
Section 19: Flexible static memory controller (FSMC) on page 409 added.
Section 20: Secure digital input/output interface (SDIO) on page 456 added.
Figure 205: CAN frames on page 560 modified. Bits 31:21 and bits 20:3
modified in CAN TX mailbox identifier register (CAN_TIxR) (x=0..2) on
page 573. Bits 31:21 and bits 20:3 modified in CAN receive FIFO mailbox
identifier register (CAN_RIxR) (x=0..1) on page 576.
Section 24.3.7: DMA requests on page 637 modified. DMAEN bit 11
description modified in Section 24.6.2: Control register 2 (I2C_CR2) on
page 643.
Clock phase and clock polarity on page 591 modified. Transmit sequence on
page 593 modified. Receive sequence on page 594 added. Reception
sequence on page 612 modified. Underrun flag (UDR) on page 613
22-May-2008 4 modified.
2
continued continued I S feature added (see Section 23: Serial peripheral interface (SPI) on
page 586).
In Section 29: Debug support (DBG) on page 952:
– DBGMCU_IDCODE on page 959 and DBGMCU_CR on page 972
updated
– TMC TAP changed to boundary scan TAP
– Address onto which DBGMCU_CR is mapped modified in
Section 29.16.3: Debug MCU configuration register on page 972.
Section 28: Device electronic signature on page 949 added.
REV_ID(15:0) definition modified in Section 29.6.1: MCU device ID code on
page 958.
Memory map figure removed from reference manual. Section 2.1: System
architecture on page 38 modified. Section 2.4: Boot configuration on
page 48 modified. Exiting Sleep mode on page 58 modified. Section 5.3.2:
RTC calibration on page 67 updated. Wakeup event management on
page 175 updated.
Section 6.3: RCC registers on page 82 updated. Section 10.2: DMA main
features on page 182 updated.
Section 10.3.5: Error management modified. Figure 22: DMA block diagram
in connectivity line devices on page 183 modified. Section 10.3.4:
Programmable data width, data alignment and endians on page 186 added.
Bit definition modified in Section 10.4.5: DMA channel x peripheral address
register (DMA_CPARx) (x = 1 ..7) on page 195 and Section 10.4.6: DMA
channel x memory address register (DMA_CMARx) (x = 1 ..7) on page 195.
Note added below Figure 81: PWM input mode timing and Figure 127: PWM
input mode timing.
FSMC_NWAIT signal direction corrected in Figure 19.3: AHB interface on
page 410.
Value to set modified for bit 6 in Table 98: FSMC_BCRx bit fields, Table 101:
FSMC_BCRx bit fields and Table 107: FSMC_BCRx bit fields. Table 114: 8-
bit NAND Flash, Table 115: 16-bit NAND Flash and Table 116: 16-bit PC
Card modified. NWAIT and INTR signals separated in Table 116: 16-bit PC
Card. Note added in PWAITEN bit definition in PC Card/NAND Flash control
registers 2..4 (FSMC_PCR2..4) on page 448.
Bit definitions updated in FIFO status and interrupt register 2..4
(FSMC_SR2..4) on page 449. Note modified in ADDHLD and ADDSET bit
23-Dec-2008 7 definitions in SRAM/NOR-Flash chip-select timing registers 1..4
(FSMC_BTR1..4) on page 438. Bit 8 is reserved in PC Card/NAND Flash
control registers 2..4 (FSMC_PCR2..4) on page 448.
MEMWAIT[15:8] bit definition modified in Common memory space timing
register 2..4 (FSMC_PMEM2..4) on page 450.
ATTWAIT[15:8] bit definition modified in Attribute memory space timing
registers 2..4 (FSMC_PATT2..4) on page 451.
Section 19.6.5: NAND Flash pre-wait functionality on page 446 modified.
Figure 175: NAND/PC Card controller timing for common memory access
modified.
Note added below Table 84: NOR/PSRAM bank selection on page 412.
32-bit external memory access removed from Table 85: External memory
address on page 412 and note added.
Caution: added to Section 19.6.1: External memory interface signals on
page 442.
NIOS16 description modified in Table 116: 16-bit PC Card on page 443.
Register description modified in Attribute memory space timing registers 2..4
(FSMC_PATT2..4) on page 451.
Resetting the password on page 478 step 2 corrected.
write_data signal modified in Figure 175: NAND/PC Card controller timing
for common memory access.
bxCAN main features on page 542 modified.
Section 24.3.8: Packet error checking on page 639 modified.
Section 29.6.3: Cortex-M3 TAP modified.
DBG_TIMx_STOP positions modified in DBGMCU_CR on page 972.
Small text changes.
Index
A CAN_TDHxR . . . . . . . . . . . . . . . . . . . . . . . . . 575
CAN_TDLxR . . . . . . . . . . . . . . . . . . . . . . . . . 575
ADC_CR1 . . . . . . . . . . . . . . . . . . . . . . . . . . .220
CAN_TDTxR . . . . . . . . . . . . . . . . . . . . . . . . . 574
ADC_CR2 . . . . . . . . . . . . . . . . . . . . . . . . . . .222
CAN_TIxR . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
ADC_DR . . . . . . . . . . . . . . . . . . . . . . . . . . . .230
CAN_TSR . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
ADC_HTR . . . . . . . . . . . . . . . . . . . . . . . . . . .227
CRC_DR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
ADC_JDRx . . . . . . . . . . . . . . . . . . . . . . . . . . .230
CRC_IDR . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ADC_JOFRx . . . . . . . . . . . . . . . . . . . . . . . . .226
ADC_JSQR . . . . . . . . . . . . . . . . . . . . . . . . . .229
ADC_LTR . . . . . . . . . . . . . . . . . . . . . . . . . . . .227 D
ADC_SMPR1 . . . . . . . . . . . . . . . . . . . . . . . . .225 DBGMCU_CR . . . . . . . . . . . . . . . . . . . . . . . . 972
ADC_SMPR2 . . . . . . . . . . . . . . . . . . . . . . . . .226 DBGMCU_IDCODE . . . . . . . . . . . . . . . . . . . 959
ADC_SQR1 . . . . . . . . . . . . . . . . . . . . . . . . . .227 DMA_CCRx . . . . . . . . . . . . . . . . . . . . . . . . . . 193
ADC_SQR2 . . . . . . . . . . . . . . . . . . . . . . . . . .228 DMA_CMARx . . . . . . . . . . . . . . . . . . . . . . . . 195
ADC_SQR3 . . . . . . . . . . . . . . . . . . . . . . . . . .229 DMA_CNDTRx . . . . . . . . . . . . . . . . . . . . . . . 194
ADC_SR . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 DMA_CPARx . . . . . . . . . . . . . . . . . . . . . . . . . 195
AFIO_EVCR . . . . . . . . . . . . . . . . . . . . . . . . . .158 DMA_IFCR . . . . . . . . . . . . . . . . . . . . . . . . . . 192
AFIO_EXTICR1 . . . . . . . . . . . . . . . . . . . . . . .165 DMA_ISR . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
AFIO_EXTICR2 . . . . . . . . . . . . . . . . . . . . . . .165
AFIO_EXTICR3 . . . . . . . . . . . . . . . . . . . . . . .166
AFIO_EXTICR4 . . . . . . . . . . . . . . . . . . . . . . .166 E
AFIO_MAPR . . . . . . . . . . . . . . . . . . . . . . . . .159 ETH_DMABMR . . . . . . . . . . . . . . . . . . . . . . . 932
ETH_DMACHRBAR . . . . . . . . . . . . . . . . . . . 945
B ETH_DMACHRDR . . . . . . . . . . . . . . . . . . . . 945
ETH_DMACHTBAR . . . . . . . . . . . . . . . . . . . 945
BKP_CR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 ETH_DMACHTDR . . . . . . . . . . . . . . . . . . . . . 944
BKP_CSR . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 ETH_DMAIER . . . . . . . . . . . . . . . . . . . . . . . . 942
BKP_DRx . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 ETH_DMAMFBOCR . . . . . . . . . . . . . . . . . . . 944
BKP_RTCCR . . . . . . . . . . . . . . . . . . . . . . . . . .68 ETH_DMAOMR . . . . . . . . . . . . . . . . . . . . . . . 939
ETH_DMARDLAR . . . . . . . . . . . . . . . . . . . . . 935
C ETH_DMARPDR . . . . . . . . . . . . . . . . . . . . . . 934
ETH_DMASR . . . . . . . . . . . . . . . . . . . . . . . . 935
CAN_BTR . . . . . . . . . . . . . . . . . . . . . . . . . . .571
ETH_DMATDLAR . . . . . . . . . . . . . . . . . . . . . 935
CAN_ESR . . . . . . . . . . . . . . . . . . . . . . . . . . .570
ETH_DMATPDR . . . . . . . . . . . . . . . . . . . . . . 934
CAN_FA1R . . . . . . . . . . . . . . . . . . . . . . . . . .581
ETH_MACA0HR . . . . . . . . . . . . . . . . . . . . . . 917
CAN_FFA1R . . . . . . . . . . . . . . . . . . . . . . . . .581
ETH_MACA0LR . . . . . . . . . . . . . . . . . . . . . . 918
CAN_FiRx . . . . . . . . . . . . . . . . . . . . . . . . . . .582
ETH_MACA1HR . . . . . . . . . . . . . . . . . . . . . . 918
CAN_FM1R . . . . . . . . . . . . . . . . . . . . . . . . . .580
ETH_MACA1LR . . . . . . . . . . . . . . . . . . . . . . 919
CAN_FMR . . . . . . . . . . . . . . . . . . . . . . . . . . .579
ETH_MACA2HR . . . . . . . . . . . . . . . . . . . . . . 919
CAN_FS1R . . . . . . . . . . . . . . . . . . . . . . . . . .580
ETH_MACA2LR . . . . . . . . . . . . . . . . . . . . . . 920
CAN_IER . . . . . . . . . . . . . . . . . . . . . . . . . . . .569
ETH_MACA3HR . . . . . . . . . . . . . . . . . . . . . . 920
CAN_MCR . . . . . . . . . . . . . . . . . . . . . . . . . . .562
ETH_MACA3LR . . . . . . . . . . . . . . . . . . . . . . 921
CAN_MSR . . . . . . . . . . . . . . . . . . . . . . . . . . .564
ETH_MACCR . . . . . . . . . . . . . . . . . . . . . . . . 906
CAN_RDHxR . . . . . . . . . . . . . . . . . . . . . . . . .578
ETH_MACFCR . . . . . . . . . . . . . . . . . . . . . . . 912
CAN_RDLxR . . . . . . . . . . . . . . . . . . . . . . . . .578
ETH_MACFFR . . . . . . . . . . . . . . . . . . . . . . . 909
CAN_RDTxR . . . . . . . . . . . . . . . . . . . . . . . . .577
ETH_MACHTHR . . . . . . . . . . . . . . . . . . . . . . 910
CAN_RF0R . . . . . . . . . . . . . . . . . . . . . . . . . .567
ETH_MACHTLR . . . . . . . . . . . . . . . . . . . . . . 911
CAN_RF1R . . . . . . . . . . . . . . . . . . . . . . . . . .568
ETH_MACIMR . . . . . . . . . . . . . . . . . . . . . . . . 917
CAN_RIxR . . . . . . . . . . . . . . . . . . . . . . . . . . .576
ETH_MACMIIAR . . . . . . . . . . . . . . . . . . . . . . 911
P T
PWR_CR . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 TIMx_ARR . . . . . . . . . . . . . . . . . . . . . . . 370, 385
PWR_CSR . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 TIMx_BDTR . . . . . . . . . . . . . . . . . . . . . . . . . . 314
TIMx_CCER . . . . . . . . . . . . . . . . . . . . . 308, 368
TIMx_CCMR1 . . . . . . . . . . . . . . . . . . . . 304, 363
R
TIMx_CCMR2 . . . . . . . . . . . . . . . . . . . . 307, 367
RCC_AHBENR . . . . . . . . . . . . . . . 93, 125, 133 TIMx_CCR1 . . . . . . . . . . . . . . . . . . . . . . 312, 370
RCC_APB1ENR . . . . . . . . . . . . . . . . . . . .97, 128 TIMx_CCR2 . . . . . . . . . . . . . . . . . . . . . . 313, 371
RCC_APB1RSTR . . . . . . . . . . . . . . . . . .91, 122 TIMx_CCR3 . . . . . . . . . . . . . . . . . . . . . . 313, 371
RCC_APB2ENR . . . . . . . . . . . . . . . . . . . .95, 126 TIMx_CCR4 . . . . . . . . . . . . . . . . . . . . . . 314, 372
RCC_APB2RSTR . . . . . . . . . . . . . . . . . .89, 121 TIMx_CNT . . . . . . . . . . . . . . . . . . . 311, 369, 384
RCC_BDCR . . . . . . . . . . . . . . . . . . . . . . .99, 130 TIMx_CR1 . . . . . . . . . . . . . . . . . . . 294, 355, 381
RCC_CFGR . . . . . . . . . . . . . . . . . . 84, 115, 134 TIMx_CR2 . . . . . . . . . . . . . . . . . . . 295, 356, 383
RCC_CIR . . . . . . . . . . . . . . . . . . . . . . . . .87, 118 TIMx_DCR . . . . . . . . . . . . . . . . . . . . . . . 316, 372
RCC_CR . . . . . . . . . . . . . . . . . . . . . . . . .83, 113 TIMx_DIER . . . . . . . . . . . . . . . . . . 299, 360, 383
RCC_CSR . . . . . . . . . . . . . . . . . . . . . . .101, 132 TIMx_DMAR . . . . . . . . . . . . . . . . . . . . . 317, 373
RTC_ALRH . . . . . . . . . . . . . . . . . . . . . . . . . .397 TIMx_EGR . . . . . . . . . . . . . . . . . . . 302, 362, 384
RTC_ALRL . . . . . . . . . . . . . . . . . . . . . . . . . . .397 TIMx_PSC . . . . . . . . . . . . . . . . . . . 311, 370, 385
RTC_CNTH . . . . . . . . . . . . . . . . . . . . . . . . . .396 TIMx_RCR . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
RTC_CNTL . . . . . . . . . . . . . . . . . . . . . . . . . .396 TIMx_SMCR . . . . . . . . . . . . . . . . . . . . . 297, 357
RTC_CRH . . . . . . . . . . . . . . . . . . . . . . . . . . .392 TIMx_SR . . . . . . . . . . . . . . . . . . . . 301, 361, 384
RTC_CRL . . . . . . . . . . . . . . . . . . . . . . . . . . . .393
RTC_DIVH . . . . . . . . . . . . . . . . . . . . . . . . . . .395
RTC_DIVL . . . . . . . . . . . . . . . . . . . . . . . . . . .395 U
RTC_PRLH . . . . . . . . . . . . . . . . . . . . . . . . . .394 USART_BRR . . . . . . . . . . . . . . . . . . . . . . . . . 686
RTC_PRLL . . . . . . . . . . . . . . . . . . . . . . . . . . .395 USART_CR1 . . . . . . . . . . . . . . . . . . . . . . . . . 686
USART_CR2 . . . . . . . . . . . . . . . . . . . . . . . . . 688
USART_CR3 . . . . . . . . . . . . . . . . . . . . . . . . . 690
S
USART_DR . . . . . . . . . . . . . . . . . . . . . . . . . . 685
SDIO_CLKCR . . . . . . . . . . . . . . . . . . . . . . . .497 USART_GTPR . . . . . . . . . . . . . . . . . . . . . . . 691
SDIO_DCOUNT . . . . . . . . . . . . . . . . . . . . . . .503 USART_SR . . . . . . . . . . . . . . . . . . . . . . . . . . 683
SDIO_DCTRL . . . . . . . . . . . . . . . . . . . . . . . .502 USB_ADDRn_RX . . . . . . . . . . . . . . . . . . . . . 538
SDIO_DLEN . . . . . . . . . . . . . . . . . . . . . . . . . .501 USB_ADDRn_TX . . . . . . . . . . . . . . . . . . . . . 537
SDIO_DTIMER . . . . . . . . . . . . . . . . . . . . . . . .501 USB_BTABLE . . . . . . . . . . . . . . . . . . . . . . . . 532
SDIO_FIFO . . . . . . . . . . . . . . . . . . . . . . . . . .510 USB_CNTR . . . . . . . . . . . . . . . . . . . . . . . . . . 526
SDIO_FIFOCNT . . . . . . . . . . . . . . . . . . . . . . .509 USB_COUNTn_RX . . . . . . . . . . . . . . . . . . . . 538
SDIO_ICR . . . . . . . . . . . . . . . . . . . . . . . . . . .505 USB_COUNTn_TX . . . . . . . . . . . . . . . . . . . . 537
SDIO_MASK . . . . . . . . . . . . . . . . . . . . . . . . .507 USB_DADDR . . . . . . . . . . . . . . . . . . . . . . . . 531
SDIO_POWER . . . . . . . . . . . . . . . . . . . . . . . .497 USB_EPnR . . . . . . . . . . . . . . . . . . . . . . . . . . 532
SDIO_RESPCMD . . . . . . . . . . . . . . . . . . . . .500 USB_FNR . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
SDIO_RESPx . . . . . . . . . . . . . . . . . . . . . . . . .500 USB_ISTR . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
SDIO_STA . . . . . . . . . . . . . . . . . . . . . . . . . . .504
SPI_CR1 . . . . . . . . . . . . . . . . . . . . . . . . . . . .614
SPI_CR2 . . . . . . . . . . . . . . . . . . . . . . . . . . . .616 W
SPI_CRCPR . . . . . . . . . . . . . . . . . . . . . . . . . .619 WWDG_CFR . . . . . . . . . . . . . . . . . . . . . . . . . 407
SPI_DR . . . . . . . . . . . . . . . . . . . . . . . . . . . . .618 WWDG_CR . . . . . . . . . . . . . . . . . . . . . . . . . . 407
SPI_I2SCFGR . . . . . . . . . . . . . . . . . . . . . . . .620 WWDG_SR . . . . . . . . . . . . . . . . . . . . . . . . . . 408
SPI_I2SPR . . . . . . . . . . . . . . . . . . . . . . . . . . .622
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.