rm0368 reference manual - home - s · pdf filerm0368 reference manual ... this reference...

841
May 2015 DocID025350 Rev 4 1/841 RM0368 Reference manual STM32F401xB/C and STM32F401xD/E advanced ARM ® -based 32-bit MCUs Introduction This Reference manual targets application developers. It provides complete information on how to use the memory and the peripherals of the STM32F401xB/C and STM32F401xD/E microcontrollers. STM32F401xB/C and STM32F401xD/E are part of the STM32F401xx family of microcontrollers with different memory sizes, packages and peripherals. For ordering information, mechanical and electrical device characteristics refer to the datasheets. For information on the ARM ® Cortex ® -M4 with FPU core, refer to the Cortex ® -M4 with FPU Technical Reference Manual. Related documents Available from STMicroelectronics web site (http://www.st.com): STM32F401xB/C datasheet STM32F401xD/E datasheet For information on the ARM ® -M4 core with FPU, refer to the STM32F3xx/F4xxx Cortex ® - M4 with FPU-M4 programming manual (PM0214). www.st.com

Upload: vuthuy

Post on 30-Jan-2018

246 views

Category:

Documents


1 download

TRANSCRIPT

  • May 2015 DocID025350 Rev 4 1/841

    RM0368Reference manual

    STM32F401xB/C and STM32F401xD/E advanced ARM-based 32-bit MCUs

    IntroductionThis Reference manual targets application developers. It provides complete information on how to use the memory and the peripherals of the STM32F401xB/C and STM32F401xD/E microcontrollers.

    STM32F401xB/C and STM32F401xD/E are part of the STM32F401xx family of microcontrollers with different memory sizes, packages and peripherals.

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

    For information on the ARM Cortex-M4 with FPU core, refer to the Cortex-M4 with FPU Technical Reference Manual.

    Related documentsAvailable from STMicroelectronics web site (http://www.st.com): STM32F401xB/C datasheet STM32F401xD/E datasheet For information on the ARM-M4 core with FPU, refer to the STM32F3xx/F4xxx Cortex-

    M4 with FPU-M4 programming manual (PM0214).

    www.st.com

    http://www.st.com

  • Contents RM0368

    2/841 DocID025350 Rev 4

    Contents

    1 Documentation conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341.1 List of abbreviations for registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    1.2 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    1.3 Peripheral availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    2 Memory and bus architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.1 System architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    2.1.1 I-bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.1.2 D-bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.1.3 S-bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.1.4 DMA memory bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.1.5 DMA peripheral bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.1.6 BusMatrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.1.7 AHB/APB bridges (APB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    2.2 Memory organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    2.3 Memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382.3.1 Embedded SRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    2.3.2 Flash memory overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    2.3.3 Bit banding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    2.4 Boot configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3 Embedded Flash memory interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    3.2 Main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    3.3 Embedded Flash memory in STM32F401xB/C andSTM32F401xD/E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

    3.4 Read interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463.4.1 Relation between CPU clock frequency and Flash memory read time . 46

    3.4.2 Adaptive real-time memory accelerator (ART Accelerator) . . . . . . . . 47

    3.5 Erase and program operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493.5.1 Unlocking the Flash control register . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

    3.5.2 Program/erase parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    3.5.3 Erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

  • DocID025350 Rev 4 3/841

    RM0368 Contents

    23

    3.5.4 Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

    3.5.5 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    3.6 Option bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523.6.1 Description of user option bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    3.6.2 Programming user option bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

    3.6.3 Read protection (RDP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

    3.6.4 Write protections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    3.6.5 Proprietary code readout protection (PCROP) . . . . . . . . . . . . . . . . . . . 57

    3.7 One-time programmable bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

    3.8 Flash interface registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603.8.1 Flash access control register (FLASH_ACR) . . . . . . . . . . . . . . . . . . . . 60

    3.8.2 Flash key register (FLASH_KEYR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    3.8.3 Flash option key register (FLASH_OPTKEYR) . . . . . . . . . . . . . . . . . . . 61

    3.8.4 Flash status register (FLASH_SR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

    3.8.5 Flash control register (FLASH_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

    3.8.6 Flash option control register (FLASH_OPTCR) . . . . . . . . . . . . . . . . . . . 65

    3.8.7 Flash interface register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

    4 CRC calculation unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684.1 CRC introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    4.2 CRC main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    4.3 CRC functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

    4.4 CRC registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694.4.1 Data register (CRC_DR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    4.4.2 Independent data register (CRC_IDR) . . . . . . . . . . . . . . . . . . . . . . . . . 69

    4.4.3 Control register (CRC_CR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

    4.4.4 CRC register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

    5 Power controller (PWR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715.1 Power supplies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

    5.1.1 Independent A/D converter supply and reference voltage . . . . . . . . . . . 72

    5.1.2 Battery backup domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    5.1.3 Voltage regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

    5.2 Power supply supervisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.2.1 Power-on reset (POR)/power-down reset (PDR) . . . . . . . . . . . . . . . . . . 74

    5.2.2 Brownout reset (BOR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

  • Contents RM0368

    4/841 DocID025350 Rev 4

    5.2.3 Programmable voltage detector (PVD) . . . . . . . . . . . . . . . . . . . . . . . . . 76

    5.3 Low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765.3.1 Slowing down system clocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

    5.3.2 Peripheral clock gating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

    5.3.3 Sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

    5.3.4 Stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

    5.3.5 Standby mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

    5.3.6 Programming the RTC alternate functions to wake up the device fromthe Stop and Standby modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

    5.4 Power control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 865.4.1 PWR power control register (PWR_CR) . . . . . . . . . . . . . . . . . . . . . . . . 86

    5.4.2 PWR power control/status register (PWR_CSR) . . . . . . . . . . . . . . . . . 88

    5.5 PWR register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

    6 Reset and clock control (RCC) for STM32F401xB/Cand STM32F401xD/E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906.1 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

    6.1.1 System reset . . . . . . . . .