Summary of some errors during KEIL51 debugging

Publisher:快乐的旅程Latest update time:2016-09-25 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
(1) It says there is no M51 file

Compile time prompt:

F:\...\XX.M51

File has been changed outside the editor, reload?

------

Solution:

Regenerate the project and generate STARTUP.A51.

 

(2) L15 repeated calls

***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 simultaneously by the main function and an interrupt service routine (or a function that calls an interrupt service routine), or by multiple interrupt service routines at the same time.

    One of the reasons for this problem is that this function is not reentrant. 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 be reentrant after a period of time.

However, the corresponding data will not be lost).

    The second reason is that the memory area used for local variables and variables (let's translate it this way, arguments, [independent variables, variable-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 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 that the function does not occupy any memory (assuming only registers are used), you can completely ignore this warning.

    If the function occupies memory, it should be excluded from overlay analysis using the linker OVERLAY directive, for example:

OVERLAY (?PR?_WRITE_GMVLX1_REG?D_GMVLX1 ! *)

   The above directive prevents the memory area used by this function from being overwritten by other functions. If this 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 while it is executing, the situation becomes more complicated. There are several approaches you can take:

1. Disable interrupts when the main program calls this function. You can use the #pragma disable statement when the function is called to achieve the purpose of disabling interrupts. You must use the OVERLAY instruction to remove the function from the coverage analysis.

2. Copy two copies of the function code, one to the main program and the other to the interrupt service program.

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 will slow down the execution of reentrant functions.

 

(3) L16 no call

*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS

   

SEGMENT: ?PR?_COMPARE?TESTLCD

       Note: Some functions in the program, such as COMPARE (or fragments), have never been called before (during debugging), or there is no statement to call it at all.

       This warning should be preceded by a message indicating which function is causing the problem. It should be fine with 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.

 

(4) L10 and L16 "Main program name is wrong (or there is no main program)"

In the program:

void main (void)

Compilation tips:

*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS

    SEGMENT: ?PR?MIAN?MAIN

*** WARNING L10: CANNOT DETERMINE ROOT SEGMENT

    Program Size: da ta=8.0 xdata=0 co de=9

---

Revise:

The main program is missing (actually a typo), change mian to main 

 

(5) The L16 main program does not use the previously defined functions

 The previously defined function is not used in the main program, and the following is displayed during compilation:

*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS

    SEGMENT: ?PR?DELAY?MAIN

 

(6) Generate SRC statement before L210 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

---------

For setting problems, just disable #pragma src in the program.

 

(7) C206 function is not defined

This function is not defined

MAIN.C(15): warning C206: 'delay1': missing function-prototype

 

(8) C141 Less semicolon

Part of the program:

  {

  pval = P1 /* Read P1 into pval */

  P3 = pval; /* Write pval to P3 */

  }

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 appears, miss; before 0000;

If you save it as: c0.asm, this error will not occur. If you save it as c, the c51 compiler will be called first and compiled according to the requirements of the c language, so an error will occur. You can refer to some books that specifically introduce the keilc compiler;

(10) C101 and C141 on 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','0x3 b','0x37','0x2f','0x1f','0x1e','0x1d','0x1b','0x17','0x0f','0x0e','0x0d','0x0b','0x07' ,'0x06','0x05','0x03','0x02','0x01','0x00'};

But the compilation always fails, and the error prompt is 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 quotes '...'

 

(11) C100, C141 and C129 programs have Chinese punctuation

An error occurred when compiling with Keil, as follows: D:\KEIL\C51\INC\REG52.H(1): error C100: unprintable character 0xA1 skipped

There are many errors as above, and D:\KEIL\C51\INC\REG52.H(2): error C141: syntax error near '#'

                    D:\KEIL\C51\INC\REG52.H(2): error C129: missing ';' before '<'    

But the reg52.h header file comes with Keil (see below), so why does it report an error?

----

Answer: There are Chinese punctuation marks in the program. Just rewrite it in English.

 

(12) Confusion of numbers and letters in A45 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

---------

Notice:

The letter "O" and the number "0". This is where the main mistake is.

You entered the letter "O" instead of the number "0".

(13) C141 error

Tip 001.C(23): error C141: syntax error near 'unsigned'

The statement before this line "bit flag_Key_Service_song=0" is missing a semicolon

(14) C129 error

Tip 001.C(22): error C129: missing ';' before 'flag_Key_Service_song'

In the definition, "bi flag_Key_Service_song=0;"

Change to bit

Reference address:Summary of some errors during KEIL51 debugging

Previous article:128*64 LCD uses the program of "MCU internal display buffer"
Next article:Keil C51 program debugging process

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号