Single-chip microcomputer serial communication technology

1. What is serial communication?

Serial communication (English: Serial communication) is a method of communication that transmits one bit of data at a time on a computer bus or other data channel and continuously performs the above single process. Corresponding to this is parallel communication, which communicates on the serial port by transmitting several bits of metadata at the same time.

In short: Serial communications are organized as a team, and parallelism is arranged in a row, as shown below

2. Synchronous serial communication and Asynchronous serial communication

The sending end sends a serial clock and simultaneously provides a clock signal, and sends data according to a certain convention (for example, when the rising edge of the clock signal is sent out), the receiving end according to the clock signal provided by the sending end, and Everyone's agreement to receive data. This is often referred to as Synchronous serial communication. I2C, SPI, and other protocols that have a clock signal belong to this type of communication.

The sender tells the receiver to start (or stop) receiving data before and after data transmission by signals of a specific type (such as a START signal and a STOP signal). At the same time, the sending and receiving parties will agree on a data transmission speed (namely, the famous baud rate). After sending the START signal, the sending end sends serial data at a fixed rhythm. At the same time, the receiving end receives the data. After the START signal, serial data is also received at a fixed rhythm. This is often referred to as Asynchronous serial communication.

3, commonly used in the microcontroller serial communication interface

• SPI: High speed synchronous serial port. 3~4wire interface, independent transceiver, synchronous serial peripheral interface, is a synchronous serial communication mode introduced by Motorola, a three-wire synchronous bus, because of its strong hardware function, SPI-related software It's fairly simple, giving the CPU more time to handle other transactions. The SPI usually has three signals: SCK clock, STB chip select, and DATA data signal. I2C usually has two signals of SDA data and SCL clock. The SPI bus truly implements full-duplex data transmission. The SPI has three lines and four lines. If the line is four lines, it is a line called SDC, which is used to tell whether the slave device now transmits data or instructions. This interface is faster and can transmit more continuous data. SPI speed is greater than IIC, generally used in high-speed data communication between internal components of products, such as large-capacity memory.

• UART: Universal Asynchronous Serial Port. Generally speaking, the "serial port" on the MCU is mostly UART. Full-duplex communication is possible, with fewer lines. The data is transmitted asynchronously, the timing requirements for both parties are relatively strict, and the communication speed is not very fast. The most used for communication between multiple machines (single chip microcomputer and single chip microcomputer).

• IIC: A serial transmission method, three-wire system. The communication protocol and usage can be found on the Internet. The protocol of the IIC interface includes device address information. Multiple slave devices can be connected to the same bus, and data and commands can be exchanged through the response. . However, the transmission rate is limited, which can reach 100Kbps in the standard mode, 400Kbps in the fast mode, and Mbps in the high-speed mode. The full duplex cannot be achieved, and it is not suitable for transmitting a large amount of data.

• USB: This is certainly familiar, dealing with almost every day. Universal Serial Bus (USB) is a serial bus standard that connects a computer system and an external device. It is also a specification of an input/output interface and is widely used in personal computers and mobile devices. Information and communication products, and extended to other related fields such as photographic equipment, digital televisions (set-top boxes), and game consoles. Many microcontrollers also have a USB interface such as ST's STM32.

The communication protocols of the various interfaces above are different. For example, the simplest protocol of the UART is a start bit and an eight data bit in the middle of the termination bit, and the USB communication protocol is much more complex.

4, serial interface electrical standards.

TTL level: TTL level refers to a low level of 0 and a high level of 1 (+5V level). This level is used by most microcontrollers' own serial ports. Generally used for communication between chips, TTL level communication distance is short.

UART uses the level that the one-chip computer brings, what is the standard level of the one-chip computer then the one-chip computer UART is what level standard, for example UART of 51 one-chip computer is used TTL level. And this level is no way for remote data transmission, in order to enable serial data can be transmitted farther, we need more powerful transmission standards, so there is RS-232, RS-422, RS485 and so on.

• RS-232-C

RS-232-C, also known as standard serial port, is the most commonly used serial communication interface. It was established in 1970 by the United States Electronic Industries Association (EIA) in conjunction with the Bell system, modem manufacturers and computer terminal manufacturers for the serial communication standard. Its full name is "a serial binary data exchange interface technology standard between data terminal equipment (DTE) and data communication equipment (DCE)." The traditional RS-232-C interface standard has 22 wires and uses a standard 25-pin D-type connector. A simplified 9-pin D-type socket has been used since IBM PC/AT. So far, 25-pin connectors have rarely been used in modern applications. The computer usually has two serial ports: COM1 and COM2. The 9-pin D-shaped interface is usually seen behind the computer. Many mobile phone data lines or logistics receivers are now connected to computers using the COM port.

• RS-422

To improve the shortcomings of RS-232 communication at short distances and low speeds, RS-422 defines a balanced communication interface that increases the transmission rate to 10 Mb/s and extends the transmission distance to 4000 feet (at a rate lower than 100 kb/s). And allows up to 10 receivers to be connected on a balanced bus. RS-422 is a unidirectional, balanced transmission specification for single-machine transmission, multi-machine reception and is named TIA/EIA-422-A.

• RS-485

To expand the application range, EIA developed the RS-485 standard based on RS-422 in 1983, adding multi-point, two-way communication capabilities that allow multiple transmitters to be connected to the same bus while adding a transmitter. The drive capability and collision protection features extend the bus common-mode range and was later named TIA/EIA-485-A.

The following figure shows the general transmission process: the MCU matches the level to RS-232, transmits it through RS-232, and then matches it from RS-232 to TTL to another microcontroller.

5, other

All kinds of serial communication can be converted to each other. The CH340 chip most frequently used in the figure below can convert USB to UART serial communication with TTL level.

Coalbed Gas Generator

Coalbed Gas Generator,Diesel Water Pump Generator,Diesel Geneator Water Pump,Silent Gas Generator

Jiangsu Vantek Power Machinery Co., Ltd , https://www.vantekpower.com