7567 views|10 replies

1379

Posts

0

Resources
The OP
 

Basic knowledge of Keil C51 development system [Copy link]

Basic knowledge of Keil C51 development system
1. Section 1 System Overview
Keil C51 is a 51 series compatible microcontroller C language software development system produced by Keil Software, USA. Compared with assembly language, C language has obvious advantages in function, structure, readability and maintainability, so it is easy to learn and use. After using assembly language, you will have a deeper understanding of C development.
Keil C51 software provides rich library functions and powerful integrated development and debugging tools, with a full Windows interface. Another important point is that as long as you look at the assembly code generated after compilation, you can appreciate that the target code generated by Keil C51 is very efficient. The assembly code generated by most statements is very compact and easy to understand. The advantages of high-level languages can be better reflected when developing large-scale software.
The following is a detailed introduction to the functions and uses of each part of the Keil C51 development system.
2. Section 2 The overall structure of the Keil C51 microcontroller software development system
The overall structure of the C51 toolkit is shown in Figure (1), where uVision and Ishell are the integrated development environments (IDE) of C51 for Windows and for Dos, respectively, which can complete the entire development process such as editing, compiling, connecting, debugging, and simulation. Developers can use the IDE itself or other editors to edit C or assembly source files. Then the C51 and A51 compilers compile and generate target files (.OBJ). The target file can be created by LIB51 to generate a library file, or it can be linked and located together with the library file through L51 to generate an absolute target file (.ABS). The ABS file is converted into a standard Hex file by OH51 for use by the debugger dScope51 or tScope51 for source code level debugging. It can also be used by the emulator to debug the target board directly, or it can be written directly into the program memory such as EPROM.



Figure (1) Overall structure of the C51 toolkit


3. Section 3 Installation of the Keil C51 toolkit
1. 1. C51 for Dos
directly runs DOS\C51DOS.exe in the software package under Windows and then selects the installation directory. After completion, the following operations must be performed to make the system work properly (assuming C:\C51 is the installation directory):
Modify Autoexec.bat, add
path=C:\C51\Bin
Set C51LIB=C:\C51\LIB
Set C51INC=C:\C51\INC
Then run Autoexec.bat
2. 2. Installation and precautions of C51 for Windows:
Run WIN\Setup.exe in the software package under Windows. It is best to choose the same installation directory as C51 for Dos. This is the simplest setting (assuming it is installed in the C:\C51 directory). Then copy the files in the crack directory in the software package to the C:\C51\Bin directory.
4. Section 4 Introduction to the functions and uses of each part of the Keil C51 toolkit
1. 1. C51 and A51
1. (1) C51
C51 is a C language compiler. Its usage is:
C51 sourcefile [compilation control instruction]
or
C51 @ commandfile,
where sourcefile is a C source file (.C). A large number of compile control instructions complete all the functions of the C51 compiler. Package control C51 output files C.LST, .OBJ, .I and .SRC files. Source file (.C) control, etc., see the detailed introduction in Part 5.
Commandfile is a connection control file whose contents include: .C source file and various compile control instructions. It has no fixed name. Developers can specify it according to their own habits. It is suitable for occasions with more control instructions.
2. (2) A51
A51 is an assembly language compiler. The usage is:
A51 sourcefile [compile control instructions]
or A51 @ commandfile,
where sourcefile is the assembly source file (.asm or .a51), and the use of compile control instructions is similar to other assemblers such as ASM language. You can refer to other assembly language materials.
Commandfile is similar to Commandfile in C51. It makes A51 easy to use and modify.
2. 2. L51 and BL51
1. (1) L51
L51 is a linker/locator provided by Keil C51 software package. Its function is to link and locate the compiled OBJ file with the library file to generate an absolute target file (.ABS). Its usage is:
L51 target file list [library file list] [to outputfile] [link control instruction]
or L51 @Commandfile
Multiple modules of the source program are compiled by C51 and A51 respectively to generate multiple OBJ files. When linking, these files are all listed in the target file list as input files. If they need to be linked with the library file (.LiB), the library file must also be listed after it. outputfile is the output file name. If missing, it is the first module name with the suffix .ABS. The link control instruction provides all control functions during linking and positioning. Commandfile is a connection control file. Its specific contents include the target file list, library file list, output file, and connection control command to replace the first cumbersome format. Since most target module library files have more than one, the second method is more common. The name of this file can also be specified by the user.
2. (2) Bl51
BL51 is also a connection/locator for the C51 software package. It has all the functions of L51. In addition, it has the following three special features:
a. It can connect and locate programs larger than 64kBytes.
b. With code domain and domain switching function (CodeBanking & Bank Switching)
c. Can be used for RTX51 operating system
RTX51 is a real-time multitasking operating system, which changes the traditional programming mode and does not even need to use the main() function. The development of microcontroller system software towards RTOS is a trend. This trend is more obvious and necessary for 186, 386 and 68K series CPUs. For 8051, because the CPU is relatively simple and the program structure is not too complicated, the role of RTX51 is not very prominent. Its professional version software PK51 software package does not even include RTX51Full, but only an RTX51TINY version of RTOS. RTX51 TINY is suitable for microcontroller systems without external RAM, so its application range is very narrow and will not be introduced in this article. Bank switching technology is rarely used and will not be introduced.
3. 3. DScope51, Tscope51 and Monitor51
1. (1) dScope51
dScope51 is a source-level debugger and simulator, which can debug programs generated by C51 compiler, A51 assembler, PL/M-51 compiler and ASM-51 assembler. It does not require a target board (for Windows, it can also connect to the target board through mon51), and can only perform software simulation, but it is powerful and can simulate the CPU and its peripheral devices, such as internal serial ports, external I/O and timers, etc., and can effectively test embedded software functions.
Its usage is:
DS51[debugfile][INIT(initfile)]
where debugfile is an 8051 file in Hex format, that is, the file to be debugged. It is optional and can be loaded with the load command after entering dScope51.
Initfile is an initialization file, which is loaded after starting dScope51 and before debugfile is loaded. It contains some dScope initialization parameters and commonly used debugging functions. The following is the content of a dScope.ini file (for dos):
Load ..\..\ds51\8051.iof
Map 0,0xffff
For dScope51 for Windows, you can directly enter with the mouse, and then use load to load the file to be debugged.
2. (2) The difference between tScope51
and dScope51 is that Scope51 must be accompanied by a target board. Currently, it can access the target board in two ways. (1) Through the EMul51 online emulator, tScope51 prepares a dynamic link file EMUL51.IOT for the emulator, but this method must be used with the emulator. (2) Through the Monitov51 monitoring program, this method is feasible. tScope51 has a special MON51.IOT connection program for accessing Monitor51. When using it, you can debug the target board through the serial port and the monitoring program.
The usage is:
TS51[INIT(file_name.ini)],
where file_name.ini is an initialization file.
After entering TS51, you must load the IOT file. There are two types available: MON51.IOT and EMUL51.IOT. For example, to load MON51.IOT:
Load.C:\C51\TS51\MON51.IOT CPUTYPE(80517)
Unfortunately, tScope51 only has a version for Dos.
3. (3) Monitor 51
Monitor51 is a monitoring program that communicates with the target board through the serial port of the PC. Monitor operation requires MON51 or dScope51 for Windows. The following section will give a more detailed introduction to Monitor51.
4. 4. Ishell and uVision
1. (1) Ishell for Dos
This is an IDE for Dos. Simply type Ishell in the command line to enter the environment. It is simple and convenient to use. Its command line has the same functions as the DOS command line. For a single-module project, you can directly compile and link it from the menu. For a multi-module project, you can directly compile and link it from the menu. Then use batch processing and BAT files to compile and link, and then use menu control to debug the program with dScope51 or tScope51. Because it is for dos, it will not be introduced in detail.
2. (2) uVision for Windows
uVision for Windows is a standard Windows application. It is an integrated software development platform for C51. It has functions such as source code editing, project management, and integrated make. It has a friendly human-computer interface and is easy to operate. It is the first choice for developers. For specific configuration and use, see Part 5.
2. Chapter 2 Detailed Explanation of Keil C51 Software Use
1. Section 1 Control Instructions for Keil C51 Compiler
The control instructions of the C51 compiler are divided into three categories: source file control class, target file control class, and list control class.
1. 1. Source file control class
NOEXTEND: C51 source files are not allowed to use ANSI C extension functions.
DEFINE (DF): Define preprocessing (in the C51 command line).
2. 2. Object file (Object) control class:
COMPACT LARGE SMALL Select compilation mode
DEBUG (DB) Contains debugging information for use by the simulator or dSCope51.
NOAMAKE (NOAM) Disable AutoMake information recording
NOREGPARMS Disable passing parameters using registers
OBJECTEXTEND (OE) Object file contains additional variable type information
OPTIMIZE (OT) Specify the optimization level
REGFILE (RF) Specify a register file for overall optimization
REGISTERBANK (RB) Specify a register bank name
SRC for absolute register access Do not generate an object file, only generate an assembly source file
Other controls are not commonly used.
3. 3. Listing file (listing) control class:
CODE (CD): add assembly list to the listing file
LISTINCLUDE (LC): display indude file
SYMBOLS (SB): the listing file includes a list of all symbols in the module
WARNINGLEVEL (WL): select the "warning" level
2. Section 2 Use of dScope51
1. 1. dScope51 for Dos
In general, dScope51 has the following features:
l High-level language display mode
l Integrated hardware environment simulation
l Single-step or "GO" execution mode
l Memory, register and variable access
l Watch expression value
l Function and signal function
The following is a detailed explanation of how to implement the above functions after entering dScope51 for Dos. dScope51 uses a drop-down menu format and window display control. There are four windows: language, serial, exe, and register. exe is the command line window, language is the program window, serial is the serial port window, and register is the register window.
1. (1) High-level language display mode
Click "View" in the main menu. The three commands "Highlevel", "Mixed" and "Assembly" in the first column display the loaded program in "high-level", "mixed level" and "assembly level" respectively for easy debugging.
2. (2) Integrated hardware environment simulation display
The "Peripheral" items in the main menu can display the status of the simulated hardware environment, including:
I/O Port: Displays the value of each I/O port. For 8031, the values of P1, P2, P3, P0 and pins in SFR are listed separately:
Interrupt: Displays whether the entry mode of the five interrupt sources is allowed, the priority and other interrupt status.
Timer: Displays the mode, initial value status of each timer/counter, etc.
int Message: Interrupt information is allowed. If it is allowed (“>>” appears), when the interrupt is requested, the interrupt source information is displayed. For example, when an interrupt occurs, it will display:
"interrupt Timer 0 occurred" etc.
A/D converter:
When the A/D converter status is not displayed, it will prompt "None".
Serial: Serial port information display, including serial port mode, baud rate, etc.
Other: Other devices, if it is 8031, it will display "None"
3. (3) Single step or "Go" execution
"F8" single step execution, "F5" full speed execution to breakpoint. Or select Trace in the main menu to execute single-step CPU in Go at full speed.
4. (4) Memory register and variable access
external memory management MAP menu: Set (set), cancel (reset), display (Display) to handle available storage space.
Modify Code code: ASM command
Memory display command: D Category is (X, D, I, B, C)
Modify memory command: E There are the following commands EB, EC, EI, EL, EF, EP
Complex data type display: Object command; used to display the contents of a structure or array. To make this command effective, the C51 compiler must have DB and OBJECTEXTEND.
Disassembly command: U
5. (5) The value of the "Watch" expression
has four items in the "Watch" column of the View menu: including defining Watch Point (Define), deleting Watch Point (remove, kill all), and automatic update options.
You can also use WS, WK and other commands instead. Let’s take a look at the “Expression” type in detail:
dScope51 can set up to 16 WtchPoint expressions at a time, which are displayed in the Watch Window. The expression can be a simple variable or a complex data type such as a structure, array, and pointer to a structure, for example:
>WS *ptime
>WS ptime→hour
>WS some_record[o], analog, etc.
6. (6) About .IOF files
After starting DS51, you must load the .IOF file to make the CPU and Peripheral items work. The use of this function is based on the different characteristics of the 8051 series CPUs. It loads the 8051 CPU hardware device simulation driver files. For example, the 8031CPU must load 8051.IOF in the DS51 directory.
2. 2. dScope for Windows
dScope for Windows has all the functions of dScope for DOS. In addition, it has the following obvious advantages:
(1) Standard Windows interface, easier and simpler to operate;
(2) Common operations are performed in dialog boxes instead of DOS line commands;
(3) Richer window resources: memory window, coverage analysis, and running status analysis window, which enhance the debugging function;
because dScope for Windows is powerful, the specific operation is described in detail in Chapter 8.
3. Section 3 Monitor51 and its use
1. 1. Hardware requirements for Monitor51
(1) The hardware system is a 51 series CPU;
(2) With 5K external program memory (starting from address O) to store Monitor51 programs;
(3) 256Bytes external data memory and 5K trace buffer. In addition, the external data memory must be large enough to accommodate all application code and data, and all external data memories must be von Neumann memories, that is, they can consistently access XDATA and Code space.
(4) A timer is used as a baud rate generator for the serial port;
(5) 6 bytes of free stack.
2. 2. Use of Mon51
There are three ways to use Mon51:
(1) Dos line command mode
, that is, first use install to configure MON51, then use MON51 to enter the Monitor state, and enable various commands to debug Monitor51.
(2) tScope51 mode,
start tScope51, load the MON51.IOT driver file in the TS51 directory, and communicate with the target board.
(3) dScope51 for Windows mode
, when selecting the CPU driver file, select "MON51.dll", then check the target board and enter the MON51 state.
3. 3. Configuration of MON51
(1) Configuration of MON51 for Dos,
run the install file (in the MON51 directory), different parameters can configure different hardware environments. INSTALL Serialtype [xdstastart[codestart[bank][PROMCHECK]]], for specific instructions, see the MON51 help file or user manual.
(2) Configuration of MON51 for Windows
When MON51.dll is enabled, the system will automatically check the target board connection. If the configuration is incorrect, the "Configuration" dialog box will pop up. Set the PC serial port, baud rate, etc. Click "Apply" to make it effective.
4. 4. Serial port connection diagram:
cross-connection between sender and receiver, direct connection of RTS and CTS, direct connection of DSR and DTR. For specific pin arrangement, refer to the serial port documentation.
5. 5. MON51 commands and usage For
detailed MON51 commands, please refer to the help.
4. Section 4 Use of Integrated Development Environment (IDE)
1. 1. Use of Ishell for Dos
After entering Ishell, you will see two windows: one is the file window and the other is the Dos command line window. Above the window is a drop-down command menu, in which Files controls the visibility of the file window.
The first step in using Ishell is to configure the system, which means learning how to modify and create two files:
1. (1) Ishell.CFG file.
Each project has an Ishell.CFG file, which contains some information under the Option menu and Setup menu; Bell enabled, Monochrome enabled, Editor Selected, CRT Lines, target enviroment, name of user edit, Automatic load for configuration enabled, file window enabled, file specification for file window, translate command line controls, project name, etc.
The above information must be set for each project, and then save the setup file to start the following work.
2. (2) IShell.col file.
For IDE color settings, if not changed, you can use the default.
3. (3) CDF file
This file is located in the BIN directory. Each file defines a set of external function toolkits, that is, defines external environments such as 8051.CDF, USER.CDF, etc. Developers can modify CDF files for their own use. As for the content of CDF files, you can check 8051.CDF to know. Note that .CDF files are the core of the Ishell system. Different CDF files can make this IDE suitable for different compilation and connection systems, that is, this IDE is not only suitable for C51. Let
's talk about the Automake tool:
C51's Automake is a project manager. In the 8051 toolkit, the information of a project is retained in the form of an OBJECT file. AutoMake uses this information to manage the project. Once a project is manually established, Automake can generate a new OBJECT. AutoMake uses this file to compile the modified files.
Automake supports C51, A51, L51/BL51, C166, A166, L166 and other compilers and connectors. Click Automake in the main menu to run this tool.
Ishell for Dos is relatively cumbersome to use, and it is recommended to use uVision for windows.
2. 2. Usage of uVision for windows
uVision is a standard windows application. Its compiling function, file handling function, project handling function, window function and tool reference function (such as A51, C51, PL/M41, BL51 dScope, etc.) are much stronger than Ishell for Dos.
uVision uses BL51 as a connector. Because BL51 is compatible with L51, all projects that can work under Dos can be connected and debugged in uVision.
uVision uses dScope for windows as a debugger. This debugger supports MON51 and system simulation. It is more powerful and easy to use than for DOS, and has powerful debugging functions.
Note:
(1) You must know how to use the items under the Option menu. A51, C51, PL/M51, and BL51 define the compilation and connection control instructions used by each file. dScope defines a dScope initialization file. Make defines a make file.
(2) To enter debugging, run dScope under the RUN menu.
(3) Project includes new creation, opening, modifying, updating, compiling, linking and other project processing. For specific usage, please refer to the following examples.
3. Chapter 3 Keil C51 vs Standard C
In-depth understanding and application of C51's extension of standard ANSI C is one of the keys to learning C51. Because most of the extended functions are directly aimed at the 8051 series CPU hardware. There are roughly the following 8 categories:
l 8051 storage type and storage area
l Storage mode
l Memory type declaration
l Variable type declaration
l Bit variable and bit addressing
l Special function register (SFR)
l C51 pointer
l Function attribute
The specific description is as follows (8031 is the default CPU).
1. Section 1 Keil C51 Extended Keywords
C51 V4.0 version has the following extended keywords (19 in total):
_at_ idata sfr16 alien interrupt small
bdata large _task_ Code bit pdata
using reentrant xdata compact sbit data sfr
2. Section 2 Memory Areas:
1. 1. Pragram Area:
The Code indicates that there can be up to 64kBytes of program memory
2. 2. Internal Data Memory:
The internal data memory can be described by the following keywords:
data: direct addressing area, the lower 128 bytes of the internal RAM 00H~7FH
idata: indirect addressing area, including the entire internal RAM area 00H~FFH
bdata: bit addressable area, 20H~2FH
3. 3. External Data Memory
The external RAM can be identified by the following keywords depending on the usage:
xdata: can specify up to 64KB of external direct addressing area, address range 0000H~0FFFFH
pdata: can access 1 page (25bBytes) of external RAM, mainly used in compact model.
4. 4. Special Function Register Memory
8051 provides 128Bytes of SFR addressing area, which can be bit-addressable, byte-addressable or word-addressable to control timers, counters, serial ports, I/O and other components. It can be described by the following keywords:
sfr: byte addressing, such as sfr P0=0x80; the address of the PO port is 80H, and the constant after "=" is between H and FFH.
sfr16: word addressing, such as sfr16 T2=0xcc; specifies the Timer2 port address T2L=0xcc T2H=0xCD
sbit: bit addressing, such as sbit EA=0xAF; specifies the 0xAF bit as EA, that is, interrupt enable
There may also be the following definition methods:
sbit 0V=PSW^2; (defining 0V as the second bit of PSW)
sbit 0V=0XDO^2; (same as above)
or bit 0V-=0xD2 (same as above).
This post is from 51mcu

Latest reply

Thank you so much!!!  Details Published on 2023-11-24 15:52
 

1379

Posts

0

Resources
2
 
3. Section 3 Storage Mode The storage mode determines the default storage area for variables, function parameters, etc. that do not have an explicit storage type. There are three types: 1. 1. Small mode All default variables and parameters are loaded into the internal RAM. The advantage is fast access speed, but the disadvantage is limited space. It is only suitable for small programs. 2. 2. Compact mode All default variables are located in a page (256Bytes) of the external RAM area. The specific page can be specified by the P2 port, described in the STARTUP.A51 file, or specified by pdata. The advantage is that the space is more spacious than Small, the speed is slower than Small, and faster than large. It is an intermediate state. 3. 3. Large mode All default variables can be placed in up to 64KB of external RAM area. The advantage is that the space is large and can store more variables, but the disadvantage is that the speed is slower. Tip: The storage mode is selected in the C51 compiler options. 4. Section 4 Storage Type Declaration The storage type of a variable or parameter can be specified by the default type specified by the storage mode, or it can be directly declared and specified by a keyword. Each type is described by: code, data, idata, xdata, pdata, for example: data uar1 char code array[ ] = "hello!"; unsigned char xdata arr[10][4][4]; 5. Section 5 Variables or Data Types C51 provides the following extended data types: bit Bit variable value is 0 or 1 sbit Bit variable defined from byte 0 or 1 sfr sfr byte address 0 to 255 sfr16 sfr word address 0 to 65535 The remaining data types such as: char, enum, short, int, long, float, etc. are the same as ANSI C. 6. Section 6 Bit Variables and Declarations 1. 1. Bit Type Variables Bit type variables can be used as variable types, function declarations, function return values, etc., and are stored in internal RAM 20H to 2FH. Note: (1) Functions described with #pragma disable and functions specified with "usign" cannot return bit values. (2) A bit variable cannot be declared as a pointer, such as bit *ptr; is wrong (3) There cannot be a bit array such as: bit arr[5]; is wrong. 2. 2. The bit addressable area 20H-2FH can be defined as follows: int bdata i; char bdata arr[3], then: sbit bito=in0; sbit bit15=I^15; sbit arr07=arr[0]^7; sbit arr15=arr^7; 7. Section 7 Keil C51 Pointer C51 supports general pointers (Generic Pointer) and memory pointers (Memory_Specific Pointer). 1. 1. General pointer The declaration and use of general pointers are the same as standard C, but the storage type of the pointer can also be specified at the same time, for example: long * state; is a pointer to a long integer, and the state itself is stored according to the storage mode. char * xdata ptr; ptr is a pointer to char data, and ptr itself is placed in the external RAM area. The data pointed to by the above long, char and other pointers can be stored in any memory. Generally, the pointer itself is stored in 3 bytes, which are the memory type, high offset, and low offset. 2. 2. The storage type is specified when the memory pointer is based on the pointer description, for example: char data * str; str points to the char data in the data area int xdata * pow; pow points to the int integer in the external RAM. When storing this kind of pointer, only one byte or two bytes are enough, because only the offset is needed. 3. 3. Pointer conversion is the conversion of pointers between the above two types: l When a memory-based pointer is passed as an actual parameter to a function that requires a general pointer, the pointer is automatically converted. l If the external function prototype is not declared, the memory-based pointer is automatically converted to a general pointer, resulting in an error, so please use "#include" to declare all function prototypes. l The pointer type can be forcibly changed. 8. Section 8 Keil C51 Function C51 function declaration has expanded ANSI C, including: 1. 1. Interrupt function declaration: The interrupt declaration method is as follows: void serial_ISR () interrupt 4 [using 1] { /* ISR */ } In order to improve the fault tolerance of the code, an iret statement is generated at the unused interrupt entrance to define unused interrupts. /* define not used interrupt, so generate "IRET" in their entrance */ void extern0_ISR() interrupt 0{} /* not used */ void timer0_ISR () interrupt 1{} /* not used */ void extern1_ISR() interrupt 2{} /* not used */ void timer1_ISR () interrupt 3{} /* not used */ void serial_ISR () interrupt 4{} /* not used */ 2. 2. General storage work area 3. 3. Select the general storage work area and declare it by using x, as shown in the example above. 4. 4. Specify the storage mode by small, compact and large, for example: void fun1(void) small { } Tip: All internal variables of the function specified by small use internal RAM. The key and frequently time-consuming places can be declared in this way to improve the running speed. 5. 5. #pragma disable is declared before the function and is only valid for one function. The function cannot be interrupted during the call. 6. 6. Recursive or reentrant function specifies a function that can be called in both the main program and the interrupt, which is prone to problems. Because 51 is different from PC, PC uses the stack to pass parameters, and internal variables other than static variables are all in the stack; while 51 generally uses registers to pass parameters, and internal variables are generally in RAM. When the function is reentered, the data of the last call will be destroyed. The following two methods can be used to solve the problem of function reentry: a. Use the aforementioned "#pragma disable" declaration before the corresponding function, that is, only allow the main program or interrupt to call the function; b. Describe the function as reentrant. As follows: void func(param...) reentrant; After compilation, KeilC51 will generate a reentrant variable stack, and then the method of passing variables through the stack can be simulated. Since reentrant functions are generally called by the main program and interrupts, interrupts usually use a different R register group from the main program. In addition, for reentrant functions, add the switch "#pragma noaregs" in front of the corresponding function to prohibit the compiler from using absolute register addressing, and generate code that does not depend on the register group. 7. 7. Specify the PL/M-51 function specified by alien. 4. Chapter 4 Keil C51 Advanced Programming This chapter discusses the following: l Absolute address access l C and assembly interface l Common files in the C51 software package l Segment name conversion and program optimization 1. Section 1 Absolute address access C51 provides three methods to access absolute addresses: 1. 1. Absolute macro: In the program, use "#include"You can use the macros defined therein to access absolute addresses, including: CBYTE, XBYTE, PWORD, DBYTE, CWORD, XWORD, PBYTE, DWORD For specific usage, please refer to absacc.h. For example: rval=CBYTE[0x0002]; points to address 0002h of program memory rval=XWORD [0x0002]; points to address 0004h of external RAM 2. 2. The _at_ keyword can be added directly after the data definition with _at_ const, but please note: (1) Absolute variables cannot be initialized; (2) Bit-type functions and variables cannot be specified with _at_. For example: idata struct link list _at_ 0x40; specifies that the list structure starts at 40h. xdata char text[25b] _at_0xE000; specifies that the text array starts from 0E000H. Tip: If the external absolute variable is an I/O port or other data that can change by itself, it needs to be described using the volatile keyword. Please refer to absacc.h. 3. 3. Connection positioning control This method uses the connection control instruction code xdata pdata \data bdata to control the "segment" address. If you want to specify a specific variable address, it is very limited and will not be discussed in detail. 2. Section 2 Keil C51 and assembly interface 1. 1. The interface method within the module is to use the #pragma statement. The specific structure is: #pragma asm assembly line #pragma endasm This method is essentially to tell the C51 compiler through asm and ndasm that the intermediate line does not need to be compiled into an assembly line. Therefore, there is SRC in the compilation control instruction to control the storage of these non-compiled lines. 2. 2. The interface between modules is relatively simple. Use C51 and A51 to compile the source files respectively, and then use L51 to connect the obj files. The key issue is the parameter passing between C functions and assembly functions. There are two parameter passing methods in C51. (1) Passing function parameters through registers. At most, only 3 parameters can be passed through registers. The rules are as follows: Number of parameters char int long, float General pointer 123 R7R5R3 R6 & R7R4 & R5R2 & R3 R4~R7R4~R7 R1~R3R1~R3R1~R3 (2) Passing through fixed storage area (fixed memory) This method passes bit type parameters to a storage segment: ? function_name?BIT Pass other types of parameters to the following segment: ? function_name?BYTE, and store them in the pre-selected order. As for where this fixed storage area is located, it is determined by the storage mode. (3) Function return value The function return value is always placed in the register, with the following rules: return type Registev Description bit Flag bit is returned by the specific flag bit char/unsigned char 1_byte pointer R7 Single byte is returned by R7 int/unsigned int 2_byte pointer R6 & R7 Double byte is returned by R6 and R7, MSB is in R6 long&unsigned long R4~R7 MSB is in R4, LSB is in R7 float R4~R7 32Bit IEEE format General pointer R1~R3 Storage type is in R3 High R2 Low R1 (4) SRC control This control instruction compiles the C file into an assembly file (.SRC). The assembly file can be renamed to generate an assembly .ASM file, and then compiled with A51. 3. Section 3 Common files in Keil C51 software package There are several C source files in the C51\LiB directory. These C source files play a very important role. With a slight modification, they can be used in your own dedicated system. 1. 1. Dynamic memory allocation init_mem.C: This file is the source code for initializing the dynamic memory area. It can specify the location and size of the dynamic memory. Only after using init_mem() can other functions such as malloc, calloc, realloc, etc. be called back. calloc.c: This file is the source code for allocating memory to an array. It can specify the unit data type and the number of units. malloc.c: This file is the source code for malloc, allocating a fixed size of memory. realloc.c: This file is the source code for realloc.c, and its function is to adjust the size of the currently allocated dynamic memory. 2. 2. C51 startup file STARTUP.A51 The startup file STARTUP.A51 contains the target board startup code. This file can be added to each project. As long as it is reset, the file will be executed immediately. Its functions include: l Define the internal RAM size, external RAM size, and reentrant stack position l Clear internal, external, or external memory in units of pages l Initialize the reentrant stack and stack pointer according to the storage mode l Initialize the 8051 hardware stack pointer l Hand over power to the main() function Developers can modify the following data to initialize the system Constant Name Meaning IDATALEN Length of internal RAM to be cleared XDATA START Specify the starting address of external RAM to be cleared XDATALEN Length of external RAM to be cleared IBPSTACK Flag that indicates whether the reentrant stack pointer in small mode needs to be initialized, 1 means required. The default value is 0. IBPSTACKTOP specifies the top address of the small mode reentrant stack. XBPSTACK specifies whether the large mode reentrant stack pointer needs to be initialized. The default value is 0. XBPSTACKTOP specifies the top address of the large mode reentrant stack. PBPSTACK specifies whether the Compact mode reentrant stack pointer needs to be initialized. The default value is 0. PBPSTACKTOP specifies the top address of the Compact mode reentrant stack. PPAGEENABLE P2 initialization enable switch PPAGE specifies P2 value PDATASTART The first address of the external RAM page to be cleared PDATALEN The length of the external RAM page to be cleared Tip: If you want to initialize P2 as the high-end address of the compact mode, you must: PPAGEENAGLE = 1, PPAGE is the value of P2, for example, to specify a page 1000H-10FFH, then PPAGE = 10H, and the connection must be as follows: L51PDATA(1080H), where 1080H is any value between 1000H and 10FFH. The following is a snippet of STARTUP.A51 code. The parts in red are often likely to need modification: ;------------------------------------------------------------------------------ ; This file is part of the C51 Compiler package ; Copyright KEIL ELEKTRONIK GmbH 1990 ;------------------------------------------------------------------------------ ; STARTUP.A51: This code is executed after processor reset. ; ; To translate this file use A51 with the following invocation: ; ; A51 STARTUP.A51 ; ; To link the modified STARTUP.OBJ file to your application use the following ; L51 invocation: ; ; L51, STARTUP.OBJ ; ;------------------------------------------------------------- ------------------------------- ; ; User-defined Power-On Initialization of Memory ; ; With the following EQU statements the initialization of memory ; at processor reset can be defined: ; ; ; the absolute start-address of IDATA memory is always 0 IDATALEN EQU 80H ; the length of IDATA memory in bytes. ; EQU0H; the length of XDATA memory in bytes. ; PDATASTART EQU 0H ; the absolute start-address of PDATA memory PDATALEN EQU 0H ; the length of PDATA memory in bytes. 8051 CPU. At minimum the memory space occupied from the C51; run-time routines must be set to zero. ;------------------------------------------------- -------------------------- ; ; Reentrant Stack Initilization ; ; The following EQU statements define the stack pointer for reentrant ; functions and initialized it: ; ; Stack Space for reentrant functions in the SMALL model. IBPSTACK EQU 0 ; set to 1 if small reentrant is used. IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highest location+1. ; ; Stack Space for reentrant functions in the LARGE model. XBPSTACK EQU 0 ; set to 1 if large reentrant is used. 1 if compact reentrant is used. PBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest location+1. ; ;-------------------------------------------- ---------------------------------- ; ; Page Definition for Using the Compact Model with 64 KByte xdata RAM ; ; The following EQU statements define the xdata page used for pdata ; variables. The EQU PPAGE must conform with the PPAGE control used ; in the linker invocation. ; PPAGEENABLE EQU 0 ; set to 1 if pdata object are used. PPAGE EQU 0 ; define PPAGE number. ; ;---------------------------------------------- -------------------------------- 3. 3. Standard input and output file putchar.c putchar.c is a low-level character Output subroutine, developers can modify and apply it to their own hardware system, such as outputting characters to CLD or LEN. Default: putchar.c outputs a character to the serial port. XON|XOFF is the flow control mark, and the line break character "\* n" is automatically converted to carriage return/line feed "\r\n". getkey.c The getkey function is a low-level character input routine that can be used in your own hardware system, such as matrix keyboard input. By default, characters are input through the serial port. 4. 4. Other files also include unique functions for Watch-Dog The target file generated by the C51 compiler is stored in In many segments, these segments are some units of code space or data space. A segment can be relocatable or absolute. Each relocatable segment has a type and name. C51 segment names have The following rules apply: Each segment name consists of two parts: a prefix and a module name. The prefix indicates the storage type, and the module name is the name of the compiled module. For example: ? CO? main1: indicates the constant part of the code segment in the main1 module? PR? function1? module indicates the executable segment of function function1 in module module. For specific regulations, please refer to the manual. 2. 2. Program Optimization The C51 compiler is a compiler with optimization functions. It provides six levels of optimization functions to ensure the highest efficiency of the generated target code (the least code and the fastest running speed). The specific contents of the six levels of optimization can be found in Refer to the help. The following compiler control instructions are provided in C51 to control code optimization: OPTIMIZE (SJXE): Use subroutines as much as possible to reduce program code. NOAREGS: Do not use absolute register access, program code and register segment are independent. NOREGPARMS: Parameter passing is always It is implemented in the local data segment, and the program code is compatible with the lower version C51. OPTIMIZE(SIZE)AK OPTIMIZE(speed) provides 6 levels of optimization function, the default is: OPTIMIZE(6,SPEED). 5. Chapter 5 Keil C51 Library Function One of the important manifestations of C51's powerful functions and high efficiency is its rich library functions that can be directly called. Using more library functions makes the program code simple, the structure clear, and easy to debug and maintain. The following introduces the C51 library function system. .Section 1 Intrinsic routines and non-intrinsic routines The intrinsic functions provided by C51 refer to the fixed code directly inserted into the current line during compilation, rather than being implemented using ACALL and LCALL statements. This greatly improves the efficiency of function access, while non-intrinsic functions must be called by ACALL and LCALL. There are only 9 intrinsic library functions in C51. Although the number is small, they are all very useful. They are listed as follows: _crol_, _cror_: Circularly move a char type variable to the left (right) by a specified number of bits and return _iror_, _irol_: Circularly move an int type variable to the left (right) by a specified number of bits and return _lrol_, _lror_: Circularly move a long type variable to the left (right) by a specified number of bits and return _nop_: Equivalent to inserting NOP _testbit_: Equivalent to JBC bitvar testing the bit variable and jumping to clear it at the same time. _chkfloat_: Test and return the source point number status. When used, you must include #inclucleIf not specified, the library functions discussed below are all non-intrinsic library functions.
This post is from 51mcu
 
 
 

1379

Posts

0

Resources
3
 
2. Section 2 Several important library functions 1. 1. Special register include files For example, 8031 and 8051 are both REG51.h, which includes all 8051 SFRs and their bit definitions. Generally, the system must include this file. 2. 2. Absolute address include file absacc.h This file actually only defines a few macros to determine the absolute address of each storage space. 3. 3. Dynamic memory allocation function, located in stdlib.h 4. 4. Buffer processing function is located in "string.h", which includes copy, compare, move and other functions such as: memccpy memchr memcmp memcpy memmove memset This makes it very convenient to process the buffer. 5. 5. Input and output stream functions, located in "stdio.h". The stream functions read and write data through the serial port of 8051 or the user-defined I/O port. The default is the 8051 serial port. If you want to modify it, such as changing it to LCD display, you can modify the getkey.c and putchar.c source files in the lib directory, and then replace them in the library. 3. Section 3 Keil C51 library function prototype list 1. 1. CTYPE.H bit isalnum(char c); bit isalpha(char c); bit iscntrl(char c); bit isdigit(char c); bit isgraph(char c); bit islower(char c); bit isprint(char c); cii(char c); bit toint(char c); char tolower(char c); char __tolower(char c); char toupper(char c); char __toupper(char c); 2. 2. INTRINS.H unsigned char _crol_(unsigned char c,unsigned char b); char _chkfloat_(float ual); unsigned int _irol_(unsigned int i, unsigned char b); unsigned int _iror_(unsigned int i, unsigned char b); unsigned long _irol_(unsigned long l, unsigned char b); unsigned long _iror_(unsigned long L, unsigned char b); void _nop_( void); bit _testbit_(bit b); 3. 3. STDIO.H char getchar(void); char _getkey(void); char *gets(char * string,int len); int printf(const char * fmtstr[,argument]…); char putchar(char c); int puts (const char * string); int scanf(const char * fmtstr.[,argument]…); int sprintf(char * buffer,const char *fmtstr[;argument]); int sscanf(char *buffer,const char * fmtstr[,argument]); char ungetchar(char c); void vprintf (const char *fmtstr,char * argptr); void vsprintf(char *buffer,const char * fmtstr ,char * argptr); 4. 4. STDLIB.H float atof(void * string); int atoi(void * string); long atol(void * string); void * calloc(unsigned int num,unsigned int len); void free(void xdata *p); void init_mempool(void *data *p,unsigned int size); void *malloc (unsigned int size); int ran d(void); void *realloc(void char *src); int strcspn(char *src,char * set); int strlen (char *src); char *strncat (char 8dest,char *src,int len); char strncmp(char *string1,char *string2,int len); char strncpy (char *dest,char *src,int len); char *strpbrk (char *string,char *set); int strpos (const char *string,char c); char *strrchr (const char *string,char c); char *strrpbrk (char *string,char *set); int strrpos (const char *string,char c); int strspn(char *string,char *set); 6. Chapter 6 Keil C51 Example: Hello.c Hello is located in the \C51\exempls\Hello\ directory. Its function is to output "Hello, world" to the serial port. The whole program is as follows: #pragma DB OE CD #indule #include void main(void) { SCOn=0x50; TMOD=0x20 TH1=0xf3; Tri=1; TI=1; printf("Hello,world \n"); while(1) { } } 1. Section 1 Steps for using uVision for Windows (1) Use file_new to create a new file named hello.c, enter the above content or directly use the source file in the directory. (2) Use file_save or the toolbar to save the file. (3) Use project_new to create a project named hello and add hello.c to it. At this time, the project is already open, or use open project to open an existing project. (4) Select at least two DB OEs in option_C51 compiler. (5) Select option_dscope Debugger to check hello\DS51.INI to see if DS51.INI is: "load…\…\BIN\8051.DLL map 0, 0xffff" If not, modify it. (6) Select the make file order in option_make. (7) Select Build project in project to see if there are any syntax errors. If not, generate a HEX file. If yes, modify the source file and repeat the above steps. (8) After entering dScope51 with run_dScope debugger, load hello and run it directly with go to see if there is any output in the serial window. Normally, each time the system runs once, a "Hello, world" will appear in the serial window, indicating that the operation is correct. 2. Section 2 Ishell for Dos usage steps (1) Enter Ishell and use Setup editor to select the editor. Then click Edit or use the Edit command to edit the hello.c source file and save it. You can also directly select hello.c in the files window. (2) Use cd to change the project directory to the hello directory. (3) Select 8051 in setup_target. (4) Output DB OE in setup_C51. (5) Enter the project name hello in setup_project. (6) Save the Ishell.CFG file in setup_save. (7) Edit a Link file hello.lin with a line "hell.obj". (8) With the cursor on Hello.c in the files menu, click "translate". If there is no syntax error, click "link" to generate a Hex file. (9) Click Simulate. If Simulate is selected as dScope in 8051.CDF, enter the dScope debugging and directly click "Go". The serial window outputs "Hello.world". (10) If there is an error in the program, you do not need to translate or link after modifying the source code. Just Amake is enough. If the project includes more than one file, you cannot use Translate to compile in Ishell of DOS. Instead, you should create a bat file, compile directly in the command window, and then link it. If you still need to use Translate, you can only compile multiple files separately and then link them. 7. Chapter 7 Code Efficiency of Keil C51 The efficiency of C51 program compilation to generate assembly code is determined by many factors. For Keil C51, it is mainly affected by the following two factors: 1. Section 1 The influence of storage mode The storage mode determines the storage space of the default variable, and the complexity of the assembly code to access the variables in each space determines the code rate. For example: if an integer variable i is placed in the memory space 18H and 19H, the ++i operation is compiled into four statements: INC 0x19 MOV A,0x19 JNZ 0x272D INC 0x18 0x272D: If it is placed in the external memory space 0000H and 0001H, the ++i operation is compiled into nine statements: MOV DPTR, 0001 MOVX A, @ DPTR INC A MOVX @ DPTR, A JNz #5 MOV OPTR, #0000 MOVX A, @ DPTR INC A MOVX @ DPTR, A As far as the statements after assembly are concerned, the code rate of the operation on the external memory is much lower than that of the internal memory, and the generated statements are more than twice the memory. There are a large number of such operations in the program, which shows that the storage mode affects the code rate. Therefore, the principle of program design is 1. The storage mode is selected from small-compact-large in sequence. If there are too many variables, the large mode is selected. 2. Even if the large mode is selected, it is best to put some commonly used local variables or variables that can be placed in memory in memory to maximize the code rate of the program. 2. Section 2 The influence of program structure The structural units of the program include modules, functions, etc. For the same function, if the structure is more complex, it involves more operations, variables, functional modules and functions, etc., and the code rate is naturally much lower than that of a program with good structure and simple code. In addition, the program's running control statements are also key factors affecting the code rate. For example, many compilers translate switch-case statements into very complex ones, and Keil C51 is no exception. The relatively simple Switch-case statement is compiled into a jump instruction form, and the code rate is high, but for a more complex Switch-Case, a system library function ?C?ICASE must be called for processing, which is very complicated. For example, if(), while(), etc. statements are also relatively low-code statements, but after compilation, they are much higher than switch-case. Therefore, it is recommended that designers use switch-case and other statements as little as possible to control the program structure to improve the code rate. In addition to the above two points, other factors will also affect the code rate, such as: whether to use registers to pass parameters, that is, the NOAREGS option, whether to include debugging information: that is, the DEBUG option, whether to include extended debugging information: that is, BJECTEXTEND 8. Chapter 8 Detailed Explanation of Using dScope for Windows 1. Section 1 Overview 1. 1. Mainframe Window You can set various other debugging windows, set breakpoints, watch points, modify address space, load files, etc.; 2. 2. Debug Window (DEBUG Window) Supports various display modes of user programs, can run continuously, run user programs in single steps, and can assemble online; 3. 3. Command Window (Command Window) Supports the input of command lines; 4. 4. Watch Window (Watch Window) You can set the variables and expressions to be observed; 5. 5. Register Window (Registe Window) Displays the contents of internal registers, the number of times the program is run, etc.; 6. 6. Serial Port Window (Serical Windows) Displays the data received and sent by the serial port; 7. 7. Performance Analysis Window displays the CPU space occupied by each program segment to be observed; 8. 8. Memory Window displays the data in the selected memory; 9. 9. Symbol Browser Window displays various symbol names, including proprietary symbols, user-defined symbols (function names, variables, labels), etc.; 10. 10. Call Stack Window dynamically displays the function call relationship of the currently executed program segment; 11. 11. Code Coverage Window provides the ratio of executed code in each program segment in the current module; 12. 12. Peripherals Window displays the status of peripheral devices such as I/O ports, timers, interrupts, serial ports, etc. 2. Section 2 Basic Operations of dScope for Windows 1. 1.Specify the initialization file. Specify the dScope initialization file in the uVision Option menu dScope Debugger. Use uVision's RUN to start dScope, which will automatically load this initialization file and execute the commands in it. The following is an example, showing the process of calling in a debugging code. Ds51.ini: load 8051.dll load test slog>>test.log xtal=11.0592 define button "go to main","g,main" ws RevCounter ws rm.r g,main PA RESET PA serial PA timer0 2. 2. Method 1 for observing variables: command line WS expression [, numberbase ] [ LINE ] Where numberbase is the display number system, 10 corresponds to decimal, 16 corresponds to hexadecimal, and the default is hexadecimal. LINE is single-line display, and the default is multi-line display. Method 2: setup->Watchpoints, enter the variable in the dialog box 3. 3. Display the value of RAM di(x,d): start address, end address d variable name 4. 4. Observe the stack View->Call-stack->Show invocation, you can track the calling process; 5. 5. Interrupt handler debugging After loading 8051.dll, Peripheral will be added to the main menu of dScope, which has 4 word menus: I/0 port: Pi port status Interrupt: interrupt setting Timer: timer interrupt status Serial: serial port interrupt status Setting the corresponding interrupt request flag can generate an interrupt. 6. 6. Performance Analysis (Performance Analyzer: PA) PA is used to analyze the percentage of CPU occupied by a section of code execution. Definition: Command line PA func_name 3. Section 3 dScope for Windows Command File Compilation In addition to debugging in the command line mode, dScope can also collect various debugging commands in a debugging file, and then call the file to achieve the purpose of automatically testing the user's source code. dScope's command files support the C/PL/M format, so compiling debugging command files is somewhat similar to compiling C language programs. 1. 1. Address space and address space type 1. (1) Address space segmentation The maximum available space provided by dScope is 16M. In fact, we only use the following three segments: ① Internal data space segment (0X00 segment or D segment) 0X00:0X0000~0X00:0XFFFF (for MSC51, it is 0X00:0X00FF) ② External data space segment (0X01 segment or X segment) 0X01:0X0000~0X01~0XFFFF ③ Program space segment (0XFF segment or C segment) 0XFF:0X0000~0XFF:0XFFFF 2. (2) Address space type C: Code space D: Internal direct addressing space I: Internal indirect addressing space X: External data space B: Bit addressing space P: I/O port EB: Extended bit addressing space (MCS251 exclusive) ED: Extended data space (MCS251 exclusive) CO: Constant space (MCS251 exclusive) HC: Normal constant space (MCS251 exclusive) 2. 2. Constants dScope supports hexadecimal, octal, decimal, and binary constants, with suffixes H, Q (O), T (or none), and Y respectively; dScope does not distinguish between uppercase and lowercase constants. 1. (1) Integer constants are divided into integer (int), unsigned integer (uint, 00rd), long integer (long), and unsigned long integer (Wlong, Word). 2. (2) Floating-point constants are the same as ANSI C. 3. (3) String constants are the same as ANSI C. 4. (4) Character constants are divided into character type (Char) and unsigned character type (Uchar). 5. (5) Line number constant refers to the line number in the user program, which is actually an address. 6. (6) Bit constant: 0 and 1 7. (7) Address constant There are many types of address constants. Address constants are different from line number constants. Line number constants are just addresses, and when an address number is referenced, it actually takes the data at that address. C: code address constant, such as C: 0X0012 or 0XFF:0X0012 D: internal direct addressing address constant, such as D: 0X0068 or 0X00:0X0068 I: internal inter-addressing address constant, such as I: 0X0010 or 0X00:0X0010 X: external data space address constant, such as X: 0X0028 or 0X01:0X0028 B: bit address constant, such as B: 0X20 or B:0X24.0 EB: extended bit address constant (MCS251 proprietary), ED: extended data space address constant (MCS251 proprietary) CO: constant space address constant (MCS251 proprietary) HC: normal number space address constant (MCS251 proprietary) 8. (8) Identifier constants, i.e., labels and function names in user source programs, actually represent a certain address. 9. (9) Constants defined in user source programs 3. 3. Variables The variable names or identifiers supported by dScope can be composed of up to 31 characters. The first letter is A-Z, a-z, underscore or question mark. Subsequent characters can be letters, numbers, underscores and question marks. Except for CPU variables and system variables, dScope does not support global variables, but variables defined by the "define" command can be considered global variables. The variables supported by Dscope are divided into the following types (variable names are not case-sensitive), and type conversion is supported: 1. (1) Integer variables are divided into integer variables (int), unsigned integer variables (uint/word), long integer (Long), and unsigned long integer (Ulong/dword). 2. (2) Floating-point variables (float) are the same as ANSI C. 3. (3) Character variable L It is divided into character type (char) variable and unsigned character type (Uchar) 4. (4) Bit variable (Bit) 5. (5) System variable dScope defines a series of internal variables. Users can read or read/write these variables. They can be referenced by user-defined numbers. a. Cycles (Read Only) 32-bit variable (Ulong), indicating the instruction cycles (cycle) spent by the current program execution. b. Ramsize (R/W) 16-bit variable (Uint), indicating the size of the internal directly addressable data space. c. Radix (R/N) 8-bit variable (Uchar), determines the output number system Radix=0X0A (decimal), Radix=0X10 (hexadecimal) d. -IIP- (R/W) 8-bit variable (Uchar), indicating the current number of interrupt nesting. e. $ (R/W) 32-bit variable (Ulong), indicates the PC value. By writing to it, the program execution flow can be changed. f. Itrace (R/W) 8-bit variable (Uchar), determines whether to record the program running status Itrace=1, enables the recording operation Itrace=0, basically records the operation g. __Break__ (R/W) 8-bit variable (Uchar) __Break__=1, terminates the program running h. __Mode__ and __Frame size__ are variables exclusive to MCS 251. 6. (6) CPU variables, namely R0~R7, A, C (bit variables), B, DPTR and special function register variables, all of which can be read and written. 7. (7) Variables, arrays, structures, etc. defined in the user source program 4. 4. Operators dScope supports ANSI C operators, including arithmetic operators, logical operators, and relational operators. 5. 5. Expressions The constants, variables, functions, etc. supported by dScope are connected together with operators to form dScope expressions. 6. 6.Arrays dScope does not support defining arrays in command files, but can reference arrays in user programs in the same way as C. 7. 7. Structures and Unions dScope does not support defining structures and unions in command files, but can reference structures and unions in user programs in the same way as C. However, if you want to output the result of the entire structure or union, you must use the command "OBJ". 8. 8. Pointers: Pointers cannot be customized, but pointer variables in user source programs are supported. 9. 9. dScope Command Statements dScope provides a series of debugging commands. In command files, dScope only supports these statements and the expressions defined above. C language statements are not supported. However, C statements are supported in user-defined functions (not functions in user source programs) included in command files. However, arrays, structures, unions and pointers are not supported in user-defined functions. 1. (1) ASM online assembly command, the format is as follows: ASM C: 0Xnnnn (or label); set the address of the inserted assembly instruction ASM assembly instruction After the ASM assembly instruction is inserted, select "Assemble->Assemble" in the debug window to complete the compilation. 2. (2) Assign serial port assignment command, the format is as follows: Assign channeloutreg for MCS51 is: Assign WinSoot But the current version of dScope does not provide complete serial port window functions. 3. (3) Define user-defined variable command, the format is as follows: Define <type> <variable name> Type 1 is the variable type as described above. The variable defined by the Define command may be a global variable and can be referenced by a user-defined function. 4. (4) Display memory display command, the format is as follows: D start address, end address address as the address constant and identifier constant as described above. 5. (5) Enter memory modification command, the format is as follows: E type address = expression [expression 2], [……] type as described above, address as the address constant as described above. The expression is as described above, but if it is a function name (including labels and pointer variables), the keyword E→EP 6. (6) Map/Reset map Map is a memory segment modification command, and Reset map resets the memory segment or the default value. 7. (7) Object is used to reference the structure (union) and array in the user source program, the format is as follows: Obj expression [n,], [Line] The expression is the array and structure (union) name in the user source program. When Line is missing, the content of the number and structure (union) is output in n lines; if Line is present, it is output in a single line. 8. (8) U Disassembly command, the format is as follows: U [address] The address includes address constants and identifier constants, indicating the starting address of disassembly. 9. (9) WK Watchpoint deletion command, the format is as follows: WK n1[n2], [……]; delete the specified watchpoint, n is a character type, integer constant WK *; delete all watchpoints 10. (10) WS Watchpoint setting command, the format is as follows: WS expression [,n][LINE] When the keyword LINE exists, the watchpoint expression is output in a single line. When LINE is missing, the watchpoint expression is output in n lines. 11. (11) G Continuous operation command, the format is as follows: G [starting address], [ending address] The address is an identifier constant or an address constant. When the address is missing, it is a continuous operation. 12. (12) T/P single-step run command, the format is as follows: T/P n; n refers to the number of steps to a single line run, P refers to when the user calls a function, it is treated as a step, and does not enter the function run. 13. (13) PA performance analysis operation command, which is divided into the following types: PA displays the current performance analysis level segment PA Kill It can't be typed in by myself! It would be great if this was a separate document~~ It would be a KEIL application guide.
This post is from 51mcu
 
 
 

7815

Posts

57

Resources
4
 
I didn't type it myself! It would be great if this was a separate document~~ It would be a KEIL application guide.
This post is from 51mcu
 
Personal signature

强者为尊,弱者,死无葬身之地

 
 

2

Posts

0

Resources
5
 
If only it were documentation.
This post is from 51mcu
 
 
 

12

Posts

0

Resources
6
 
Thank you
This post is from 51mcu
 
 
 

58

Posts

0

Resources
7
 

Thank you for sharing. It is not easy to publish so much content. Thank you.

This post is from 51mcu
 
 
 

718

Posts

0

Resources
8
 

Basic knowledge of Keil C51 development system, a long article!

Thanks for publishing! Let’s improve together!

This post is from 51mcu
 
 
 

205

Posts

0

Resources
9
 

Basic knowledge of Keil C51 development system. It will be more readable if the layout is clear and the structure is clear.

This post is from 51mcu
 
 
 

69

Posts

0

Resources
10
 

Thanks!!!!!!!!!!!!!!!

This post is from 51mcu
 
 
 

1

Posts

0

Resources
11
 
Thank you so much!!!
This post is from 51mcu
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list