How to solve common problems in MCU debugging

.error: #18:

6. error: #18: expected a ")"

If it appears in the c file, it is probably because there is a missing ")", or the error line has characters that the compiler does not recognize

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

error: #20

error: #20: identifier "TIM2_IRQChannel" is undefined who can tell what is wrong

The library files in your firmware library are not added to the project, so there is an undefined situation.

TIM2_IRQChannel means that the interrupt channel of timer 2 is not defined. In fact, these parameters are defined in the firmware library, and the macro definition replaces a series of register address data. The .C file needs to be added to the project file

warning: #1-D

main.c(7): warning: #1-D: last line of file ends without a newline

When compiling with keil, this warning message pops up: main.c(7): warning: #1-D: last line of file ends without a newline

This is because there is no carriage return after the "}" in the main function.

This warning message can be eliminated as long as the enter key is added after the "}" in the main function.

error:#65

...test_menu.c(27):error:#65:expected a ";"

The score is sent to you, the problem has been solved before you answer, the last line of the structure definition in the header file does not add ";" such as NB menu{..};

Error: L6200E

Error: L6200E: Symbol temp multiply defined (by wenshidu.o and main.o). This problem occurred when compiling, but I can't check it out, I hope you guys can help

What variable do you give the value twice

See if it's that external variable that you assign again

main.c declares that the .h files corresponding to other .c files are referenced by extern

warning: #223-D

....sourceCCxx00_New.C(718): warning: #223-D: function "_NOP_" declared implicitly

Add extern void _NOP_() in the used file; either

warning: #1295-D

....includeCCxx00_New.h(20): warning: #1295-D: Deprecated declaration CC_XCal - give arg types

When there is no formal parameter, use void CC_XCal(void);

Error: L6218E: Undefined symbol

.Objoutput.axf: Error: L6218E: Undefined symbol FSMC_NORSRAMCmd (referred from tft_lcd.o).

.Objoutput.axf: Error: L6218E: Undefined symbol FSMC_NORSRAMInit (referred from tft_lcd.o).

Target not created

Ask an expert, how should I deal with it.

Look at tft_lcd to see if there is a header file such as fsmcXXX.h added. This error means that the function you are using is not defined.

Generally, you only need to add the corresponding header file

error: #101:

error: #101: has already been declared in the current scope

will

#ifndef __STM32F10x_LIB_H

#define __STM32F10x_LIB_H

#endif Tweak to the end!

file:///C:UsersADMINI~1AppDataLocalTempksohtmlwps_clip_image-20349.png

error: #247: function "DelayUs" has already been defined

There is a DelayUs class with the same name already defined

error: #109: expression must have (pointer-to-) function type

This problem is most of the 19 errors, which means that the expression requires a (pointer) function parameter. I thought it was an error in my own function declaration or call at first, but after reading it, I found that there was nothing wrong, and then I checked it. After a long time, I found out that I made a very low-level mistake: I renamed the macro definition and the function name. Because I thought at the beginning that each macro definition corresponds to a function name, it is clearer to do so, but I was stupid and copied the function name directly to the macro name every time, resulting in this kind of broken result.

warning: #61-D

warning: #68-D:

In KeilARM's LPCARM, there is (1

main.c(174): warning: #61-D: integer operation result is out of range

main.c(174): warning: #68-D: integer conversion resulted in a change of sign

Since the compiler defaults to signed int, which is a 32-bit signed integer type, and 1

In this way, it is possible to rewrite the sign bit (the highest bit)

And so on, (2

The solution is: ((unsigned int)1

warning: #1295-D:

warning: #1295-D: Deprecated declaration ShowSendTime - give arg types

Solution: Change void ShowSendTime() to void ShowSendTime(void)

warning: #550-D:

warning: #550-D: variable "d" was set but never used

Description: The variable 'd' is defined but never used, or, although you use the variable, the compiler thinks that the statement where the variable d is located is meaningless, and the compiler optimizes it.

Solution: Carefully measure whether the defined variable d is useful. If 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.

error: #159:

.error: #159: declaration is incompatible with previous "wr_lcd" (declared at line 40)

void a(void) //Entity of function a

{

b(); //call function b

}

void b(void) //the entity of function b

{

...

}

In this way, if the point is compiled, an error of 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) //the entity of function b

{

...

}

error: #70:

error: #70: incomplete type is not allowed

It turns out that the definition is repeated, including the definition of psock twice, so this happens. Because I found that psock and pt are defined in the same way, but pt does not report an error, so I tried to delete the line that included the header file in the header file, and the error was eliminated. Thank you. Dead make up, to think, haha.

warning: #550-D:

1. warning: #550-D: variable "d" was set but never used

Description: The variable 'd' is defined but never used, or, although you use the variable, the compiler thinks that the statement where the variable d is located is meaningless, and the compiler optimizes it.

Solution: Carefully measure whether the defined variable d is useful. If 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.

warning: #1-D:

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.

Solution: You can ignore it. If you feel uncomfortable with the warning, then hit enter at the last line of the file where the warning appears, and leave a line.

warning: #111-D:

3. warning: #111-D: statement is unreachable

Description: The statement cannot be reached. It appears more often in this situation:

int main(void)

{

...

while(1) // infinite loop, this is most common in programs that do not use the operating system

{

...

}

return 0; //This statement cannot be executed under normal circumstances, and the compiler issues a warning

}

Solution: ignore it.

warning: C3017W:

4. warning: C3017W: data may be used before being set

Description: The variable 'data' has no explicit assignment before use. For example:

uint8 i, data; //Define the variables i and data, neither of which has a clear assignment

for ( i = 0; i

{

if ( IO1PIN & SO_CC2420 )

data |= 0x01; //The variable 'data' is not definitely assigned before use, the compiler issues a warning

else

data &= ~0x01;

}

Solution: You should carefully measure 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, but if the initial value of the variable is not It should be 0, ignoring this warning may cause a fatal error. This warning should be paid enough attention. You should develop the habit of assigning initial values ​​to variables, fortunately, the compiler will check.

warning: #177-D:

5. warning: #177-D: variable "temp" was declared but never referenced

Description: The variable 'temp' was declared but not referenced. Mostly when a variable is declared but not used, it differs from warning: #550-D: variable "temp" was set but never used in that temp Never 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

warning: #940-D:

6. warning: #940-D: missing return statement at end of non-void function "DealwithInspect2"

Description: The last missing return value declaration of the non-null function "DealwithInspect2". For example:

int DealwithInspect2(uint32 test)

{

...

...

...

//This should be return x; return an int data, if there is no return value, the compiler will generate a warning

}

.warning: #1295-D:

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

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

error: #65:

1. error: #65: expected a ";"

Description: Missing semicolon. Mostly missing ';'.

Solution: Double-click the error line, find the statement without the ';' sign near the error point, and add a semicolon. It is not necessarily that there is a semicolon in the error line located, it may be the previous line of this line, Possibly the next line as well.

error: #65: error: #20

2. error: #65: expected a ";" and error: #20: identifier "xxxx" is undefined appear together, and the following error: #20 may have a lot of errors

Description: This error is definitely a nightmare for those who encounter it for the first time. When the error occurs, double-click the error message with hope, but when I come to the wrong line, I am surprised to find that the wrong line is absolutely not wrong, so I look for the wrong line. The previous line, the next line, there is no error, and then find the upper line, the lower line... The extremely depressing thing has appeared: all the error lines in the compilation prompt cannot have errors. In fact, this is most likely that you are in .h When the file declares external variables or functions, there is no semicolon at the end of the declaration statement! If you have many modules, such as main.c, lcd.c, key.c... There are many header files, such as lcd.h, key .h, if there is no semicolon when declaring the function in the lcd.h file, then this error may be set in main.c, so check all header files.

Solution: Check the .h file carefully and fill in the semicolon.

Error: L6200E:

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 (defined in both uart0.c and main.c). Usually the mistake is that the definition of the global variable is repeated. For example: define the global variable flagu in main.c:

uint8 flagu=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 modification 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, so the definition is repeated. The variable flag. The correct way to declare it is to remove the assignment part:

extern uint8 flagu;

Solution: Find the variable that is defined repeatedly, and modify it according to the situation.

error: #159:

4.error: #159: declaration is incompatible with previous "wr_lcd" (declared at line 40)

Description: It has been used before the wr_lcd function has been declared. It mostly occurs in two situations: the first is that the wr_lcd function body has not been written yet, but it has been used. This situation mostly occurs when writing the general structure of a program , just briefly write the framework. The second case is more common, function a calls function b, but the function body of function b is below function a:

void a(void) //Entity of function a

{

b(); //call function b

}

void b(void) //the entity of function b

{

...

}

In this way, if the point is compiled, an error of 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) //the entity of function b

{

...

}

error: #137:

5. error: #137: expression must be a modifiable lvalue

Description: The expression must be a modifiable lvalue. It mainly occurs in this phenomenon:

a=NUM;

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

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

error: #1113:

After tossing for a long time, I figured out a no-op instruction

First of all, some people said that it is __asm{NOP;}, which is called from intrinsics.h, but I searched all the corners and found no intrinsic.h file. If used directly, error: #1113: Inline assembler not permitted when generating Thumb code

Finally search for this error and know that it is because __asm("instruction"); This syntax is the syntax of inline assembly. Under RMDK, inline assembly only supports ARM assembly language, not Thumb or Thumb-2 assembly language; but inline assembler supports Thumb and Thumb-2.

__asm ​​is placed in a separate sub-function and then called, there is no problem

as follows:

__asm ​​void nop(void)

{

NOP

}

Then call the function in the C code after:

void main()

{

...

nop();

...

}

Industrial Diesel Generator

Industrial Diesel Generator,Industrial Generators,Commercial Diesel Generators,Industrial Type Diesel Generator

Jiangsu Vantek Power Machinery Co., Ltd , https://www.vantekpower.com