跳转到主要内容

使用FlyMCU往STM32中烧写程序

cathy 提交于

<strong><font color="#004a85">1、软硬件环境</font> </strong>

<p>1)操作系统:Windows</p>
<p>2)软件:</p>
<ul>
<li>Keil</li>
<li>FlyMcu</li>
</ul>
<p>3)硬件:</p>
<ul>
<li>PC</li>
<li>STM32最小系统开发板</li>
<li>USB转TTL CH340G</li>
</ul>

<strong><font color="#004a85">2、生成hex文件</font> </strong>

编写好要烧写的程序后,点击菜单栏的【Flash】,选择【Config Flash Tools】。首先,在【Device】页面中选择设备类型,这里是STM32F103C8。

<center><img src="http://mcu.eetrend.com/files/2021-11/博客/100555247-226815-1.png&quot; alt=“使用FlyMCU往STM32中烧写程序"></center>

然后,切换到【Output】页面,勾选【Create HEX File】,最后点击【OK】。

<center><img src="http://mcu.eetrend.com/files/2021-11/博客/100555247-226816-2.png&quot; alt=“使用FlyMCU往STM32中烧写程序"></center>

回到Keil主界面,点击【Build】编译项目,部分输出如下:

<pre style="overflow-x:auto; background-color:#e9e9e9;">Build started: Project: encoder_test
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin'
Build target 'Encoder'
compiling stm32f10x_bkp.c...
..\Sys\stm32f10x.h(53): warning: #47-D: incompatible redefinition of macro "STM32F10X_MD"
#define STM32F10X_MD /* 处理器型号 stm32f103rb */
..\Lib\src\stm32f10x_bkp.c: 1 warning, 0 errors
...
linking...
Program Size: Code=9612 RO-data=336 RW-data=68 ZI-data=1636
FromELF: creating hex file...
".\output\encoder_test.axf" - 0 Error(s), 30 Warning(s).
Build Time Elapsed: 00:00:07</pre>

可以看到,没有报错,而且生成了hex文件,这正是我们需要的。

<strong><font color="#004a85">3、准备STM32最小系统开发板</font> </strong>

<strong>3.1、设置BOOT方式</strong>

STM32最小系统开发板如下图所示,这里只看【BOOT选择部分】,上面是BOOT 0,下面是BOOT 1,左侧是0,右侧是1。

有两种BOOT模式,一种为运行模式,另一种为烧写模式,设置方式为:

<ul>
<li>运行模式:BOOT 0为0,BOOT 1为0</li>
<li>烧写模式:BOOT 0为1,BOOT 1为0</li>
</ul>

因为这里要烧写程序,所以将BOOT 0设置为0,BOOT 1设置为0。

<center><img src="http://mcu.eetrend.com/files/2021-11/博客/100555247-226817-3.png&quot; alt=“使用FlyMCU往STM32中烧写程序"></center>

<strong>3.2、连接USB转TTL CH340G</strong>

USB转TTL CH340G示意图:

<center><img src="http://mcu.eetrend.com/files/2021-11/博客/100555247-226818-4.png&quot; alt=“使用FlyMCU往STM32中烧写程序"></center>

根据下图的接线方式,将USB转TTL CH340G与STM32最小系统开发板连接起来。

<center><img src="http://mcu.eetrend.com/files/2021-11/博客/100555247-226819-5.png&quot; alt=“使用FlyMCU往STM32中烧写程序"></center>

连接好后,将USB转TTL CH340G插入到PC的USB接口中。

<strong><font color="#004a85">4、使用FlyMCU往STM32中烧写程序</font> </strong>

<strong>4.1、搜索串口</strong>

正常情况下,软件会自动搜索到串口。

<strong>4.2、加载hex文件</strong>

加载之前生成的hex文件。

<strong>4.3、其他设置</strong>

勾选【校验】和【编程后执行】。

<strong>4.4、烧写</strong>

点击【开始编程】,烧写程序。

右侧窗口为输出信息,可以看出,烧写完成。

<center><img src="http://mcu.eetrend.com/files/2021-11/博客/100555247-226820-6.png&quot; alt=“使用FlyMCU往STM32中烧写程序"></center>

————————————————
版权声明:本文为CSDN博主「W_Tortoise」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/learning_tortosie/article/details/105156743