中文字符在Keil中导致的错误问题(错误代码:#7 #12-D #20 #223-D #247)

在写完串口chen程序bian编译时发现报错  27 Error(s), 13 Warning(s),主要错误还在main.c中,通过百度发现主要是 #7错误,错误提示如下:

 

*** Using Compiler 'V5.06 update 5 (build 528)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'Demo'
assembling startup_stm32f10x_hd.s...
compiling core_cm3.c...
compiling misc.c...
compiling stm32f10x_bkp.c...
compiling system_stm32f10x.c...
compiling stm32f10x_cec.c...
compiling stm32f10x_adc.c...
compiling stm32f10x_can.c...
compiling stm32f10x_crc.c...
compiling stm32f10x_dma.c...
compiling stm32f10x_dbgmcu.c...
compiling stm32f10x_dac.c...
compiling stm32f10x_flash.c...
compiling stm32f10x_exti.c...
compiling stm32f10x_fsmc.c...
compiling stm32f10x_gpio.c...
compiling stm32f10x_pwr.c...
compiling stm32f10x_iwdg.c...
compiling stm32f10x_rtc.c...
compiling stm32f10x_i2c.c...
compiling stm32f10x_rcc.c...
compiling stm32f10x_sdio.c...
compiling stm32f10x_spi.c...
compiling stm32f10x_wwdg.c...
compiling main.c...
..\..\User\usart\bsp_usart1.h(11): error:  #7: unrecognized token
  void Usart_SendByte( USART_TypeDef *pUSARTx, uint8_t ch);
..\..\User\usart\bsp_usart1.h(11): error:  #130: expected a "{"
  void Usart_SendByte( USART_TypeDef *pUSARTx, uint8_t ch);
..\..\User\usart\bsp_usart1.h(12): error:  #7: unrecognized token
  void Usart_SendString( USART_TypeDef *pUSARTx, char *str);
..\..\User\main.c(50): warning:  #12-D: parsing restarts here after previous syntax error
  { 
..\..\User\main.c(52): error:  #20: identifier "b" is undefined
      for(c=0;c ..\..\User\main.c(59): warning:  #223-D: function "SPI_SPI2_Config" declared implicitly
    SPI_SPI2_Config();
..\..\User\main.c(60): warning:  #223-D: function "MS_Config" declared implicitly
      MS_Config();
..\..\User\main.c(61): warning:  #223-D: function "EXTI_IO_Config" declared implicitly
      EXTI_IO_Config();
..\..\User\main.c(62): warning:  #223-D: function "TIM2_Configuration" declared implicitly
      TIM2_Configuration();
..\..\User\main.c(88): error:  #20: identifier "INCTCD_num" is undefined
      INCTCD_num = 0x0140;
..\..\User\main.c(89): error:  #20: identifier "PSUMCD_num" is undefined
      PSUMCD_num = 19125/INCTCD_num;  //INCTAB_num * PSUMAB_num;              //17ms PSUMCD_num的值由 INCTCD_num决定
..\..\User\main.c(91): error:  #20: identifier "INCTAB_num" is undefined
      INCTAB_num = 0x4AB5;
..\..\User\main.c(92): error:  #20: identifier "PSUMAB_num" is undefined
    PSUMAB_num = 19125/INCTAB_num;  //INCTAB_num * PSUMAB_num;              //17ms    PSUMCD_num的值由 INCTCD_num决定
..\..\User\main.c(94): warning:  #223-D: function "Spi_Write" declared implicitly
   Spi_Write(0x24,0x0d00 | PSUMAB_num);     //0x0dff    
..\..\User\main.c(115): error:  #20: identifier "flag1" is undefined
          if(flag1==0)  // 
..\..\User\main.c(118): error:  #20: identifier "INCTAB_num" is undefined
             INCTAB_num = INCTAB_num - 50;   //加速  只需要把改值按照 速度曲线变化就可以改变速度,现在演示的是线性的速度变化
..\..\User\main.c(124): error:  #20: identifier "PSUMAB_num" is undefined
             PSUMAB_num = 19125/INCTAB_num;
..\..\User\main.c(125): warning:  #223-D: function "Spi_Write" declared implicitly
             Spi_Write(0x24,0x0d00 | PSUMAB_num);     //0x0dff    
..\..\User\main.c(129): error:  #20: identifier "INCTCD_num" is undefined
                   INCTCD_num = INCTCD_num+ 30;
..\..\User\main.c(134): error:  #20: identifier "PSUMCD_num" is undefined
                   PSUMCD_num = 19125/INCTCD_num;
..\..\User\main.c(156): error:  #20: identifier "INCTAB_num" is undefined
             INCTAB_num = INCTAB_num + 30;    //减速
..\..\User\main.c(162): error:  #20: identifier "PSUMAB_num" is undefined
             PSUMAB_num = 19125/INCTAB_num;
..\..\User\main.c(163): warning:  #223-D: function "Spi_Write" declared implicitly
             Spi_Write(0x24,0x0d00 | PSUMAB_num);     //0x0dff    
..\..\User\main.c(167): error:  #20: identifier "INCTCD_num" is undefined
                   INCTCD_num  = INCTCD_num - 50;
..\..\User\main.c(172): error:  #20: identifier "PSUMCD_num" is undefined
                   PSUMCD_num = 19125/INCTCD_num;
..\..\User\main.c(205): warning:  #223-D: function "Delay" declared implicitly
          Delay(60);
..\..\User\main.c(209): error:  #20: identifier "flag1" is undefined
          flag1 = !flag1;
..\..\User\main.c(216): warning:  #223-D: function "Delay" declared implicitly
          Delay(60);
..\..\User\main.c(220): warning:  #223-D: function "MS_Rest" declared implicitly
               MS_Rest();
..\..\User\main.c(221): warning:  #223-D: function "MS_Int1" declared implicitly
               MS_Int1();
..\..\User\main.c(224): error:  #20: identifier "INCTCD_num" is undefined
              INCTCD_num = 0x0120;
..\..\User\main.c(225): error:  #20: identifier "PSUMCD_num" is undefined
              PSUMCD_num = 19125/INCTCD_num;  //INCTAB_num * PSUMAB_num;              //5ms
..\..\User\main.c(227): error:  #20: identifier "INCTAB_num" is undefined
              INCTAB_num = 0x4AB5;
..\..\User\main.c(228): error:  #20: identifier "PSUMAB_num" is undefined
              PSUMAB_num = 19125/INCTAB_num;  //INCTAB_num * PSUMAB_num;              //5ms    
..\..\User\main.c: 12 warnings, 22 errors
compiling stm32f10x_usart.c...
compiling bsp_usart1.c...
..\..\User\usart\bsp_usart1.h(11): error:  #7: unrecognized token
  void Usart_SendByte( USART_TypeDef *pUSARTx, uint8_t ch);
..\..\User\usart\bsp_usart1.h(11): error:  #130: expected a "{"
  void Usart_SendByte( USART_TypeDef *pUSARTx, uint8_t ch);
..\..\User\usart\bsp_usart1.h(12): error:  #7: unrecognized token
  void Usart_SendString( USART_TypeDef *pUSARTx, char *str);
..\..\User\usart\bsp_usart1.c(28): warning:  #12-D: parsing restarts here after previous syntax error
  {
..\..\User\usart\bsp_usart1.c(89): error:  #20: identifier "SendBuff" is undefined
          DMA_InitStructure.DMA_MemoryBaseAddr = (u32)SendBuff;
..\..\User\usart\bsp_usart1.c(128): error:  #247: function "Usart_SendByte"  has already been defined
          void Usart_SendByte( USART_TypeDef *pUSARTx, uint8_t ch)
..\..\User\usart\bsp_usart1.c: 1 warning, 5 errors
compiling stm32f10x_it.c...
compiling stm32f10x_tim.c...
compiling bsp_SPI.c...
compiling bsp_41908.c...
compiling bsp_exti.c...
compiling bsp_TiMbase.c...
"..\..\Output\Template.axf" - 27 Error(s), 13 Warning(s).
Target not created.
Build Time Elapsed:  00:00:03

 

 

 

 

引用网友解决办法:

..\main.c(173): error:  #7: unrecognized token

这个错误可能是拷贝的时候,中间有中文,或者其他不能识别的,看不见的字符。keil 编译的时候就会出错。

解决:找到那一行,删除那些不可见的字符即可。

你可能感兴趣的:(STM32)