UM0306 STM32F10X 使用参考设置
©2007 MXCHIP Corporation. All rights reserved.
www.mxchip.com
021-52655026/025
UM0306 参考手册
STM32F101xx 和 STM32F103xx
——基于 ARM Cortex-M3 的先进 32 位微控制器
引言
该参考手册以应用开发者为目标,提供了关于如何使用 STM32F101xx 和
STM32F101xx 微控制器存储器和外围设备的完整信息。在整个文档中,STM32F101xx 和
ST32M103xx 将被作为 STM32F10x 提及。
STM32F10x 是一个微控制器系列,该系列的不同微控制器具有不同的存储器大小,组
件以及外围设备。
如果需要其他的信息、机械特性、电器特性,请参照
STM32F101xx and
ST32M103xx datasheets
.。如果需要关于 Flash 存储器的编程、擦除和保护,请参照
STM32F10x Flash Programming Manual。
如果需要关于 ARM Cortex-M3 内核的信
息,请参照
Cortex-M3
TM
Technical Reference Manual。
UM0306 STM32F10X 使用参考设置
©2007 MXCHIP Corporation. All rights reserved.
www.mxchip.com
021-52655026/025
1 文档约定 ...................................................................................................................................... 24
1.1 寄存器的缩写词列表 ................................................................................................ 24
2 存储器和总线的结构 ................................................................................................................. 25
2.1 系统的结构 ................................................................................................................. 25
2.2 存储器结构 ................................................................................................................. 27
2.3 存储器映射 ................................................................................................................. 28
2.3.1 外设存储器映射 ................................................................................................ 29
2.3.2 嵌入式SRAM ..................................................................................................... 31
2.3.3 Bit banding ....................................................................................................... 31
2.3.4 嵌入式Flash存储器 .......................................................................................... 32
2.4 Boot设置 .................................................................................................................... 36
3 电源控制 ...................................................................................................................................... 38
3.1 电源供应 ..................................................................................................................... 38
3.1.1 独立的A/D转换装置和参考电压 .................................................................... 38
3.1.2 电池备份 ............................................................................................................. 39
3.1.3 电压调制器 ......................................................................................................... 39
3.2 电源供应管理 ............................................................................................................. 40
3.2.1 上电复位(POR)/掉电复位(PDR) ......................................................... 40
3.2.2 可编程的电压检测器(PWD) ...................................................................... 41
3.3 低功耗模式 ................................................................................................................. 42
3.3.1 降低系统时钟的速率 ........................................................................................ 43
3.3.2 外设时钟门控..................................................................................................... 43
UM0306 STM32F10X 使用参考设置
©2007 MXCHIP Corporation. All rights reserved.
www.mxchip.com
021-52655026/025
3.3.3 睡眠模式 ............................................................................................................. 44
3.3.4 停止模式 ............................................................................................................. 45
3.3.5 STANDBY模式(STANDBY模式) ............................................................... 47
3.3.6 从低功耗模式自动唤醒(Auto-Wake-Up: AWU) ............................. 49
3.4 电源控制寄存器 ......................................................................................................... 50
3.4.1 电源控制寄存器(PWR_CR) ....................................................................... 50
3.4.2 电源控制/状态寄存器(PWR_CSR)........................................................... 52
3.5 PWR寄存器映射 ....................................................................................................... 54
4 复位和时钟控制 ......................................................................................................................... 55
4.1 复位.............................................................................................................................. 55
4.1.1 系统复位 ............................................................................................................. 55
4.1.2 电源复位 ............................................................................................................. 56
4.1.3 备份区域复位..................................................................................................... 57
4.2 时钟.............................................................................................................................. 57
4.2.1 HSE时钟 ............................................................................................................. 59
4.2.2 HIS时钟 .............................................................................................................. 61
4.2.3 PLL ....................................................................................................................... 61
4.2.4 LSE时钟 .............................................................................................................. 62
4.2.5 LSI时钟 ............................................................................................................... 62
4.2.6 系统时钟(SYSCLK)选择 ............................................................................. 63
4.2.7 时钟安全系统(CSS) ..................................................................................... 63
4.2.8 RTC时钟 .............................................................................................................. 64
UM0306 STM32F10X 使用参考设置
©2007 MXCHIP Corporation. All rights reserved.
www.mxchip.com
021-52655026/025
4.2.9 看门狗时钟 ......................................................................................................... 64
4.2.10 时钟输出性能..................................................................................................... 65
4.3 RCC寄存器描述 ......................................................................................................... 65
4.3.1 时钟控制寄存器(RCC_CR) ......................................................................... 65
4.3.2 时钟配置寄存器 ................................................................................................ 68
4.3.3 时钟中断寄存器 ................................................................................................ 73
4.3.4 APB2 外设复位寄存器 (RCC_APB2RSTR) ........................................... 77
4.3.5 APB1 外设复位寄存器 (RCC_APB1RSTR) ........................................... 80
4.3.6 AHB 外设时钟使能寄存器 (RCC_AHBENR) ........................................ 83
4.3.7 APB2 外设时钟使能寄存器(RCC_APB2ENR) ...................................... 84
4.3.8 APB1 外设时钟使能寄存器 (RCC_APB1ENR) .................................... 87
4.3.9 备份区域控制寄存器 (RCC_BDCR) ........................................................ 91
4.3.10 控制/状态寄存器 (RCC_CSR) .................................................................. 93
4.4 RCC寄存器映射 ......................................................................................................... 95
5 通用输入/输出和备用输入/输出(GPIO 和AFIO) .......................................................... 97
5.1 GPIO功能描述 ........................................................................................................... 97
5.1.1 通用输入/输出(GPIO) ................................................................................ 99
5.1.2 原子位置位或复位 .......................................................................................... 100
5.1.3 外部中断/唤醒线 ............................................................................................. 100
5.1.4 备用功能(AF) ............................................................................................. 100
5.1.5 输入/输出备用功能的软件重映射 ............................................................... 101
5.1.6 GPIO锁定机制 ................................................................................................. 101
UM0306 STM32F10X 使用参考设置
©2007 MXCHIP Corporation. All rights reserved.
www.mxchip.com
021-52655026/025
5.1.7 输入配置 ........................................................................................................... 101
5.1.8 输出配置 ........................................................................................................... 102
5.1.9 备用功能配置................................................................................................... 103
5.1.10 模拟输入配置................................................................................................... 104
5.2 GPIO寄存器描述 ..................................................................................................... 105
5.2.1 端口配置寄存器低位(GPIOx_CRL) (x=A..E) ................................. 105
5.2.2 端口配置寄存器高位 (GPIOx_CRH) (x=A..E) .............................. 106
5.2.3 端口输入数据寄存器 (GPIOx_IDR) (x=A..E) ............................... 108
5.2.4 端口输出数据寄存器 (GPIOx_ODR) (x=A..E) ............................. 108
5.2.5 端口位置位/复位寄存器 (GPIOx_BSRR) (x=A..E) ...................... 109
5.2.6 端口位复位寄存器 (GPIOx_BRR) (x=A..E) ................................... 110
5.2.7 端口配置锁定寄存器 (GPIOx_LCKR) (x=A..E) ............................ 110
5.3 备用功能输入/输出和调试配置 (AFIO) ........................................................ 112
5.3.1 使用OSC_IN/OSC_OUT引脚作为GPIO 端口 PD0/PD1 ..................... 112
5.3.2 BXCAN 备用功能重映射 .............................................................................. 112
5.3.3 JTAG/SWD 备用功能重映射 ....................................................................... 113
5.3.4 定时器备用功能重映射 .................................................................................. 114
5.3.5 USART 备用功能重映射 ............................................................................... 115
5.3.6 I2C 1 备用功能重映射 ................................................................................... 116
5.3.7 SPI 1 备用功能重映射 .................................................................................. 116
5.4 AFIO寄存器描述 ..................................................................................................... 117
5.4.1 AF 重映射和调试I/O配置寄存器(AFIO_MAPR) ................................ 118