正点原子的STM32F103ZET6最小系统板,开发环境为 (Keil) MDK 5.31
入门第一步,新建工程模版。
按照B站教程和正点原子的开发指南中给出的操作步骤,逐步操作。最后,应当如教程所示出现“0 Error(s), 0 Warning(s)”的编译结果,但
是我的编译依然报错
../CORE/core_cm3.c(445): error: non-ASM statement in naked function is not supported
uint32_t result=0;
^
../CORE/core_cm3.c(442): note: attribute is here
uint32_t __get_PSP(void) __attribute__( ( naked ) );
^
../CORE/core_cm3.c(465): error: parameter references not allowed in naked functions
"BX lr \n\t" : : "r" (topOfProcStack) );
^
../CORE/core_cm3.c(461): note: attribute is here
void __set_PSP(uint32_t topOfProcStack) __attribute__( ( naked ) );
^
../CORE/core_cm3.c(479): error: non-ASM statement in naked function is not supported
uint32_t result=0;
^
../CORE/core_cm3.c(476): note: attribute is here
uint32_t __get_MSP(void) __attribute__( ( naked ) );
^
../CORE/core_cm3.c(499): error: parameter references not allowed in naked functions
"BX lr \n\t" : : "r" (topOfMainStack) );
^
../CORE/core_cm3.c(495): note: attribute is here
void __set_MSP(uint32_t topOfMainStack) __attribute__( ( naked ) );
^
4 errors generated.
Error 集中在 core_cm3.c 这一文件上,而该文件是从正点原子提供的官方固件库包 STM32F10x_StdPeriph_Lib_V3.5.0 中复制来的,应该不会有问题。
检查 Options for Target窗口的选项
发现 C/C++这一选项卡和样例中明显不同,不应该有(AC6)的标识,该选项卡下的内容也有些不同。
仔细检查后发现,Target选项卡下的设置与样例有出入,晶振频率为12 MHz,Arm Compiler为 use default arm compiler version 6,而样例中的 Xtal 为 8 MHz,Arm compiler 为 use default arm compiler version 5
这里需要按照样例模版工程中的设置,将 ARM Compiler改为 Use default arm compiler version 5,即可解决报错问题
"..\OBJ\template.axf" - 0 Error(s), 0 Warning(s).