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

2019-07-21 04:18发布


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

*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:Keil_v5ARMARMCCBin'
Build target 'Target_LED'
assembling startup_stm32f10x_hd.s...
compiling core_cm3.c...
compiling misc.c...
..USERstm32f10x.h(428): 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;
..STM32F10x_FWLibsrcmisc.c: 1 warning, 1 error
compiling led.c...
..USERstm32f10x.h(428): 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;
..HARDWARELEDled.c(20): warning:  #1-D: last line of file ends without a newline

..HARDWARELEDled.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...
..USERstm32f10x.h(428): 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;
..SYSTEMsyssys.c: 1 warning, 1 error
compiling stm32f10x_usart.c...
..USERstm32f10x.h(428): 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;
..STM32F10x_FWLibsrcstm32f10x_usart.c: 1 warning, 1 error
compiling usart.c...
..USERstm32f10x.h(428): 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;
..SYSTEMusartusart.c(48): warning:  #260-D: explicit type is missing ("int" assumed)
  _sys_exit(int x)
..SYSTEMusartusart.c: 2 warnings, 1 error
compiling delay.c...
..USERstm32f10x.h(428): 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;
..SYSTEMdelaydelay.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...
..USERstm32f10x.h(428): 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;
..STM32F10x_FWLibsrcstm32f10x_rcc.c: 1 warning, 1 error
compiling stm32f10x_gpio.c...
..USERstm32f10x.h(428): 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;
..STM32F10x_FWLibsrcstm32f10x_gpio.c: 1 warning, 1 error
"..OBJPro_LED.axf" - 10 Error(s), 12 Warning(s).
Target not created.
Build Time Elapsed:  00:00:01

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
5条回答
约翰一世
2019-07-21 14:49
1208 发表于 2019-3-16 17:53
参考这个看下http://www.openedv.com/forum.php?mod=viewthread&tid=289461

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

首先搜报错提示,搜到这个帖子:
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.
  */

一周热门 更多>