keil报错Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file

最近一次在使用keil时发现有一个报错是

Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file

keil报错Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file_第1张图片
查看了stm32f1xx.h头文件报错的地方,发现是没有定义具体的设备,解决方法如下:

  1. 在报错的头文件里面找到一段如下的定义代码,然后找到自己型号对应的定义并复制,例如我这里是STM32F103xB
    keil报错Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file_第2张图片
  2. 打开魔法棒→C/C++→define,添加信息:
    STM32F103xB,USE_STDPERIPH_DRIVER
    其中第一个文本就是要改成我们第一步查到的定义
    keil报错Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file_第3张图片
  3. 点击OK保持,然后运行一下就成功了

我这例子是报错出现在stm32f1xx.h头文件的,其他的头文件也可能会有类似的报错,解决方法同理。

你可能感兴趣的:(keil报错Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)