Keil5 STM32f10x_MD 在Preprosessor Symbols 可以不写

文章讲述了在使用STM32F103C8T6微控制器时,基于Keil4和Keil5编译器,预处理符号USE_STDPERIPH_DRIVER和STM32f10x_MD的写法变化。在MDK-RTE环境下,stm32f10x.h头文件会自动生成USE_STDPERIPH_DRIVER定义,而在非RTE环境下,则需要手动在预处理器中添加USE_STDPERIPH_DRIVER。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  如果使用STM32f103C8T6,在用keil编译时,不同的软件版本,在预处理符上写法不同。在keil4中preprocessor symbols需要写USE_STDPERIPH_DRIVER,STM32f10x_MD,如果不写就会报错。在keil5中,不写STM32f10x_MD,也是可以编译成功。

   如果用MDK RTE环境生成库函数,stm32f10x.h会多下面的几行代码,且会生成一个RTE Component.h文件,通过下面的代码,会自定义 USE_STDPERIPH_DRIVER,这样在preprocessor symbols中USE_STDPERIPH_DRIVER也不用写。

  如果不是用MDK RTE环境加外设,在preprocessor symbols中USE_STDPERIPH_DRIVER还是要写的。

#if !defined  USE_STDPERIPH_DRIVER

  #ifdef _RTE_

    #include "RTE_Components.h"

    #ifdef RTE_DEVICE_STDPERIPH_FRAMEWORK

      #define USE_STDPERIPH_DRIVER

    #endif

  #endif

#endif

又出现了这个错误*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin' Rebuild target 'Target 1' assembling startup_stm32f10x_md.s... compiling core_cm3.c... compiling misc.c... compiling stm32f10x_bkp.c... compiling system_stm32f10x.c... compiling stm32f10x_adc.c... compiling stm32f10x_it.c... compiling main.c... User\main.c(270): warning: #223-D: function "RTC_WriteProtectionCmd" declared implicitly RTC_WriteProtectionCmd(DISABLE); User\main.c(498): warning: #223-D: function "sprintf" declared implicitly sprintf(buf, "Time: %02d:%02d:%02d", hour, min, sec); User\main.c: 2 warnings, 0 errors compiling stm32f10x_can.c... compiling stm32f10x_cec.c... compiling stm32f10x_crc.c... compiling stm32f10x_dbgmcu.c... compiling stm32f10x_dma.c... compiling stm32f10x_dac.c... compiling stm32f10x_exti.c... compiling stm32f10x_flash.c... compiling stm32f10x_fsmc.c... compiling stm32f10x_iwdg.c... compiling stm32f10x_pwr.c... compiling stm32f10x_i2c.c... compiling stm32f10x_gpio.c... compiling stm32f10x_rcc.c... compiling stm32f10x_rtc.c... compiling stm32f10x_sdio.c... compiling stm32f10x_wwdg.c... compiling stm32f10x_spi.c... compiling stm32f10x_usart.c... compiling stm32f10x_tim.c... linking... .\Output\工程模板.axf: Error: L6218E: Undefined symbol RTC_WriteProtectionCmd (referred from main.o). Not enough information to list image symbols. Not enough information to list load addresses in the image map. Finished: 2 information, 0 warning and 1 error messages. ".\Output\工程模板.axf" - 1 Error(s), 2 Warning(s). Target not created. Build Time Elapsed: 00:00:01
06-26
Build started: Project: deepone *** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Program Files\MDK\Core\ARM\ARMCC\Bin' Build target 'Target 1' compiling main.c... D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\Device\Include\stm32f10x.h(8302): error: #5: cannot open source input file "stm32f10x_conf.h": No such file or directory #include "stm32f10x_conf.h" main.c: 0 warnings, 1 error compiling misc.c... D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\Device\Include\stm32f10x.h(8302): error: #5: cannot open source input file "stm32f10x_conf.h": No such file or directory #include "stm32f10x_conf.h" D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\Device\StdPeriph_Driver\src\misc.c: 0 warnings, 1 error compiling stm32f10x_gpio.c... D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\Device\Include\stm32f10x.h(8302): error: #5: cannot open source input file "stm32f10x_conf.h": No such file or directory #include "stm32f10x_conf.h" D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\Device\StdPeriph_Driver\src\stm32f10x_gpio.c: 0 warnings, 1 error compiling GPIO_STM32F10x.c... D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\Device\Include\stm32f10x.h(8302): error: #5: cannot open source input file "stm32f10x_conf.h": No such file or directory #include "stm32f10x_conf.h" D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\RTE_Driver\GPIO_STM32F10x.c: 0 warnings, 1 error compiling stm32f10x_rcc.c... D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\Device\Include\stm32f10x.h(8302): error: #5: cannot open source input file "stm32f10x_conf.h": No such file or directory #include "stm32f10x_conf.h" D:\Program Files\MDK\Pack\Keil\STM32F1xx_DFP\2.3.0\Device\StdPeriph_Driver\src\stm32f10x_rcc.c: 0 warnings, 1 error ".\Objects\deepone.axf" - 5 Error(s), 0 Warning(s). Target not created. Build Time Elapsed: 00:00:01
03-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值