OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2467|回复: 5

f103上编译正常的程序换到f107设备,编译报错?

[复制链接]

10

主题

28

帖子

0

精华

初级会员

Rank: 2

积分
143
金钱
143
注册时间
2019-1-16
在线时间
24 小时
发表于 2019-3-16 17:42:17 | 显示全部楼层 |阅读模式
1金钱

小白请问,一个选定型号f103上编译正常的程序,换成别的板子需要改动那些地方呢?
比如,我的一个简单led灯实验,换成f107型号,就报下面的错,同样flash256k。
请大家指点!谢谢

*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Build target 'Target_LED'
assembling startup_stm32f10x_hd.s...
compiling core_cm3.c...
compiling misc.c...
..\USER\stm32f10x.h(428): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\USER\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\STM32F10x_FWLib\src\misc.c: 1 warning, 1 error
compiling led.c...
..\USER\stm32f10x.h(428): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\USER\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\HARDWARE\LED\led.c(20): warning:  #1-D: last line of file ends without a newline

..\HARDWARE\LED\led.c: 2 warnings, 1 error
compiling stm32f10x_it.c...
stm32f10x.h(428): 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 sys.c...
..\USER\stm32f10x.h(428): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\USER\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\SYSTEM\sys\sys.c: 1 warning, 1 error
compiling stm32f10x_usart.c...
..\USER\stm32f10x.h(428): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\USER\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\STM32F10x_FWLib\src\stm32f10x_usart.c: 1 warning, 1 error
compiling usart.c...
..\USER\stm32f10x.h(428): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\USER\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\SYSTEM\usart\usart.c(48): warning:  #260-D: explicit type is missing ("int" assumed)
  _sys_exit(int x)
..\SYSTEM\usart\usart.c: 2 warnings, 1 error
compiling delay.c...
..\USER\stm32f10x.h(428): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\USER\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\SYSTEM\delay\delay.c: 1 warning, 1 error
compiling system_stm32f10x.c...
stm32f10x.h(428): 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 stm32f10x_rcc.c...
..\USER\stm32f10x.h(428): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\USER\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\STM32F10x_FWLib\src\stm32f10x_rcc.c: 1 warning, 1 error
compiling stm32f10x_gpio.c...
..\USER\stm32f10x.h(428): error:  #67: expected a "}"
    ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */
..\USER\stm32f10x.h(472): warning:  #12-D: parsing restarts here after previous syntax error
  } IRQn_Type;
..\STM32F10x_FWLib\src\stm32f10x_gpio.c: 1 warning, 1 error
"..\OBJ\Pro_LED.axf" - 10 Error(s), 12 Warning(s).
Target not created.
Build Time Elapsed:  00:00:01

最佳答案

查看完整内容[请看2#楼]

参考这个看下http://www.openedv.com/forum.php?mod=viewthread&tid=289461
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

57

主题

1680

帖子

3

精华

资深版主

Rank: 8Rank: 8

积分
4307
金钱
4307
注册时间
2018-6-30
在线时间
808 小时
发表于 2019-3-16 17:42:18 | 显示全部楼层
业精于勤荒于嬉;行成于思毁于随!
回复

使用道具 举报

10

主题

28

帖子

0

精华

初级会员

Rank: 2

积分
143
金钱
143
注册时间
2019-1-16
在线时间
24 小时
 楼主| 发表于 2019-3-16 18:23:10 | 显示全部楼层
1208 发表于 2019-3-16 17:53
参考这个看下http://www.openedv.com/forum.php?mod=viewthread&tid=289461

亲,参考了。
只需要把device改为Stm32f107rc、flash算法改一下 两个地方,但还是报错呢
回复

使用道具 举报

10

主题

28

帖子

0

精华

初级会员

Rank: 2

积分
143
金钱
143
注册时间
2019-1-16
在线时间
24 小时
 楼主| 发表于 2019-3-16 18:51:14 | 显示全部楼层

大概是解决了!预定义的问题。

首先搜报错提示,搜到这个帖子:
https://blog.csdn.net/tianshaolin12/article/details/51692962
意识到是预定义的问题。


然后,测试了一下编译:去掉预定义,f107rc和f103rc,都编译通过,0 Error。但是是否烧录后运行有影响?还没实际测试。


最后,搜索一下预定义名称,在stm32f10x.h文件中发现如下注释描述,看来f107级联型设备要写预定义的话得加STM32F10X_CL 才对。

#if !defined (STM32F10X_LD) && !defined (STM32F10X_LD_VL) && !defined (STM32F10X_MD) && !defined (STM32F10X_MD_VL) && !defined (STM32F10X_HD) && !defined (STM32F10X_HD_VL) && !defined (STM32F10X_XL) && !defined (STM32F10X_CL)
  /* #define STM32F10X_LD */     /*!< STM32F10X_LD: STM32 Low density devices */
  /* #define STM32F10X_LD_VL */  /*!< STM32F10X_LD_VL: STM32 Low density Value Line devices */  
  /* #define STM32F10X_MD */     /*!< STM32F10X_MD: STM32 Medium density devices */
  /* #define STM32F10X_MD_VL */  /*!< STM32F10X_MD_VL: STM32 Medium density Value Line devices */  
  /* #define STM32F10X_HD */     /*!< STM32F10X_HD: STM32 High density devices */
  /* #define STM32F10X_HD_VL */  /*!< STM32F10X_HD_VL: STM32 High density value line devices */  
  /* #define STM32F10X_XL */     /*!< STM32F10X_XL: STM32 XL-density devices */
  /* #define STM32F10X_CL */     /*!< STM32F10X_CL: STM32 Connectivity line devices */
#endif
/*  Tip: To avoid modifying this file each time you need to switch between these
        devices, you can define the device in your toolchain compiler preprocessor.

- Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
   where the Flash memory density ranges between 16 and 32 Kbytes.
- Low-density value line devices are STM32F100xx microcontrollers where the Flash
   memory density ranges between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx microcontrollers
   where the Flash memory density ranges between 64 and 128 Kbytes.
- Medium-density value line devices are STM32F100xx microcontrollers where the
   Flash memory density ranges between 64 and 128 Kbytes.   
- High-density devices are STM32F101xx and STM32F103xx microcontrollers where
   the Flash memory density ranges between 256 and 512 Kbytes.
- High-density value line devices are STM32F100xx microcontrollers where the
   Flash memory density ranges between 256 and 512 Kbytes.   
- XL-density devices are STM32F101xx and STM32F103xx microcontrollers where
   the Flash memory density ranges between 512 and 1024 Kbytes.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
  */

回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2019-3-17 02:32:19 | 显示全部楼层
学会移植代码先
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

10

主题

28

帖子

0

精华

初级会员

Rank: 2

积分
143
金钱
143
注册时间
2019-1-16
在线时间
24 小时
 楼主| 发表于 2019-3-17 22:19:05 | 显示全部楼层

嗯嗯!好的原子哥
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-24 00:32

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表