diff --git a/README.md b/README.md index 5e5e862..a2b3ceb 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,5 @@ 7. 第6章:[串口通信](book/06:串口通信/01.md) 8. 第7章:[FreeRTOS](book/07:FreeRTOS/01.md) 9. 第8章:[补充内容](book/08:补充内容/01.md) +10. 常见问题:[常见问题](book/常见问题/01.md) diff --git a/book/常见问题/01.md b/book/常见问题/01.md new file mode 100644 index 0000000..19a1626 --- /dev/null +++ b/book/常见问题/01.md @@ -0,0 +1,55 @@ +[开发板常见问题](https://docs.baud-dance.com/docs/stm32/FAQ/) + +- [1. 下载不成功](#1-下载不成功) + - [1.1. 解决方案](#11-解决方案) + - [1.2. 为什么会出现这个问题](#12-为什么会出现这个问题) + - [1.3. 为什么以前没有出现这个问题?](#13-为什么以前没有出现这个问题) + - [1.4. 怎么避免这个问题?](#14-怎么避免这个问题) + + +# 1. 下载不成功 + +## 1.1. 解决方案 + +1. 将 SYS -> Debug 设为 Serial Wire,然后**保存并重新生成代码** + +![image-20241218094627910](./img/image-20241218094627910.png) + +2. **将 BOOT0 跳线帽改到 H** + +![image-20241218094748537](./img/image-20241218094748537.png) + +3. **按一下复位键** + +![image-20241218094803715](./img/image-20241218094803715.png) + +4. **现在就能下载程序了~** + +![image-20241218094819489](./img/image-20241218094819489.png) + +5. **将跳线帽换回 L,按复位键,程序就开始跑啦~** + +6. **避免下次再出现,后面再新建的工程,都按步骤1配置一下** + +## 1.2. 为什么会出现这个问题 + +- 当没有配置 Debug 接口为 Serial Wire 时,HAL库会认为**不需要下载接口** +- 因此在生成初始化代码时,可能出现这一行: + +```c +__HAL_AFIO_REMAP_SWJ_DISABLE(); // 关闭SWD、JTAG接口 +``` + + + +- 这行代码**关闭了芯片的 SWD 接口**,导致下载失败 + +## 1.3. 为什么以前没有出现这个问题? + +- 这行代码是跟着 **串口、I²C** 等初始化代码一起生成的 +- 以前的工程可能没有用到,所以并没有生成这行代码 +- 而当用到例如 串口、I²C 等功能时,HAL库需要初始化 AFIO 时,就会生成这行代码 + +## 1.4. 怎么避免这个问题? + +在每次新建工程后,就配置好 Debug 接口为 Serial Wire \ No newline at end of file diff --git a/book/常见问题/img/image-20241218094627910.png b/book/常见问题/img/image-20241218094627910.png new file mode 100644 index 0000000..224bf92 Binary files /dev/null and b/book/常见问题/img/image-20241218094627910.png differ diff --git a/book/常见问题/img/image-20241218094748537.png b/book/常见问题/img/image-20241218094748537.png new file mode 100644 index 0000000..9662453 Binary files /dev/null and b/book/常见问题/img/image-20241218094748537.png differ diff --git a/book/常见问题/img/image-20241218094803715.png b/book/常见问题/img/image-20241218094803715.png new file mode 100644 index 0000000..1b3d911 Binary files /dev/null and b/book/常见问题/img/image-20241218094803715.png differ diff --git a/book/常见问题/img/image-20241218094819489.png b/book/常见问题/img/image-20241218094819489.png new file mode 100644 index 0000000..deb0a74 Binary files /dev/null and b/book/常见问题/img/image-20241218094819489.png differ