Use of serial port debugging Genie and serial port program debugging skills

Source: Internet
Author: User
Use of serial port debugging Genie and serial port program debugging skills
Time: 19:04:49 | [<] [>]
51 single-chip microcomputer has a full-duplex serial communication port. Therefore, the single-chip microcomputer and the computer can communicate with each other conveniently. For serial communication, certain conditions must be met. For example, the serial port of a computer is RS232 level, while the serial port of a single-chip computer is TTL level. There must be a level conversion circuit between the two, we use a dedicated-chip maxcompute for conversion. Although several transistors can be used for analog conversion, the dedicated-chip is simpler and more reliable. We use a three-line connection serial port, that is to say, and the computer's 9-pin serial port only connect to three of the three lines: 5th Gnd, 2nd rxd, 3rd txd. This is the simplest connection method, but it is enough for us. As shown in the circuit, the 10th-foot connection of maxcompute and the 11-foot connection of single chip microcomputer, and the 10-foot connection of single chip microcomputer, 15th-foot connection with 20-foot single-chip microcomputer. All hardware has been assembled on the 51 Single-Chip Microcomputer lab board with extended components provided by the electronic production lab website.

Shows the hardware circuit used for serial communication.

In order to be able to see the data sent by the microcontroller on the computer end, we must use a Windows software for observation. Here we use a free computer serial port debugging software.

Click here to download and run the serial port debugging software. This is a green software that can run directly at the current location without installation. The software interface is shown in figure. First, we need to set the serial communication parameters, adjust the baud rate to 4800, and check the hexadecimal display. Choose "COM1" as the serial port. Of course, connect the serial port of 51 Single-Chip Microcomputer lab Board provided by the website to COM1 of the computer, and insert the single-chip microcomputer with the following program into the universal socket of the single-chip microcomputer lab board, and connect the power of 51 Single-Chip Microcomputer lab board. If you press K1 once, an "af" character will be added to the receiving area interface of the serial port debugging Assistant Software, the single-chip microcomputer successfully sends the "af" character to the computer. The source program of the serial port experiment is as follows:

This is a demonstration program for the Single-Chip Microcomputer Experimental Development Board to send data to the PC's serial port one-way af
Use a dedicated maxcompute chip for RS232/TTL level conversion.
The communication baud rate is 4800 kbps, as long as you press K1 once (that is, p3.6 pin becomes low)
Sends a hexadecimal af character.

Org 0000 h
MoV scon, #50 h; set to serial port 1
MoV tmod, #20 h; baud rate generator T1 works on Mode 2
MoV pcon, #80 h; the baud rate doubles to 2400x2 = 4800bps
MoV Th1, # 0f3h; preset initial values (according to the baud rate of 2400bps)
MoV TL1, # 0f3h; preset initial values (according to the baud rate of 2400bps)
SETB tr1; Start timer T1
The above completes communication initialization settings

Writ: JB p3.6, $; determine If k1 is pressed. If not, wait.
Acall delay10; 10 milliseconds delayed contact Jitter
JB p3.6, writ; remove interference signals
JNB p3.6, $; wait for the button to release

MoV A, # 0afh; send the hexadecimal character af to the serial port
MoV sbuf, A; send the AF through the serial port

Ajmp writ

; 10 ms latency subroutine
Delay10: mov R4, #20
D2: mov R5, #248
Djnz R5, $
Djnz R4, D2
RET

End

This is the programmer program compiled above to write the file: 88.hex

Download the burned-down file: move the mouse to the super key of the burned-down file, right-click the file, and select "Save as ()... "Do not select" text file "for the file type to be saved. Select" all files "to obtain *. HEX file.

 

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.