目录
stm32其实还是上手比较容易的,现在先来说一下建立工程
1.下载固件库
进入 st官网STSW-STM32054 - STM32F10x标准外设库 - STMicroelectronics下载en.stsw-stm32054_v3-6-0_v3.6.0固件库
解压后得到STM32F10x_StdPeriph_Lib_V3.6.0文件
2、建立工程所需文件夹
桌面建立文件夹Template,在Template文件夹里面再建立四个子文件夹“Library”,“Output“,”Project“,”Source”
3、复制所需库文件
把刚刚解压的固件库STM32F10x_StdPeriph_Lib_V3.6.0中Libraries文件中的CMSIS和STM32F10x_StdPeriph_Driver文件复制出来放进去我们自己建立的Template工程的子文件夹Library中。
把刚刚解压的固件STM32F10x_StdPeriph_Lib_V3.6.0\Project\STM32F10x_StdPeriph_Template中的main.c stm32f10x_conf.h stm32f10x_it.c stm32f10x_it.h system_stm32f10x.c一共五个文件复制出来放进去我们自己建立的Template工程的子文件夹Source中。
在Template\Source中新建一个名称为Help的txt文件
4、新建工程
打开软件,选择Project -->New uVision Project
选择工程保存位置为刚刚建立的Template文件夹中的Project内,工程命名为MyProject,点击保存
我这边使用的主控芯片是stm32f103zet6,所以选择STM32F103ZE
5、建立Groups
在Groups中创建四个文件夹分别是 User CMISIS STM32F10x_StdPeriph_Lib_V3.6.0 Help
在User中添加 (点击Add Files)Template\Source中的main.c stm32f10x_conf.h stm32f10x_it.c stm32f10x_it.h system_stm32f10x.c一共五个文件
在CMISIS中添加 (点击Add Files)Template\Library\CMSIS\CM3\CoreSupport中的core_cm3.c文件。
在CMISIS中添加 (点击Add Files)Template\Library\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm中的startup_stm32f10x_hd.s文件。
在STM32F10x_StdPeriph_Lib_V3.6.0中添加 (点击Add Files)Template\Library\STM32F10x_StdPeriph_Driver\src中的
共计23个文件。
在Help中添加 (点击Add Files)Template\Source中的 Help.txt 文档
6、配置中间输出文件保存位置![](https://i-blog.csdnimg.cn/blog_migrate/51404c9d652f502011cca01b45ee1f77.png)
7、配置路径
同样方法把这五个路径都加上
8、编译
打开main.c
把多余的代码都删除,只留下
int main(void)
{
while (1)
{
}
}
点击编译
0错误 0警告,工程模板建立成功
9、删除多余文件
另外为了减小工程文件的大小,可以把一些没用的删除掉
9.1
Template\Library\CMSIS 中的三个文件 CMSIS changes.htm CMSIS debug support.htm License.doc
9.2
Template\Library\CMSIS\CM3\DeviceSupport\ST\STM32F10x中的 LICENSE.txt Release_Notes.html system_stm32f10x.c system_stm32f10x.h 4个文件
9.3
Template\Library\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup中的 gcc_ride7 iar TrueSTUDIO
9.4
Template\Library\CMSIS 中的Documentation
9.5
Template\Library\STM32F10x_StdPeriph_Driver 中的两个
9.6
删除Template\Project中的 DebugConfig Listings Objects 三个文件夹
以后当你的项目完成后交付时候可以直接删除Output文件夹中的这些中间文件,减少工程文件所占空间
至此大功告成
链接:https://pan.baidu.com/s/1us0kbK5BNjpha0NF2wr3og
提取码:only