How to understand what a single-chip microcomputer is and how to understand a full-duplex serial communication interface

How to understand what a single-chip microcomputer is and how to understand a full-duplex serial communication interface

A single-chip microcomputer integrates most of the functions and resources of a computer in a single chip, so we can understand it as a computer with very weak performance. Compared with common ordinary computers or mobile phones, the operation speed of single-chip microcomputers is about 100% of them. One, the storage space is one millionth of their size, so the single-chip microcomputer is relatively cheap, and it can be bought very cheaply. The single-chip microcomputer is suitable for simple programming control of electronic products.

The 51 single-chip microcomputer has a programmable full-duplex asynchronous serial communication interface, which has all the functions of a general asynchronous transceiver. The asynchronous serial communication interface is called UART, which refers to a general asynchronous transceiver, which has a general asynchronous The function of the transceiver does not only refer to having this function, but also can be used as a synchronous shift register.

The full-duplex asynchronous serial communication interface of the single-chip microcomputer has four working modes, among which mode 0 can be used as a synchronous shift register. If you want to use the single-chip microcomputer for serial communication for data transmission and reception, then It is necessary to use its serial communication interface. The communication interface is the serial communication between the device and the device or between the device and the host. It is necessary to use pins. The 51 single-chip microcomputer uses two pins for serial communication. The pins are P3.0 and P3.1. When doing communication, GND is generally used. Three wires can be used for full-duplex serial communication. The full-duplex asynchronous serial communication interface can be received when sending. It can also send when receiving, and it is asynchronous communication, not synchronous.

Asynchronous means that when doing asynchronous serial communication, its data is actually sent in character frames. A frame format will include several things, start bit, data bit stop bit, parity check Bit verification, these constitute a frame format, the time interval between each frame of data and each frame of data is arbitrary, and one frame of data bits in each frame of data includes ten bits of asynchronous serial communication. The time interval is strictly specified according to the baud rate. For example, the baud rate is 4800. When transmitting this frame of data, the time interval between each bit and the other bit should be based on this baud rate. Configuration, the sender and receiver can know how to identify the data. The serial communication on the hardware uses the three lines of P3.03.1 and GND. In this function, it is a full-duplex serial port.

Asynchronous communication includes data start bits, stop bits, and parity bits. The positions of these bits are in a frame format. When sending data, each frame of data transmission must be transmitted according to this frame format. The start bit and If the stop bit uses the serial communication interface inside the single-chip microcomputer, in fact, this is added by the hardware, and we don’t need to manage it. The data starts to be transmitted. There is no data transmission between the TSD or SD line when it is idle. It is a high level. To establish a communication, first pull this line to a low level, which is the sender. Pulling this line out to a low level means that a frame of data is to be sent, and the receiver has been monitoring this signal line, so it can know that there is data to be sent, and can send and receive data according to the agreed baud rate. .

When the stop bit is sent, the microcontroller considers that a frame of data has been sent, and can receive another frame of data. The stop bit keeps the bus in an idle state, and another communication can be initiated. The transmission baud rate is commonly used. That is, the current baud rate can be made higher, which determines how high the speed of serial communication in the selected chip can be achieved, and how high the clock crystal oscillator is. Agree on what the current communication baud rate is, and then configure the serial port to generate a baud rate. The baud rate must be agreed first. For example, when working mode 1 is used, it is generated by the timer counter of the microcontroller. The baud rate is not to generate a baud rate directly and then to communicate, determine the baud rate in advance, and then let the serial communication interface generate this baud rate according to the set baud rate, so that both the sender and the receiver can generate the baud rate. The communication is carried out according to this agreed baud rate.

At the beginning of the initial communication, there must be a basic communication agreement. After the basic communication agreement is established, the communication sender and receiver can transmit a byte or a frame of data. The data represents some commands or some parameters. Make some communication protocols of the upper software layer, or some communication protocols of the application layer. In fact, the communication protocol should be divided into two types in terms of the software layer. One is the basic communication protocol, such as serial communication. When the computer is used to communicate with the computer, the debugging assistant of the serial port is used when the computer starts debugging. First, select the baud rate, then select the start bit, stop bit and check bit. The sending and receiving parties follow a unified standard, or a unified agreement, the data path between the sending and receiving parties is established, and the data can be sent and received.

If you are interested in single-chip microcomputer, you can check the content shared in previous issues , hoping to help everyone take some detours on the road of learning single-chip microcomputer . If you want to get started with single-chip microcomputer, you can continue to pay attention to the programming of single-chip microcomputer , and reply "Take me to learn" to view more content sharing .

Guess you like

Origin blog.csdn.net/m0_66707146/article/details/123902199