STM32 common error analysis

Publisher:calmrsLatest update time:2018-09-01 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1.warning: #550-D: variable "d" was set but never used
Description: The variable 'd' is defined but never used, or, although you use this variable, the compiler thinks that the statement where the variable d is located is meaningless, and the compiler optimizes it.
Solution: Carefully consider whether the defined variable d is useful. If you believe that the statement where the variable d is located is meaningful, try to modify the variable d with the volatile keyword. If it is really useless, delete it to release possible memory.

2.warning: #1-D: last line of file ends without a newline
Description: The last line of the file is not a new line. The compiler requires that the last line of the program file must be a blank line. I have been thinking about it for a long time but I can't figure out why it is like this.
Solution: You can ignore it. If you feel uncomfortable with the warning, then press Enter on the last line of the file where the warning appears to leave a blank line.

3. warning: #111-D: statement is unreachable
Description: The statement is impossible to reach. It often appears in this situation:
 int main(void)
 {
   ...
  
        while(1) // infinite loop, which is most common in programs that do not use the operating system
       {
             ...
   
        }
  
   return 0; // This statement is impossible to execute under normal circumstances, and the compiler issues a warning
 }
 
Solution: Ignore it.

4. warning: C3017W: data may be used before being set
Description: The variable 'data' is not explicitly assigned a value before use. For example:
 uint8 i,data; //Define variables i and data, neither of which is explicitly assigned a value

 for ( i = 0; i < 8; i++) // variable 'i' is assigned 0 in the statement
 {
     if ( IO1PIN & SO_CC2420 )
      data |= 0x01; // variable 'data' is not explicitly assigned before use, compiler issues a warning
     else
      data &= ~0x01;
 }
Solution: Carefully consider whether the initial value of the variable is 0. If so, you can ignore this warning, because the MDK compiler will initialize the used data area to 0 before the program is executed. However, if the initial value of the variable should not be 0, ignoring this warning may cause a fatal error. This warning should be taken seriously. You should develop the habit of assigning initial values ​​to variables, fortunately, the compiler will check it.

5. warning: #177-D: variable "temp" was declared but never referenced
Description: The variable 'temp' was declared but not referenced. This usually happens when a variable is declared but not used. The difference between it and warning: #550-D: variable "temp" was set but never used is that temp has never been used.
Solution: If the defined variable is really useless, delete it; if it is useful, use it in the program.
Similar to this warning is warning: #177-D: function "MACProcessBeacon" was declared but never referenced

6. warning: #940-D: missing return statement at end of non-void function "DealwithInspect2"
Description: The function "DealwithInspect2" that returns non-void value is missing the return value statement at the end. For example:
 int DealwithInspect2(uint32 test)
 {
  ...
  ...
  ...
    //This should be return x; return an int data type. If there is no return value, the compiler will generate a warning
 }

7..warning:  #1295-D: Deprecated declaration lcd_init - give arg types

Description: When defining a function, if you write function parameters, this warning will appear, such as void timer_init(); there is no formal parameter here, if this happens, the compiler will give a warning.

 

 

 

 

 

1. error: #65: expected a ";"
Description: Missing semicolon. Most of the time, it is because the ';' is forgotten.
Solution: Double-click the error line, find the statement without the ';' sign near the error point, and add a semicolon. The semicolon is not necessarily missing in the error line, it may be the previous line or the next line.

2. error: #65: expected a ";" and error: #20: identifier "xxxx" is undefined appear together, and the following error: #20 may have a lot of
descriptions: This error is definitely a nightmare for those who encounter it for the first time. When the error appears, you double-click the error prompt with hope, but when you come to the error line, you are shocked to find that the error line is absolutely correct. So you look for the previous line and the next line of the error line, and there is no error. Then you look for the previous line and the next line... Something very depressing has happened: all the error lines in the compilation prompt cannot have errors. In fact, this is most likely because you did not add a semicolon at the end of the declaration statement when declaring external variables or functions in the .h file! If you have many modules, such as main.c, lcd.c, key.c... and many header files, such as lcd.h, key.h, if you do not add a semicolon when declaring a function in the lcd.h file, then this error may be determined in main.c, so you need to check all header files.
Solution: Check the .h file carefully and add the semicolon.

3.  Error: L6200E: Symbol flagu multiply defined (by uart0.o and main.o).

Description: The variable (also a symbol) flagu is defined in multiple places (in uart0.c and main.c). This is usually caused by repeated global variable definitions. For example, in main.c, define the global variable flagu:

      uint8 flag=0;

This variable is also used in uart0.c, so to declare this variable, I usually copy the defined variable first and then add the keyword extern in front of the variable:

      extern uint8 flagu=0;

Then compile, the above connection error will appear. The reason is that I defined another variable in uart0.c instead of declaring the variable, because I assigned the initial value "flagu=0" to the variable, which repeated the definition of the variable flag. The correct declaration method is to remove the assignment part:

      extern uint8 flagu;

Solution: Find the duplicate defined variables and modify one of them depending on the situation.

4.error: #159: declaration is incompatible with previous "wr_lcd" (declared at line 40)
Description: The wr_lcd function was used before it was declared. This often occurs in two situations: First, the wr_lcd function body has not been written yet, but it has been used. This often occurs when writing the general structure of a program, where just a simple framework is written. The second situation is more common, where function a calls function b, but the body of function b is below function a:
void a(void) //the entity of function a
{
       ​​b(); //call function b
}

void b(void) //Entity of function b
{
       ...
}
If you compile this, error #159 will be generated, because when function a calls function b, it is found that there is no declaration of function b before it.
Solution: Before function a calls function b, declare function b, such as:
void b(void); //Declare function b

void a(void) //Entity of function a
{
      ​​b(); //Call function b
}

void b(void) //Entity of function b
{
     ...
}
 
 5. error: #137: expression must be a modifiable lvalue

Description: The expression must be a modifiable left value. It mainly appears in this phenomenon:

                 a=NUM;

NUM is a value or expression, and a is a variable, but a is defined as an immutable type like const, which means that NUM cannot be assigned to variable a.

Solution: Either give up the assignment or modify the variable properties.


6.error: #18: expected a ")"
If it appears in a c file, it is probably because a ")" is missing, or the error line contains characters that the compiler does not recognize.

If it appears in a header file, and the error line is a function declaration, it is probably because there are characters in the function declaration that the compiler does not recognize.


7.error:  #7: unrecognized token

Unrecognized marks are mostly switched to Chinese punctuation.


Keywords:stm32 Reference address:STM32 common error analysis

Previous article:STM32 uses SWD to connect and report errors
Next article:Macro definition problem of STM32

Recommended ReadingLatest update time:2024-11-16 11:40

STM32 register operation mode learning - GPIO
1. When a port is to be configured as an external interrupt line, the port must be configured in input mode. 2. For bidirectional multiplexing functions, the port bit must be configured with the multiplexing function output mode (push-pull or open-drain). At this time, the input driver is configured as floating input
[Microcontroller]
stm32 download method serial port ISP\swd (JLink)
1. First look at the stm32 startup mode  The boot mode of stm32 is determined by the boot0 and boot1 pins of the 32 chip. It is divided into embedded flash boot mode (normal boot mode), memory boot mode, and rom boot mode. The corresponding relationship between the boot mode and the pin high and low levels is as follo
[Microcontroller]
stm32 download method serial port ISP\swd (JLink)
STM32 power management and low power mode
7.1 Power Management Overview Processors make extensive use of clock gating to disable inputs to unused functions and blocks, so that only the clocks that are being used are Dynamic power is consumed only by logic that is actively in use. The ARMv7-M architecture supports a system sleep mode that stops the Cortex-M3 a
[Microcontroller]
STM32 power management and low power mode
Solution to the problem that the stm32 microcontroller cannot download the program after entering the sleep (STOP) mode
By using the sleep mode of the stm32 microcontroller, the microcontroller can be put into sleep intermittently to achieve low power consumption. It often fails to wake up after entering sleep mode, resulting in the next program not being able to be burned in. The usual solution is: the general development board or mic
[Microcontroller]
Solution to the problem that the stm32 microcontroller cannot download the program after entering the sleep (STOP) mode
STM32IO and timer mapping to address
Significance: Sometimes when we operate multiple STM32 IOs, the hardware design may not be regular, such as the output pins are: PB3, PC4, PC5, PD0, but the operations of these pins have commonalities, or we want to use for(it i = 0; i 4; i++) to operate these pins like an array, the program will become very concise,
[Microcontroller]
stm32 FSMC-External SRAM IS62WV51216
Pin Definition  FSMC configuration steps 1. Enable the corresponding pin GPIO clock  2. Configure the GPIO pin mode  3. Enable the FSMC clock  4. FSMC initialization  5. Memory block enable Example  #define Bank1_SRAM3_ADDR ((u32)(0x68000000)) //First address 0x60000000, each block 0x40000000 void SRAM_gp
[Microcontroller]
stm32 FSMC-External SRAM IS62WV51216
STM32 PWM waveform output configuration summary
1. TIMER classification: There are 11 timers in STM32, of which TIM6 and TIM7 are basic timers; TIM2, TIM3, TIM4, and TIM5 are general timers; TIM1 and TIM8 are advanced timers, as well as 2 watchdog timers and 1 system tick timer. The system tick timer is the SysTick described above. Timer Counter resolution Cou
[Microcontroller]
STM32 PWM waveform output configuration summary
Tic and toc in STM32, use SysTick to count the execution time of code segments
Systick in STM32 has a total of 4 registers, the names and addresses are: SysTick_CTRL, 0xE000E010 -- Control register  SysTICK_LOAD, 0xE000E014 -- Reload register  SysTick_VAL, 0xE000E018 -- Current value register  SysTick_CALRB, 0xE000E01C -- Calibration value register  First look at the SysTick- CTRL control
[Microcontroller]
Tic and toc in STM32, use SysTick to count the execution time of code segments
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号