ALIENTEK 探索者 STM32F407 开发板教程
II
STM32F4 开发指南(寄存器版)
内容简介 ........................................................................................................................ I
前言 ................................................................................................................................ 2
第一篇 硬件篇 .............................................................................................................. 4
第一章 实验平台简介 .................................................................................................. 5
1.1 ALIENTEK 探索者 STM32F4 开发板资源初探 ................................................ 5
1.2 ALIENTEK 探索者 STM32F4 开发板资源说明 ................................................ 7
1.2.1 硬件资源说明 .................................................................................................... 7
1.2.2 软件资源说明 .................................................................................................. 12
第二章 实验平台硬件资源详解 ................................................................................ 14
2.1 开发板原理图详解 ............................................................................................ 14
2.1.1 MCU ................................................................................................................. 14
2.1.2 引出 IO 口 ....................................................................................................... 15
2.1.3 USB 串口/串口 1 选择接口 ............................................................................ 16
2.1.4 JTAG/SWD ....................................................................................................... 17
2.1.5 SRAM ............................................................................................................... 17
2.1.6 LCD 模块接口 ................................................................................................. 18
2.1.7 复位电路 ......................................................................................................... 19
2.1.8 启动模式设置接口 ......................................................................................... 19
2.1.9 RS232 串口 ...................................................................................................... 19
2.1.10 RS485 接口 .................................................................................................... 20
2.1.11 CAN/USB 接口 .............................................................................................. 21
2.1.12 EEPROM ........................................................................................................ 21
2.1.13 光敏传感器 ................................................................................................... 22
2.1.14 SPI FLASH ..................................................................................................... 22
2.1.15 六轴加速度传感器 ....................................................................................... 23
2.1.16 温湿度传感器接口 ....................................................................................... 23
2.1.17 红外接收头 ................................................................................................... 24
2.1.18 无线模块接口 ............................................................................................... 24
2.1.19 LED ................................................................................................................ 24
2.1.20 按键 ............................................................................................................... 25
2.1.21 TPAD 电容触摸按键 ..................................................................................... 25
2.1.22 OLED/摄像头模块接口 ................................................................................ 26
2.1.23 有源蜂鸣器 ................................................................................................... 26
ALIENTEK 探索者 STM32F407 开发板教程
III
STM32F4 开发指南(寄存器版)
2.1.24 SD 卡接口 ...................................................................................................... 27
2.1.25 ATK 模块接口 ................................................................................................ 27
2.1.26 多功能端口 ................................................................................................... 28
2.1.27 以太网接口(RJ45) ................................................................................... 29
2.1.28 I2S 音频编解码器 .......................................................................................... 30
2.1.29 电源 ............................................................................................................... 30
2.1.30 电源输入输出接口 ....................................................................................... 31
2.1.31 USB 串口 ....................................................................................................... 32
2.2 开发板使用注意事项 ......................................................................................... 32
2.3 STM32F4 学习方法 ............................................................................................ 33
第二篇 软件篇 ............................................................................................................ 35
第三章 MDK5 软件入门 ............................................................................................ 36
3.1 MDK5 简介 ......................................................................................................... 36
3.2 新建 MDK5 工程 ............................................................................................... 37
3.3 MDK5 使用技巧 ................................................................................................. 51
3.3.1 文本美化 ......................................................................................................... 51
3.3.2 语法检测&代码提示 ...................................................................................... 53
3.3.3 代码编辑技巧 ................................................................................................. 55
3.3.4 其他小技巧 ..................................................................................................... 59
第四章 下载与调试 .................................................................................................... 62
4.1 STM32F4 程序下载 ............................................................................................ 62
4.2 STM32F4 在线调试 ............................................................................................ 68
第五章 SYSTEM 文件夹介绍 ................................................................................... 76
5.1 delay 文件夹代码介绍 ....................................................................................... 76
5.1.1 delay_init 函数 ................................................................................................. 77
5.1.2 delay_us 函数 ................................................................................................... 78
5.1.3 delay_xms 函数 ................................................................................................ 80
5.1.4 delay_ms 函数 .................................................................................................. 80
5.2 sys 文件夹代码介绍 ........................................................................................... 81
5.2.1 IO 口的位操作实现 ......................................................................................... 82
5.2.2 时钟配置函数 ................................................................................................. 84
5.2.3 Sys_Soft_Reset 函数 ........................................................................................ 89
5.2.4 Sys_Standby 函数 ............................................................................................ 90
ALIENTEK 探索者 STM32F407 开发板教程
IV
STM32F4 开发指南(寄存器版)
5.2.5 IO 设置函数 ..................................................................................................... 92
5.2.6 中断管理函数 ................................................................................................. 99
5.3 usart 文件夹介绍 .............................................................................................. 104
5.3.1 USART1_IRQHandler 函数........................................................................... 105
5.3.2 uart_init 函数 .................................................................................................. 106
第三篇 实战篇 .......................................................................................................... 109
第六章 跑马灯实验 .................................................................................................. 110
6.1 STM32F4 IO 简介 ............................................................................................. 111
6.2 硬件设计 ........................................................................................................... 111
6.3 软件设计 ........................................................................................................... 111
6.4 下载验证 .......................................................................................................... 115
第七章 蜂鸣器实验 .................................................................................................. 117
7.1 蜂鸣器简介 ...................................................................................................... 118
7.2 硬件设计 .......................................................................................................... 118
7.3 软件设计 .......................................................................................................... 119
7.4 下载验证 .......................................................................................................... 121
第八章 按键输入实验 .............................................................................................. 122
8.1 STM32F4 IO 口简介 ........................................................................................ 123
8.2 硬件设计 .......................................................................................................... 123
8.3 软件设计 .......................................................................................................... 123
8.4 下载验证 ........................................................................................................... 128
第九章 串口通信实验 .............................................................................................. 129
9.1 STM32F4 串口简介 .......................................................................................... 130
9.2 硬件设计 .......................................................................................................... 131
9.3 软件设计 .......................................................................................................... 132
9.4 下载验证 .......................................................................................................... 134
第十章 外部中断实验 .............................................................................................. 136
10.1 STM32F4 外部中断简介 ................................................................................ 137
10.2 硬件设计 ........................................................................................................ 137
10.3 软件设计 ........................................................................................................ 137
10.4 下载验证 ........................................................................................................ 140
第十一章 独立看门狗(IWDG)实验 ................................................................... 142
ALIENTEK 探索者 STM32F407 开发板教程
V
STM32F4 开发指南(寄存器版)
11.1 STM32F4 独立看门狗简介 ............................................................................ 143
11.2 硬件设计 ........................................................................................................ 144
11.3 软件设计 ........................................................................................................ 145
11.4 下载验证 ........................................................................................................ 146
第十二章 窗口门狗(WWDG)实验 ..................................................................... 147
12.1 STM32F4 窗口看门狗简介 ............................................................................ 148
12.2 硬件设计 ........................................................................................................ 150
12.3 软件设计 ........................................................................................................ 150
12.4 下载验证 ........................................................................................................ 152
第十三章 定时器中断实验 ...................................................................................... 153
13.1 STM32F4 通用定时器简介 ............................................................................ 154
13.2 硬件设计 ........................................................................................................ 157
13.3 软件设计 ........................................................................................................ 157
13.4 下载验证 ........................................................................................................ 158
第十四章 PWM 输出实验 ........................................................................................ 159
14.1 PWM 简介 ....................................................................................................... 160
14.2 硬件设计 ........................................................................................................ 162
14.3 软件设计 ........................................................................................................ 162
14.4 下载验证 ........................................................................................................ 164
第十五章 输入捕获实验 .......................................................................................... 165
15.1 输入捕获简介 ................................................................................................ 166
15.2 硬件设计 ........................................................................................................ 169
15.3 软件设计 ........................................................................................................ 169
15.4 下载验证 ........................................................................................................ 173
第十六章 电容触摸按键实验 .................................................................................. 174
16.1 电容触摸按键简介 ........................................................................................ 175
16.2 硬件设计 ........................................................................................................ 176
16.3 软件设计 ........................................................................................................ 176
16.4 下载验证 ........................................................................................................ 181
第十七章 OLED 显示实验 ...................................................................................... 182
17.1 OLED 简介 ..................................................................................................... 183
17.2 硬件设计 ........................................................................................................ 189
17.3 软件设计 ........................................................................................................ 189