KeilC51 compilation common errors and warnings

Publisher:Joyful222LifeLatest update time:2015-09-28 Source: eefocusKeywords:keilC51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
(1) L15 repeated call
***WARNING L15: MULTIPLE CALL TO SEGMENT
SEGMENT: ?PR?SPI_RECEIVE_WORD?D_SPI
CALLER1: ?PR?VSYNC_INTERRUPT?MAIN
CALLER2: ?C_C51STARTUP
This warning indicates that the linker has found a function that may be called by the main function and an interrupt service routine (or a function that calls an interrupt service routine) at the same time, or by multiple interrupt service routines at the same time.
One of the reasons for this problem is that this function is a non-reentrant function. When the function is running, it may be interrupted by an interrupt, which
may change the result and cause some variable conflicts (that is, cause some data in the function to be lost. Reentrant functions can be interrupted by ISR at any time and can run again after a period of time, but the corresponding data will not be lost).
The second reason is that the memory area used for local variables and variables (arguments, [independent variables, variable-value, used to determine the value of a program or subroutine]) is overwritten by the memory area of ​​other functions. If the function is interrupted, its memory area will be used, which will cause
memory conflicts in other functions.

For example, in the first warning, the function WRITE_GMVLX1_REG is defined in D_GMVLX1.C or D_GMVLX1.A51, and it is
called by an interrupt service routine or a function that calls an interrupt service routine. The function that calls it is VSYNC_INTERRUPT, in MAIN.C.

Solution:
If you are sure that the two functions will never be executed at the same time (the function is called by the main program and interrupts are disabled), and the function does not occupy memory (assuming that only registers are used), you can completely ignore this warning.
If the function occupies memory, you should use the linker OVERLAY directive to
exclude the function from overlay analysis, for example:
OVERLAY (?PR?_WRITE_GMVLX1_REG?D_GMVLX1 ! *)
The above directive prevents the memory area used by the function from being overwritten by other functions. If the function calls other functions, and these functions are
also called elsewhere in the program, you may want to exclude these functions from overlay analysis. This OVERLAY directive
enables the compiler to remove the above warning message.
If the function can be called during its execution, the situation becomes more complicated. In this case, the following methods can be used:
1. Disable interrupts when the main program calls the function. You can use the #pragma disable statement to achieve the purpose of disabling interrupts when the function is called.
The OVERLAY directive must be used to exclude the function from overlay analysis.
2. Copy the code of the function twice, one to the main program and the other to the interrupt service routine.
3. Set the function to be reentrant. For example: void myfunc(void) reentrant {
...
}
This setting will generate a reentrant stack, which is used to store function values ​​and local variables. When using this method, the reentrant stack must be configured in the STARTUP.A51 file. This method consumes more RAM and reduces the execution speed of the reentrant function.

(2) Prompt that there is no M51 file
When compiling, it prompts:
F:...XX.M51
File has been changed outside the editor, reload?
------
Solution:
Regenerate the project and generate STARTUP.A51.

(3) L16 No call
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_COMPARE?TESTLCD
Explanation: Some functions in the program, such as COMPARE (or segments), have never been called before (during debugging), or there is no
statement to call it.
This warning message should be preceded by a message indicating which function is causing the problem. It can be fixed with a few simple adjustments
. It is not a big deal to ignore it.
Solution: Remove the COMPARE() function or use conditional compilation #if … ..#endif to keep the function and not compile.

(4) L10 and L16 "Main program name is wrong (or there is no main program)"
In the program:
void main (void)
Compiler prompt:
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?MIAN?MAIN
*** WARNING L10: CANNOT DETERMINE ROOT SEGMENT Program Size: data=8.0 xdata=0 code=9
---
Modification:
The main program is missing (actually a typo), change mian to main

(5) L16 The main program does not use the previously defined function
The previously defined function is not used in the main program. When compiling, it is displayed:
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?DELAY?MAIN

(6) L210 Generate SRC statement before the program
Build target 'Target 1'
assembling STARTUP.A51...
compiling test.C...
linking...
BL51 BANKED LINKER/LOCATER V6.00 - SN: K1JXC-94Z4V9
COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2005
"STARTUP.obj",
"test.obj"
TO "test"
*** FATAL ERROR L210: I/O ERROR ON INPUT FILE:
EXCEPTION 0021H: PATH OR FILE NOT FOUND
FILE: test.obj
Target not created
---------
Problem with the settings. Just disable #pragma src in the program.

(7) C206 Function not defined
The function is not defined
MAIN.C(15): warning C206: 'delay1': missing function-prototype(8) C141 Missing semicolon
Part of the program:
{
pval = P1
P3 = pval;
}
Compilation error:
MAIN.C(22): error C141: syntax error near 'P3'
Correction: Add ";" after P1

(9) C129 assembly and C suffix issues
For example, write a small program like this and save it as c0.c. When compiling, error c129, miss; before 0000 appears.
If it is saved as: c0.asm, this error will not appear. If it is saved as c, the c51 compiler is called first and compiled according to the requirements of the c language, so
an error occurs; you can refer to some books that specifically introduce the keilc compiler;

(10) C101 and C141 about array quotation marks
The following array is defined:
unsigned char
a[36]={'0xfe','0xfd','0xfb','0xf7','0xef','0xdf','0xbf','0x7f','0x7e','0x7d','0x7b','0x77','0x6f',' 0x5f','
0x3f','0x3e','0x3d ','0x3b','0x37','0x2f','0x1f','0x1e','0x1d','0x1b','0x17','0x0f','0x0e','0
x0d','0x0b','0x07','0x06','0x05','0x03','0x02','0x01','0x00'};
but it always fails when compiling, and the error prompts are as follows:
Build target 'Target 1'
compiling shaomiao.c...
SHAOMIAO.C(3): error C101: ''0': invalid character constant
SHAOMIAO.C(3): error C141: syntax error near 'xfe'
SHAOMIAO.C(3): error C101: ''}': invalid character constant
Target not created
Solution: remove the '...' quotation marks

(11) C100 and C141 and C129 programs have Chinese punctuation
Errors occur when compiling with keil, as follows: D:KEILC51INCREG52.H(1): error C100: unprintable character 0xA1
skipped There are many errors as above, and there are also D:KEILC51INCREG52.H(2): error C141: syntax error near '#'
D:KEILC51INCREG52.H(2): error C129: missing ';' before '<'
But the reg52.h header file is provided by Keil (see below), why does it report an error?
----
Answer: If there are Chinese punctuation marks in the program, just rewrite it in English.

(12) A45: Numbers and letters are confused in assembly.
MOV PO,A ; put on next 11
...
MOV RO,#0FFH ; 14
MOV R1,#OFFH ; 15
...
DJNZ RO,DLY_LP ;19
MOV R0,#OFFH ; 20
...
After compilation:
ledtest.asm(11): error A45: UNDEFINED SYMBOL (PASS-2)
ledtest.asm(14): error A45: UNDEFINED SYMBOL (PASS-2)
ledtest.asm(15): error A45: UNDEFINED SYMBOL (PASS-2)
ledtest.asm(19): error A45: UNDEFINED SYMBOL (PASS-2)
ledtest.asm(20): error A45: UNDEFINED SYMBOL (PASS-2)
Target not created
---------
Note:
The letter "O" and the number "0". The main error is here.
You should enter the number "0", but you entered the letter "O".

(13)  Warning 280: ' i ' : unreferenced local variable
Description The local variable i is not accessed in the function Solution Eliminate the declaration of the variable i in the function 2 Warning 206: ' Music3 ' : missing function-prototype
Description The Music3() function is not declared or not declared externally, so it cannot be called by other functions
Solution Write the statement void Music3(void) at the beginning of the program to declare it. If it is a function in other files, write it
as extern void Music3(void), that is, declare it externally

3 Compling: C:8051MANN.C
Error:318: can't open file ' beep.h '
Description During the compilation of C:8051MANN.C program, main.c used the instruction #include "beep.h", but it
could not be found Solution Write an include file of beep.h and save it to c:8051 In the working directory

(14) Compling: C: 8051LED.C
Error 237: ' LedOn ' : function already has a body
Description LedOn() function name is defined repeatedly, that is, there are more than two identical function names
Solution Correct one of the function names so that the function names are independent

15) ***WARNING 16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_DELAYX1MS?DELAY
Description DelayX1ms() function will occupy program memory space even if it is not called by other functions Solution Remove DelayX1ms() function or use conditional compilation #if … ..#endif, you can keep the function and not compile

(16) ***WARNING 6: XDATA SPACE MEMORY OVERLAP
FROM: 0025H
TO: 0025H
Description The address 0025H of the external data ROM is defined repeatedly
Solution The definition of the external data ROM is as follows Pdata unsigned char XFR_ADC _at_0x25
The name of the XFR_ADC variable is 0x25. Please check if there are other variable names defined at 0x25 and correct them.

(17) WARNING 206: ' DelayX1ms ' : missing function-prototype
C:8051INPUT.C
Error 267 : ' DelayX1ms ' : requires ANSI-style prototype C:8051INPUT.C
Description The program calls the DelayX1ms function but the function is not defined, that is, the program content is not written or the function is defined but not declared.
Solution: After writing the content of DelayX1ms, you must declare it or make an external declaration. You can declare it as external in the include file of delay.h so that other functions can call it.

(18) ***WARNING 1:UNRESOLVED EXTERNAL SYMBOL
SYMBOL:MUSIC3
MODULE:C:8051MUSIC.OBJ(MUSIC)
***WARNING 2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: MUSIC3
MODULE: C: 8051MUSIC.OBJ (MUSIC)
ADDRESS: 0018H
Description The program calls the MUSIC function but does not add the extension C file of the function to the project file Prj for compilation and linking.
Solution: Set the MUSIC3 function in MUSIC C and add MUSIC C to the project file

(19) ***ERROR 107: ADDESS SPACE OVERFLOW
SPACE: DATA
SEGMENT: _DATA_GOUP_
LENGTH: 0018H
***ERROR 118: REFERENCE MADE TO ERRONEOUS EXTERNAL
SYMBOL: VOLUME
MODULE: C: 8051OSDM.OBJ (OSDM)
ADDRESS: 4036H
Description data The address range of the storage space is 0~0x7f. When the number of public variables and local variables in the function is set to SMALL, the local variables will first use the working registers R2~R7 for temporary storage. When the memory is insufficient,
the address will be insufficient when the number of temporary storage in the data type space exceeds 0x7f.
The solution is to modify the public variables defined as data type to idata type definition


(20). ***WARNING L15: MULTIPLE CALL TO SEGMENT
SEGMENT: ?PR?_WRITE_GMVLX1_REG?D_GMVLX1
CALLER1: ?PR?VSYNC_INTERRUPT?MAIN
CALLER2: ?C_C51STARTUP
***WARNING L15: MULTIPLE CALL TO SEGMENT
SEGMENT: ?PR?_SPI_SEND_WORD?D_SPI
CALLER1: ?PR?VSYNC_INTERRUPT?MAIN
CALLER2: ?C_C51STARTUP
***WARNING L15: MULTIPLE CALL TO SEGMENT
SEGMENT: ?PR?SPI_RECEIVE_WORD?D_SPI
CALLER1: ?PR?VSYNC_INTERRUPT?MAIN
CALLER2: ?C_C51STARTUP
This warning indicates that the linker has found a function that may be called by the main function and an interrupt service routine (or a function that calls an interrupt service routine) at the same time, or by multiple interrupt service routines at the same time.

One reason for this problem is that this function is a non-reentrant function. When the function is running, it may be
interrupted by an interrupt, which changes the result and may cause some variable conflicts (that is, causing some data in the function to be lost. Reentrant functions can be interrupted by ISR at any time and can run again after a period of time, but the corresponding data will not be lost).

The second reason is that the memory area used for local variables and variables (arguments, [independent variables, variables-values, used to determine the value of a program or subroutine]) is overwritten by the memory area of ​​other functions. If the function is interrupted, its memory area will be used, which will cause memory conflicts in other functions.
For example, in the first warning, the function WRITE_GMVLX1_REG is defined in D_GMVLX1.C or D_GMVLX1.A51, and is called by
an interrupt service routine or a function that calls an interrupt service routine, and the function that calls it is VSYNC_INTERRUPT, in MAIN.C. Solution: If you are sure that the two functions will never be executed at the same time (the function is called by the main program and interrupts are disabled), and the function does not occupy memory (assuming that only registers are used), then you can completely ignore this warning. If the function occupies memory, you should use the linker OVERLAY directive to exclude the function from overlay analysis , for example: OVERLAY (?PR?_WRITE_GMVLX1_REG?D_GMVLX1 ! *) The above instruction prevents the memory area used by the function from being overwritten by other functions. If this function calls other functions that are also called elsewhere in the program, you may want to exclude these functions from overlay analysis. The OVERLAY directive will allow the compiler to remove the warning message above. If the function can be called during its execution, the situation becomes more complicated. There are several ways to do this : 1. Disable interrupts when the main program calls the function. This can be done by using the #pragma disable statement when the function is called . The OVERLAY directive must be used to exclude the function from overlay analysis. 2. Make two copies of the function code, one in the main program and one in the interrupt service routine. 3. Make the function reentrant. For example: void myfunc(void) reentrant { ... } This setting will generate a reentrant stack that is used to store function values ​​and local variables. The reentrant stack must be configured in the STARTUP.A51 file when using this method. This method consumes more RAM and slows down the execution of reentrant functions. (21). *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?_COMPARE?TESTLCD Explanation: Some functions (or segments) in the program have never been called before (during debugging), or there is no statement to call them. This warning message should be preceded by a message indicating which function caused the problem. Just make some simple adjustments. Ignoring it is not a big deal. Solution: Remove the COMPARE() function or use conditional compilation #if … ..#endif to keep the function and not compile it.


































Keywords:keilC51 Reference address:KeilC51 compilation common errors and warnings

Previous article:Solutions to common warnings and error messages of Keil C compiler
Next article:MCU compilation error error A45: UNDEFINED SYMBOL

Recommended ReadingLatest update time:2024-11-16 15:38

Introduction to 51 MCU Simulator
1. Main functions and features 1. It can simulate 63K program space, close to 64K 16-bit address space; 2. Can simulate 64Kxdata space, all 64K 16-bit address space; 3. Can truly simulate all 32 IO pins; 4. Fully compatible with keilC51 UV2 debugging environment, single-step, breakpoint, full
[Microcontroller]
Detailed explanation of KeilC51 usage (Part 2)
Chapter 3 Keil C51 vs Standard C One of the keys to learning C51 is to deeply understand and apply the extensions of C51 to the standard ANSI C. This is because most of the extensions are directly targeted at the 8051 series CPU hardware. There are roughly 8 categories: l 8051 storage type and storage area l Storage m
[Microcontroller]
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号