Serial Port Hidden Tips: 3 Concepts to Boost Communication Speed
This tutorial covers UART flow control, common data verification algorithms and pipeline optimization to boost serial communication throughput.
【Preliminary Note】The original hardware example in this article was written based on the RP2040. The actual hardware used in this hands-on demonstration features the W55RP20 as the main controller chip. The circuit logic and UF2 flashing operation principles are universally applicable, with only the main controller model differing. The original chip model mentioned in the circuit descriptions below is provided for reference purposes only.
1. Serial port flow control
RTS / CTS (Request To Send / Clear To Send) flow control. Its principle is that "the receiver uses CTS to inform the transmitter whether it can send data, and the transmitter uses RTS to request permission to send data".RTS (Request To Send): A signal used by the transmitting end to request "permission to transmit" from the receiving end (for example, when an MCU sends a RTS low level to a "serial port module", it means "I am ready to receive, you may send data now").CTS (Clear To Send): A response from the receiving end to the transmitting end indicating "permission to transmit"(for example, when a MCU receives a CTS low level signal from a serial port module, it means "I am ready to transmit, and you can receive").RTS to high level (meaning "my buffer is almost full, stop sending data"); when the transmitter detects the RTS high level, it will stop transmitting.RTS to low level (meaning "my buffer has space now, keep sending"); when the transmitter detects the low level of RTS, it resumes transmission.RTS / CTS pins", and "cross connection" is required during wiring (e. g. MCU ' s RTS connects to the serial module's CTS, and MCU 's CTS connects to the serial module' s RTS).XON / XOFF characters (XON means "continue transmission", XOFF means "stop transmission").2. Data Validation
CRC check code (which is sent along with the data); the receiving end repeats the same operation on the "received data", and if the "calculated CRC " does not match the "received CRC ", it is determined that the "data is erroneous".CRC-12 (12-bit check code), CRC-16 (16-bit), CRC-CCITT (16-bit, commonly used in the communication field), CRC-32 (32-bit, commonly used for file verification).Byte₀, Byte₁, Byte₂, …, Byteₙ, and the checksum = Byte₀ ⊕ Byte₁ ⊕ Byte₂ ⊕ … ⊕ Byteₙ(where "⊕" denotes the XOR operator).