MCS51 debugging word and PDF references

Source: Internet
Author: User

Software:

Compiling keil720_newestProgramSoftware

Digital Display 1-8asm

HL-340 (USB to serial port)

Serial Communication


PDF

 

Word

 

Sst89e516rd and Keil software combined with simulation 51 microcontroller
The most important part of single-chip microcomputer experiment and development is program debugging. In my spare time, most people use the method of burning and writing chips directly to the target board for testing, however, this is troublesome in the case of program problems, and sometimes it is difficult to find out where the program problem occurs. In addition, you can use software simulation to debug the program. However, this method also has limitations. Sometimes, software simulation cannot completely replace the actual environment. Therefore, single-chip microcomputer simulators have become an important device for program debugging. However, in my spare time, very few people use high-price simulators. In order to solve this problem, this paper introduces a kind of simple 51 Single-chip Computer Simulator Based on MCS-51 architecture which is made by sst89e516rd of SST Corporation. It supports the chip compatible with MCS-51 architecture.

1. Introduction to single chip microcomputer sst89e516rd

Sst89e516rd is an 8-bit integrated memory 51 Series compatible single chip microcomputer, and 51 series single chip microcomputer software, development tools compatible, pin is also compatible.

The sst89e516rd chip contains two superflash EEPROM, which are 64 K main block (block0) and 8 K sub-block (block1 ). The address range of block0 is 127h ~ Ffffh; the address range of block1 is 10000h ~ 11 fffh. When the simulator is used, the block1 storage area is burned into the SoftICE simulation monitoring program.

Sst89e516rd has functions in application programmable (IAP) and in system programmable (ISP), where IAP is implemented through serial port.

The simulator uses the IAP function of sst89e516rd. Because sst89e516rd has two independent superflash program storage areas, when the monitoring program runs in the block1 storage area, you can rewrite the program in the block0 program storage area. This is the basic feature of the simulator.

The sst89e516rd pin is shown in Figure 1.

 

 

Ii. Circuit and working principle of the simulator

The single-chip sst89e516rd and the crystal oscillator circuit and reset circuit constitute the minimum single-chip microcomputer system. The sst89e516rd pin is connected to the 40-pin, and the 40-pin is inserted into the single-chip microcomputer socket of the target board during application. The simulator may use jumpers to select the crystal oscillator on the simulator or the crystal oscillator on the target board. The simulator uses the power supply on the target board. The working process of the simulator is to modify the program at any time during the debugging process to achieve single-step operation, cross-step operation, breakpoint operation, and full-speed operation. Single-Chip Microcomputer Program goals to be debugged during simulation using the integrated development environment of Keil μ vision2CodeIt is transmitted to the monitoring chip through the serial port, and is burned into the block0 program memory of the monitoring chip by the monitoring program. During simulation debugging, the monitoring program can rewrite the program to be debugged at any time to set single-step running, cross-step running, and breakpoint running. After the program is suspended, you can observe the various states of the MCU Ram, registers, and the MCU in the integrated development environment. The monitoring chip sst89e516rd of the simulator must be preinstalled with a monitoring program.

4. Use Keil μ vision2 for simulation debugging

After the simulator is ready, it can be used with Keil μ vision2 for simulation debugging. If you build your own project and set it, the related setting process is as follows:

1. Select optionsfor target 'targetl' from the menu project. In the debug page of the "optionsfor trarget 'targetl'" dialog box, select "Use: KeilMonitor-51 driver ". For more information about settings, see. Directly click the options for target icon or right-click the menu to open the setting menu.

 

 

 

 

 

Select Keil Monitor-51 driver in the debug column and tick both of the following.

 

Click OK to save the settings.

 

Click settings to select the computer serial port to be used. Keil μ vision2 is set to COM1/9600 by default. The simulator is adaptive to the serial communication baud rate within a certain range. When the crystal oscillator frequency is 11.0592mhz, the baud rate can be between 4800 and ~ Select between 38400. Generally, the maximum value is used to increase the speed of serial communication. See Figure 6. Click OK to save the settings. The simulator or target board can also select a crystal oscillator of other frequencies. For example, if the crystal oscillator frequency is 6 MHz, the baud rate can be between 2400 and ~ Select between 19200. If the crystal oscillator on the target board is used, the baud rate should be determined based on the crystal oscillator frequency on the target board.

 

 

Open the project test. uv2 and complete the above settings to perform simulation and debugging. Click the build target button on the toolbar to compile the project. After the project is compiled successfully, the target code is generated. Insert the simulator to the target board in the correct direction. Connect the serial port to the computer, connect the source to the target board, click the reset key sb of the simulator, and then click start/stop debug session, start the simulation debugging environment, and the target code will be automatically downloaded to the block0 user program space of the simulator. 7 is displayed after successful connection. During the connection, we will find that the light-emitting diode vd2 is flashing. When the connection fails, check the software settings and hardware circuit.

The main debugging buttons used for simulation are as follows:

The preceding buttons are used in the same way as in software simulation.

After entering the simulation debugging environment, click the "full speed" button, and the eight LEDs on the target board will turn on, indicating that the operation is successful. If we insert a breakpoint before delay (100), click the "run at full speed" button and you will find that the program runs until the breakpoint is reached and then stops running down. Only the first light emitting diode is lit; click the "full speed" button, and the first wheel is routed to the second light emitting diode, and so on. When you exit the simulation, press the reset key of the simulator and click the button to return to the editing mode. After modifying the program and re-compiling, you can enter the simulation debugging environment again. Note that you must first press the reset button sb of the simulator before entering the simulation debugging environment.

Pay attention to the following two points when using the simulator:

1. the simulator uses the serial communication interface of the simulation microcontroller and the timer 2 resources used as the baud rate generator. These resources are only released at full speed, therefore, when the target board uses these resources, it cannot run in a single step, cross step, or breakpoint. This is also a weakness of this simulator. 2. the overflasheeprom write/erase life of the simulator monitoring chip is generally 10 thousand times for each storage unit, and each single-step execution will erase the storage unit once. Therefore, the single-step execution should be used as little as possible, multiple functions such as breakpoint, cross-step, breakpoint, and execution to the cursor line save the number of writes to extend the life of the simulator.

 

 

 

Click settings to set the settings as follows:

 

[3] debugging

Click the debug icon.

 

If an error message is displayed, make sure that the setting is correct and the power supply is on. [My experience is to turn off the power and turn on again. Click try again]

After Correctly Setting and connecting, you can use the toolbar buttons of the Keil menu for simulation debugging. The key function is consistent with the software simulation.

second setting:
In the hardware simulation settings option, select serial interrupt and check it.
if you have not done the preceding settings, the simulator will issue a "WARNING-" long alert during the loading process, the simulation result is
incorrect.
other settings:
Please select use Keil Monitor-51 driver to use hardware simulation
Please select load application at start, directly load the program at startup.
select go till main and run it directly to the main function.
in hardware simulation settings, select 115200bps baud rate, you can select none or only the cache code. Same as
when selecting the correct serial port number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.