Keil serial port simulation debugging

Source: Internet
Author: User
★Software Used

● Keil Software Development

● Virtual serial port Software

● Serial port debugging Assistant

★Software Introduction 1. virtual serial port Software

For a laptop, virtual serial port can be used to simulate a real serial port without a serial port. The program can use the virtual serial port to exchange data with other serial ports. Virtual serial ports driver is a very powerful virtual serial port software. Two virtual serial ports can be created at a time, and these two serial ports have been connected, which is equivalent to a serial line.

Use the virtual software Port:


2. Serial Port debugging Assistant

The serial debugging Assistant Interface has a sending area and a receiving area. They are all relative to the upper computer (computer. The sending area is the data display area sent from the upper computer to the lower computer (Single Chip Microcomputer). The receiving area is the data display area sent from the lower computer (Single Chip Microcomputer.

★Keil Simulation Principle

It is to simulate the serial port on the computer into the serial port of the single chip microcomputer. During software simulation, all data sent to the bound computer serial port will be forwarded to the Keil simulation SCM serial port. The user program can receive the data through the interrupt processing program or query method. Similarly, the data sent to the single chip microcomputer serial port in the single chip microcomputer program will also be sent through the bound computer serial port, can be received by other software. With this feature, we can easily simulate and debug the serial port program of the single chip microcomputer.

★Basic Debugging command ● Mode

Used to set the bound computer serial port

Mode comx baudrate, parity, databits, stopbits
Comx (x = 1, 2...) indicates the serial port number of the computer, baudrate indicates the baud rate of the serial port, parity indicates the verification method, databits indicates the data bit length, and stopbits indicates the stop bit length.

Instance:

Mode com4 9600,0, 9600 indicates: Set the serial port com4 baud rate to, no check bit, eight data bit, one stop bit

● Assign

Used to bind the serial port of a single-chip microcomputer to the serial port of a computer

For example:

Assign COM1 <sin> sout binds Serial Port 1 of the computer to the serial port of the single chip microcomputer (this is for single chip microcomputer with only one serial port)
Assign com2 <s0in> s0out binds Serial Port 2 of the computer to serial port 0 of the single chip microcomputer (this is for single chip microcomputer with multiple serial ports, pay attention to the serial port number position above)

★Simulation steps

Use: virtual serial port 4 and 5. Specifically, virtual serial port 4 is bound to the serial port of the single-chip microcomputer; virtual serial port 5 is used in the serial port debugging assistant.

● First, set the project file


Note:

The content in the file debugg. INI is the two commands described above. The function is to set the computer serial port and bind the computer serial port to the single chip microcomputer serial port. The content of the Debug. ini file is as follows:

You can also enter



Set the crystal oscillator to 11.0592

● Click

To enter the debugging mode. Set the corresponding breakpoint as needed, call out the observation box as needed, and set the variables you want to observe.


Then, in debug mode, click

It will appear

You can use this window with the breakpoint you set to better clearly observe the value of the sent data.

Note: In the debugging mode, run the program first, otherwise the serial port data will not be received. Then, open the virtual serial port 5 in the serial assistant.


Enter the data to be sent and observe the phenomenon.




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.