饥荒怎么把牛圈起来:从零开始在MDK中建立基于STM32F10x_StdPeriph_Driver V3.3.0的STM32工程

来源:百度文库 编辑:偶看新闻 时间:2024/04/28 06:08:24

1.首先建立工程目录,假设为STM32_STDPeriph_Lib Template

2.在该目录下建立MDK-Proj子目录,用来存放MDK工程以及编译生成的文件和调试信息

3.在MDK-Proj目录下建立2个子目录:output和listing

4.将从ST官网下载的STM32F10x_StdPeriph_Driver V3.3.0压缩中的Libraries解压缩到STM32_STDPeriph_Lib Template目录下

5.如果要用到DSP库,请安装DSP库后将安装目录下Libraries目录下的STM32F10x_DSP_Lib文件夹复制到STM32_STDPeriph_Lib Template\Libraries\

这个时候的目录结构如下:

--STM32_STDPeriph_Lib Template

   | --MDK-Proj

   |--Libraries

       |--CMSIS

       |--STM32F10x_StdPeriph_Driver

       |--STM32F10x_DSP_Lib

6.打开MDK,选择菜单“Project”->"New μVision Project",将工程名设置为"FFT"保存工程到,STM32_STDPeriph_Lib Template\MDK-Proj目录下,根据实际情况选择对应的CPU型号,我这里选择STM32F107VC。

在弹出窗体"Copy STM32 Startup Code to Project Folder and Add File to Poject"中选择"否"

7.右键单击工程名称,打开"Manage Components"窗体,或点击工具栏上的品字图标。

将Project Targets下的"Target 1"改名为"STM32_FFT"

清空"Groups"下项目,并新建"StdPeriph_Driver","RVMDK","DSP","CMSIS","App"条目

点击"确定",关闭窗体

8.为""RVMDK"文件夹添加文件,对"RVMDK"单击右键,选择"Add Files to Group"RVMDK""

将STM32_STDPeriph_Lib Template\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\startup\arm目录下的所有.s文件添加到RVMDK组下面

根据CPU类型,选择合适的启动文件。

例如对于STM32F107VC选择startup_stm32f10x_cl.s文件。

其他的.s文件,逐一对其点右键,选择"Options for File xxxx",在""Properties"选项卡下取消"Include in Target Build"前的勾选。

 

9.为CMSIS添加下面的文件:

STM32_STDPeriph_Lib Template\Libraries\CMSIS\CM3\CoreSupport\core_cm3.c

STM32_STDPeriph_Lib Template\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\system_stm32f10x.c

10.为"StdPeriph_Driver"添加下面的文件:

STM32_STDPeriph_Lib Template\Libraries\STM32F10x_StdPeriph_Driver\src\misc.c

STM32_STDPeriph_Lib Template\Libraries\STM32F10x_StdPeriph_Driver\stm32f10x_gpio.c

STM32_STDPeriph_Lib Template\Libraries\STM32F10x_StdPeriph_Driver\stm32f10x_flash.c

STM32_STDPeriph_Lib Template\Libraries\STM32F10x_StdPeriph_Driver\stm32f10x_rcc.c

根据自己工程要用到的功能,添加其他驱动文件

11.为DSP添加下面的文件:

STM32_STDPeriph_Lib Template\Libraries\STM32F10x_DSP_Lib\src\asm\arm\cr4_fft_64_stm32.s

STM32_STDPeriph_Lib Template\Libraries\STM32F10x_DSP_Lib\src\asm\arm\cr4_fft_256_stm32.s

STM32_STDPeriph_Lib Template\Libraries\STM32F10x_DSP_Lib\src\asm\arm\cr4_fft_1024_stm32.s

12.新建main.c文件,该文件存入STM32_STDPeriph_Lib Template目录,并添加该文件到工程的"App"组

13.从StdPeriph_Drvier库的例子中拷贝以下文件到STM32_STDPeriph_Lib Template目录:

"stm32f10x_it.c"

"stm32f10x_it.h"

"stm32f10x_conf.h"

将stm32f10x_it.c添加到工程的"App"组中

 

14.打开工程属性窗口,或点击工具栏上的魔术棒图标

1)在output选项卡下Select Folder for Objects按钮,设置output目录为:MDK-Proj\output

2)在listing选项卡下select Folder for Listings按钮,设置listings目录为:MDK-Proj\listing

3)在C/C++选项卡下设置预处理符号  "USE_STDPERIPH_DRIVER,STM32F10X_CL"

STM32F10X_CL 这个符号需要根据CPU类型选择。

在Include Paths下设置:

..\;

..\Libraries\CMSIS\CM3\CoreSupport;

..\Libraries\CMSIS\CM3DeviceSupport\ST\STM32F10x;

..\Libraries\STM32F10x_StdPeriph_Driver\inc;

..\Libraries\STM32F10x_DSP_Lib\inc

 

4)在Debug选项卡下选择编程器件

5)在Utilities选项卡下选择编程器件,添加FLASH Download 算法

15. 编写应用程序,在stm32f10x_conf.h中注释掉没有用到的硬件对应的.h头文件