Keil C51 Development System Basic Knowledge - 1

xiaoxiao2021-03-06  60

Basic knowledge of Keil C51 development system

1. The first system overview

Keil C51 is a 51-series compatible microcontroller C language software development system produced by the US Keil Software. Compared to assembly, C language has a significant advantage in terms of functionality, structural, readability, and maintainability, and is easy to use. . After using the assembly language, use C to develop, and experience more profound.

Keil C51 software offers a rich library function and powerful integrated development debugging tool, all Windows interface. In addition, it is important to see the compiletable code generated after compiling, you can experience the efficiency of the target code generated by Keil C51 very high, and the assembly code generated by most statements is compact and easy to understand. The advantage of high-level languages ​​can be reflected when developing large software.

The following details of the KEIL C51 development system is described in detail.

2. The holistic structure of the second section Keil C51 single-chip microcomputer software development system

The overall structure of the C51 kit, as shown in Figure (1), where uvision and iShell are the integrated development environment (IDE) of C51 for Windows and For DOS, respectively, and can complete the entire development process of editing, compiling, connection, debugging, simulation. . Developers can edit C or assemble source files with IDE itself or other editor. The target file (.Obj) is then compiled by the C51 and A51 compiler, respectively. The target file can create a library file by lib51, or a library file can be locked by the L51 connection to generate an absolute target file (.ABS). The ABS file is converted into a standard HEX file by OH51, which is used for the debugger DSCope51 or Tscope51 to use the source code level debug, or the simulator can be commissioned directly to the target board, or directly write the program memory such as EPROM.

Figure (1) C51 Toolkin Overall Structure

3. Installation of the third section of the KEIL C51 toolkit

1. 1. C51 for DOS

DOS / C51DOS.EXE in the package under Windows and select the installation directory. After completing, you want to make the system to do the following (set C: / C51 for installation directory):

Modify autoexec.bat, join

PATH = C: / C51 / BIN

SET C51LIB = C: / C51 / LIB

SET C51INC = C: / C51 / INC

Then run autoexec.bat

2. 2. Installation and precautions for C51 for Windows:

In Windows Running Win / Setup.exe in the package, it is best to choose the installation directory as the C51 for DOS, which is the simplest (set up in the C: / C51 directory). Then copy the files in the CRACK directory in the package into the C: / C51 / bin directory.

4. Introduction to the various features and use of KEIL C51 toolkit

1. 1. C51 and A51

1. (1) C51

The C51 is a C language compiler, which is:

C51 Sourcefile [Compilation Control Directive]

or

C51 @ CommandFile

Where SourceFile is a C source file (.c). A large number of compilation control instructions complete all the functions of the C51 compiler. Package C51 output file C.LST, .Obj, .i and .SRC file control. For the control of the source file (.c), see the specific introduction of the fifth part.

CommandFile is a connection control file whose content includes: .c source files and compilation control instructions, there is no fixed name, developers can specify according to their habits, it is suitable for more control instructions.

2. (2) A51

A51 is a compiler language compiler with method:

A51 SourceFile [Compilation Control Directive]

Or A51 @ commandfile

Sourcefile is a compilation source file (.asm or .a51), the use of compilation control instructions is similar to other assembly, such as ASM languages, and can refer to other assembly language materials.

CommandFile is similar to Commandfile in C51, which makes A51 and modify it. 2. 2. L51 and BL51

1. (1) L51

The L51 is the connection / locator provided by the Keil C51 package, which generates an absolute target file (.ABS) to generate an absolute target file (.ABS) with the library file connection to the library file connection.

L51 target file list [Library list] [to outputfile] [Connection Control Directive]

Or L51 @commandfile

Multiple modules of the source program are compiled by C51 and generate multiple OBJ files. When connected to the A51, these files are listed in the list of target files, as input files, if necessary to connect with the library file (.lib), then The library file must also be listed there. OutputFile is the file name, the first module name is missing, the suffix is ​​.abs. Connection control instructions provide all control functions when connectivity. Commandfile is a connection control file, which includes the list of target file lists, library file lists, and output files, connection control commands, to replace the first cumbersome format, because the target module library file is mostly more than 1, and the second The method is more common, and this file name can also be specified by the user.

2. (2) BL51

The BL51 is also a connection / positioner of the C51 package, which has all the functions of L51, and it has the following 3 points:

a. Can connect to a program that is larger than 64kBytes.

b. Codeban and domain switching function (CodeBanking & Bank Switching)

c. Can be used in the RTX51 operating system

RTX51 is a real-time multi-task operating system that changes traditional programming mode, and does not have to use main () functions, single-chip system software is a trend to RTOS, this trend is more obvious for the 186 and 386 and 68k series CPUs. And must, the 8051 is less simple due to the CPU, the program structure is less complicated, and the RTX51 effect is not high, its professional software PK51 software package does not include RTX51full, and only one RTX51tiny version of RTOS. RTX51 Tiny is suitable for single-chip microcontroller systems without external RAM, and thus the use surface is narrow, in this article. Bank Switching technology is not introduced for use.

3. 3. DSCOPE51, TSCOPE51 and Monitor51

1. (1) DSCOPE51

DSCope51 is a source debugger and an emulator that debugged by a C51 compiler, A51 assembler, PL / M-51 compiler, and ASM-51 assembler. It does not need the target board (for Windows can also pass the MON51 to pick up ", only software simulation, but its function is powerful, can simulate CPUs and its peripherals, such as internal serial ports, external I / O and timer, etc. Effective testing of embedded software functions.

The method of use is:

DS51 [Debugfile] [INIT (INITFILE)]

Where debugfile is an 8051 file in the HEX format, that is, the file to be debugged is optional, which can be loaded with the load command after entering the DSCope51.

INITFILE is an initialization file, which is loaded before the DSCope51 is launched, and there are some of the initial debugging parameters of DSCope, and the common debug functions. Below is a DSCope.ini file (for dos) content:

Load ../../ds51/8051.iof

Map 0,0xffff

DSCope51 for Windows uses the mouse to enter, then load the to-adjustment file with LOAD.

2. (2) Different from TSCope51 and DSCope51 that scope51 must have a target board, which can be accessed in two ways. (1) The emulator by the Emul51, TSCope51 prepares a dynamic connection file Emul51.iot for the emulator, but the method must cooperate with the emulator. (2) Through the MONITOV51 monitor, this method is feasible, TSCope51 is specifically with MON51.iot connection programs for accessing Monitor51, and can debug the target board when used.

The method of use is:

TS51 [INIT (file_name.ini)]

Where file_name.ini is an initialization document.

After entering TS51, you must be loaded with an IoT file, available in Mon51.iot and Emul51.iot, such as loading mon51.iot:

Load.c: /c51/ts51/mon51.iot cputype (80517)

Unfortunately, Tscope51 is only the version of For DOS.

3. (3) Monitor 51

Monitor51 is a monitor that communicates with the target board through the PC. The Monitor operation requires MON51 or DSCOPE51 for Windows, and the back section will be more detailed in Monitor51.

4. 4. ISHELL and UVISION

1. (1) Ishell for DOS

This is a for DOS IDE, typing iShell directly on the command line, then entering the environment, it is easy to use. Its command line has the same feature with the DOS command line, and the Project of the single module is directly connected by the menu, and the multi-module's Project. The compilation connection is compiled by batch, the BAT file is compiled, and then debug the program by menu control, because it is for DOS, not too detailed.

2. (2) Uvision for Windows

Uvision for Windows is a standard Windows application. It is a integrated software development platform of C51. It has a source code editing, Project Management, Integrated make, and other features. Its human-machine interface is friendly, easy to operate, is the preferred by developers , Specifically configure and use the fifth part.

2. Chapter 2 Keil C51 software use details

1. Control instruction of the first KEIL C51 compiler

The control instruction of the C51 compiler is divided into three categories: source file control class, target file control class, and list control class.

1. 1. Source file control class

The NOEXTEND: C51 source file is not allowed to use ANSI C extension.

Define (DF): Defines the prerequisite (at the C51 command line).

2. 2. Target file (Object) Control class:

Compact Large Small Select Compilation Mode

Debug (dB) contains debugging information for use in the simulation device or DSCope51.

NoAmake (Noam) Prohibits Automake Information Record

NOREGPARMS Prohibits Register Parameters

ObjectExtendEndend (OE) Object file contains additional variable type information

Optimize (OT) specified level of optimization

Regfile (RF) Specifies the file used by a register for overall optimization

RegisterBank (RB) Specifies a register area name for absolute register access

SRC does not generate a target file only generates a post source file

Other controls are not commonly used.

3. 3. List file (LISTING) Control class:

Code (CD): Add a list of compilation to the list file

Listinclude (LC): Display Indude file

Symbols (SB): List files include lists of all symbols in the module

WARNINGLEVEL (WL): Select the "Warning" level

2. The use of the second section DSCope51

1. 1. DSCOPE51 for DOS

In general, DSCope51 has the following features:

l Advanced language display mode

l Integrated hardware environment simulation

l Single step or "go" execution mode

l Memory, registers and variables access

l Watch expression value

l function and signal function

Next, how to implement the above functions after entering the DSCope51 for DOS, the DSCope51 uses the drop-down menu format and window display control, there are four windows of Language, Serial, EXE, Register, where EXE is the command line window, and the language is the program window. Serial is a serial window, register is the register window.

1. (1) Advanced language display mode

Click "View" in the main menu, three commands "highlevel", "Mixed", "Assembly" in the first column, "high", "mixed grade" and "assembly" three in the first column The way is displayed for easy commissioning.

2. (2) Integrated hardware environment simulation display

"Peripheral" in the main menu shows the status of the analog hardware environment, where:

I / O Port: The value of each I / O port is displayed, and the P1, P2, P3, P0 of the SFR in the SFR is listed separately from the 8031:

Interrupt: Displays whether the inlet mode of 5 interrupt sources allows, priority, etc. interrupt state.

Timer: Displays the mode, initial value status of each timing / counter.

INT message: Interrupt information allows, if the application is allowed (">>", the interrupt source information is displayed when the application is interrupted. For example, when the interrupt occurs:

"Interrupt Timer 0 acured", etc.

A / D Converter:

The display A / D converter status is not time, prompt "None".

Serial: Serial port information display, including serial mode, baud product, etc.

Other: Other devices, such as 8031, display "None"

3. (3) Single Step or "Go"

"F8" single-step execution, "F5" is executed at full speed to breakpoints. Or in the selection of the main menu, the TRACE sections performs the GO full speed execution in the CPU.

4. (4) Memory register and variable access

External Memory Management MAP Menu: Setting (SET), Cancel (DIST), Display Processing Available Storage Space.

Modify Code code: ASM command

Memory display command: D category (x, d, i, b, c)

Modify the memory command: E has the following commands EB, EC, EI, EL, EF, EP

Complex data types display: Object command; content used to display structural or array. To make this command valid, the C51 compiler must have two DB and ObjectExtend.

Anti-assembly command: U

5. (5) "Watch" expression value

There are four items in the "Watch" column of the View menu: which includes definition Watch Point (Define), delete Watch Point, and automatic update options for the Watch Point (Remove, Kill ALL).

You can also replace the commands such as WS, WK, etc., the "Expression" type is specifically seen:

DSCope51 can set up up to 16 WTCHPOINT expressions, which are displayed in Watch Window, which can be simple variables, but also complex data types such as structures, arrays, and pointers, such as:

> Ws * ptime

> WS PTIME → HOUR

> WS Some_Record [O], Analog, etc.

6. (6) About .iof file

After starting the DS51, you must put the .iof file to make the CPU and Peripheral various features, which is based on the different characteristics of the 8051 series CPU, load 8051 each CPU hardware device to simulate driver files, such as 8031cpu must be loaded DS51 directory. The lower 8051.iof. 2. 2. DSCope for Windows

DScope for Windows has full features of DSCope for DOS, in addition, it has the following obvious advantages:

(1) The standard Windows interface is easier to operate;

(2) Common operation Multi-use dialog, not DOS's line command mode;

(3) Window resources are more abundant: memory window, coverage analysis, running status analysis window, strengthen debugging function;

Because the DScope for Windows is powerful, the specific operation is in detail in Chapter 8.

3. Section 3 Monitor51 and its use

1. 1. Monitor51 requirements for hardware

(1) The hardware system is 51 series CPU;

(2) With 5K external program memory (starting from the O address), store the Monitor51 program;

(3) 256Bytes external data memory and 5K tracking buffer, in addition, external data memory must accommodate all application code and data, and all external data storage must be von Nuiman memory, which can agree to XDATA and Code space.

(4) A timer is used as the baud rate generator;

(5) 6 Bytes' aerial stack.

2. 2. Mon51

There are three ways to use the MON51:

(1) DOS line command mode

That is, use install to configure the MON51, then use MON51 to enter the Monitor status, enable various commands to debug Monitor51.

(2) TSCOPE51 mode

Start TSCope51 Load the MON51.IOT driver file under the TS51 directory, communicate with the target board.

(3) DSCOPE51 for Windows Mode

When selecting a CPU driver file, select "MON51.DLL", check the target board and enter the MON51 status.

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 [xdstart "]]]]]]], specifically explained the MON51 Help file or manual.

(2) Configuration of MON51 for Windows

When MON51.DLL is enabled, the system automatically checks the target board connection. If the configuration is not correct, the "Configuration" dialog box will pop up, set the PC serial port, baud rate, etc., click "Apply" valid.

4. 4. Serial port connection diagram:

Transceiving cross interconnections, RTS, CTS direct connection, DSR, DTR direct connection, specific pins are arranged for reference serial data.

5. 5. MON51 command and use

Detailed MON51 commands can be referred to.

4. Use of the Group IV Integrated Development Environment (IDE)

1. ISHELL for DOS

After entering iShell, you see two windows: one is a file window, one is a DOS command line window, and the window is a drop-down command menu, where the Files control file window is remarkable.

Using iShell, the first step is to configure the system, that is, learn the modification and creation of two files:

1. (1) ishell.cfg file

Every Project has an ishell.cfg, where some of the "Option menu and some information under the 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. You must set the above information for each Project, then the "SAVE" of "setup" is stored so that you can officially start the following work.

2. (2) Ishell.col file

Setting the IDE color, if it does not change, it can be default.

3. (3) CDF file

This file is located in the bin directory, defines a set of external function kits, which is the external environment such as 8051.cdf, user.cdf, etc., developers can modify the CDF file for yourself, as for the CDF file content to view it 8051.cdf can be found. Note that the .cdf file is the core of the iShell system. Different CDF files can make this IDE for different compilation, connection systems, that is, this IDE is not only suitable for C51.

Let's talk about Automake tools below:

The C51's Automake is a Project Manager that retains a project information in the 8051 toolkit in the object file. Automake uses this information to perform Project management, once manually established a project, Automake can generate a new object, Automake utilization This file is to compile those modified files.

Automake supports C51, A51, L51 / BL51, C166, A166, L166 and other compilation connectors. The autoMake in the main menu is running this tool.

Ishell for DOS is more cumbersome, recommended using uvision for windows.

2. 2. UVISION for Windows

UVision is a standard Windows application, its compilation function, file processing function, Project processing function, window function, and tool reference feature (such as A51, C51, PL / M41, BL51 DSCOPE, etc.) are much stronger than ISHELL for DOS. .

UVISION uses the BL51 as a connector because the BL51 is compatible with L51, so all Projects that can work under DOS can be connected to UVISION.

UVISION uses the DSCope for Windows modulator, which supports MON51 and system simulation. The function is powerful than for DOS, and the debug function is powerful.

note:

(1) The items under the Option menu are used, where A51, C51, PL / M51, BL51 define the compilation, connection control command used by each file, and DSCOPE defines a DSCope initialization file. Make is defining an Make file.

(2) Enter the debugging is to run the DSCope under the Run menu.

(3) PROJECT includes new, open, modified, updated, compiled, connected, and other POJECT processing, which can be used in the following examples.

3. Chapter 3 Keil C51 VS Standard C

In-depth understanding and applying C51 extension of standard ANSIC is one of the key to learning C51. Because most expansion features are directly for the 8051 series CPU hardware. There are roughly the following 8:

l 8051 storage type and storage area

l storage mode

l Memory type declaration

l Variable type declaration

L bit variables and bit addressing

l Special Function Register (SFR)

l C51 pointer

l The function attribute is specifically described below (8031 is the default CPU).

1. Section 1 KEIL C51 Extension Keyword

The C51 V4.0 version has the following extension keywords:

_AT_ Idata SFR16 Alien Interrupt Small

BDATA LARGE _TASK_ CODE BIT PDATA

Using Reentrant XData Compact Sbit Data SFR

2. Second section memory area:

1. Pragram area:

Program memory with up to 64kBytes by code

2. 2. Internal Data Memory:

Internal data memory is available in the following keywords:

Data: Direct addressing area, for internal RAM low 128 bytes 00h ~ 7FH

IDATA: Indirect addressing area, including the entire internal RAM area 00h ~ FFH

BDATA: can be placed in place, 20H ~ 2FH

3. 3. External Data Memory

External RAM uses the following keyword ID:

XDATA: You can specify how up to 64KB external direct addressing area, address range 0000H ~ 0FFFFH

PDATA: Access 1 page (25bbytes) external RAM is mainly used for compact model.

4. 4. Speciac Function Register Memory

8051 provides 128bytes SFR addressing area, which can be addressed, byte addressing or word addresses, configured to control timers, counters, serial ports, I / O, and other components, can be described by the following keywords:

SFR: byte addressing, such as SFR P0 = 0x80; is a constant between the PO port address of 80h, "=" H ~ FFH.

SFR16: Word Addressing, such as SFR16 T2 = 0xcc; specifies Timer2 port address T2L = 0xcc T2H = 0xcd

SBIT: bit addressing, such as SBIT EA = 0xAF; Specifies the 0xAF bit as EA, ie interrupt allowed

It can also be defined as follows:

SBIT 0V = PSW ^ 2; (Define 0V for PSW 2nd)

SBIT 0V = 0xDO ^ 2; (ibid)

Or Bit 0V- = 0xD2 (ibid).

转载请注明原文地址:https://www.9cbs.com/read-112805.html

New Post(0)