您的位置:首页 > 其它

[STM32系列贴-初级]之STM32F10X工程建立详细过程及问题解决

2016-10-25 21:56 986 查看
2015-03-15 浏览(86)

[摘要:解释:工程情况为Keil uVision5 ARM MDK; uvision4似乎木有那类题目; 芯片版本STM32F103C8;F10X系列 简略的进程没有再细细解释,只是解释一些症结步调取题目办理举措; [此帖用于低级,往后没有]

说明:工程环境为Keil uVision5 ARM MDK; uvision4好像木有这类问题;

芯片版本STM32F103C8;F10X系列

简单的过程不再细细说明,只是说明一些关键步骤与问题解决办法;


[此帖用于初级,今后不在写此类帖子,写这类帖子原因在于修正一些网上流行的所谓正确的解决方法,以后会主要出算法的源码`(∩_∩)′]

0.建立project与工程文件下的子文件归类(参考原子教你玩STM32书(北航出版))

a.在工程文件下,需要建立以下几个文件(这些文件夹名称自己去命名,至于那些具体文件自己去找哈,最新库函数版本vision v.3.5):

b.放置CPU启动文件与CM3内核外访问层的文件夹core;

c.放置编译后输出用于仿真下载的文件夹obj;

d.放置官方head文件、source文件、重要的main函数文件的文件夹STM32_LIB;

e.放置自己写的c文件、stm32头文件、system源文件的用户文件夹user;

\

f.new一个project,利用packinstaller安装STM32F10x系列芯片驱动之后,选择相应的芯片型号,保存到user文件夹下;

1.之后右键工程文件夹,如图,manage project Items…

\

\

如图添加每个GROUP的文件夹内的文件,这些文件都是c文件,没有head文件。

特殊说明:user内所有的c文件,stm32_lib内的所有文件,core内的一个c文件与启动文件;

\

\

下面说明启动文件的选取:

对于 103 系列,主要是用其中 3 个启动文件:

startup_stm32f10x_ld.s: 适用于小容量 产品

startup_stm32f10x_md.s : 适用于中等容量产品

startup_stm32f10x_hd.s: 适用于大容量产品

这里的容量是指 FLASH 的大小.判断方法如下:

小容量:16K <= FLASH <= 32K

中容量:64K <= FLASH <= 128K

大容量:256K <= FLASH <= 512K

2.建立完成后,点击魔术棒,如图:\

对于output内的文件夹,选择刚刚建立的obj文件夹,同时把生成hex文件勾上;

\

对于C/C++选项卡,要两处操作

\

首先说明最下面那个:

这个把刚刚建立的文件夹内的所有head文件关联起来,具体有如图:

\

\

到这一步的时候,编译一次,只会出现一类错误(前提是也把STM32F10X_HD也声明成了preprocessor symbol),就是如下面的error,我把所有的报错信息粘贴在下面:

Build target ‘TEST’

compiling main.c…

stm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

main.c: 1 warning, 1 error

compiling stm32f10x_it.c…

stm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

stm32f10x_it.c: 1 warning, 1 error

compiling system_stm32f10x.c…

stm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

stm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

system_stm32f10x.c: 1 warning, 1 error

compiling misc.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcmisc.c: 1 warning, 1 error

compiling stm32f10x_adc.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_adc.c: 1 warning, 1 error

compiling stm32f10x_bkp.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_bkp.c: 1 warning, 1 error

compiling stm32f10x_can.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_can.c: 1 warning, 1 error

compiling stm32f10x_cec.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_cec.c: 1 warning, 1 error

compiling stm32f10x_crc.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_crc.c: 1 warning, 1 error

compiling stm32f10x_dac.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_dac.c: 1 warning, 1 error

compiling stm32f10x_dbgmcu.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_dbgmcu.c: 1 warning, 1 error

compiling stm32f10x_dma.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_dma.c: 1 warning, 1 error

compiling stm32f10x_exti.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_exti.c: 1 warning, 1 error

compiling stm32f10x_flash.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn
4000
_Type;

..STM32_LIBsrcstm32f10x_flash.c: 1 warning, 1 error

compiling stm32f10x_fsmc.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_fsmc.c: 1 warning, 1 error

compiling stm32f10x_gpio.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_gpio.c: 1 warning, 1 error

compiling stm32f10x_i2c.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_i2c.c: 1 warning, 1 error

compiling stm32f10x_iwdg.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_iwdg.c: 1 warning, 1 error

compiling stm32f10x_pwr.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_pwr.c: 1 warning, 1 error

compiling stm32f10x_rcc.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_rcc.c: 1 warning, 1 error

compiling stm32f10x_rtc.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_rtc.c: 1 warning, 1 error

compiling stm32f10x_sdio.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_sdio.c: 1 warning, 1 error

compiling stm32f10x_spi.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_spi.c: 1 warning, 1 error

compiling stm32f10x_tim.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_tim.c: 1 warning, 1 error

compiling stm32f10x_usart.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_usart.c: 1 warning, 1 error

compiling stm32f10x_wwdg.c…

..USERstm32f10x.h(298): error: #67: expected a “}”

ADC1_2_IRQn = 18, /!< ADC1 and ADC2 global Interrupt /

..USERstm32f10x.h(472): warning: #12-D: parsing restarts here after previous syntax error

} IRQn_Type;

..STM32_LIBsrcstm32f10x_wwdg.c: 1 warning, 1 error

compiling core_cm3.c…

assembling startup_stm32f10x_hd.s…

“..OBJTEST.axf” - 26 Error(s), 26 Warning(s).

Target not created

3.下面具体介绍一下,为什么报错:

随便点击一个error,就会出现位置,如图:

\

\

STM32F10X_HD下的第一行入口就有错误,然后会百度,上面都说的问题是

直接用uvision5的packinstaller将STM32F10X_DFP删掉1.0.2的版本,就会编译通过,仔细想想能是这样吗?!这不是解决方法!

理由1:从STM官方角度,从1.0.0版本一直升级到1.0.2版本,向下的兼容性会照顾得很好,而且不可能将F10X的驱动,老版本没问题,新版本update的有问题,F10X系列有F4X的优势,比如说USB方面的性能,F10X就比F4X好用,官方自己的下载器USB都用F10X做的,而没用太高级的主芯片。

理由2:从keil官方角度,看一下官方的信息,如图:这个是官方对uvision5的支持

\

理由3:若是把pack删掉,下次建立新项目怎么办,没有了F10X选择,而且仿真下载模型选择怎么办,也没有了,所以这个方法是暂时的;

\

如图,这是在选定芯片类型之后,打开details之后看到的硬件支持:

\

\

均是1.0.2版本

正确的解决方法:

在C/C++选项卡里,把STM3210X_HD从prepocessor symbol define 里面删掉`(∩_∩)′

\

这么做的原因:在老版本的官方STM32F10X.H文件里,这句话不是这么写的,若没记错的话,是

…&&!defined(STM32F10X_HD) && …

原来是有括号的,不做标识符来处理,而新版的,如图,直接说明了出来,那就没有必要,可以根据C/C++知识自己去推断;

另外,说明一下,一个标准的STM32的架构,这个帖子说明的是不全面的,以后有时间再出帖子具体说明,可以去参考STM32官方的例程模板架构;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  stm32
相关文章推荐