Share this

Several methods for expanding serial ports in embedded systems

2026-04-06 03:14:42 · · #1
Introduction Serial interface devices, with their advantages of flexible control, simple interface, and low system resource consumption, are widely used in industrial control, home security, GPS satellite positioning and navigation, and meter reading for water, electricity, and gas. In these embedded systems, many slave devices may communicate with the host via serial interfaces, such as GPRS modems, infrared transmitters and receivers, and RS485 bus interfaces. This often leads developers to face the problem of insufficient serial communication interfaces for the host in embedded systems. This article introduces several common solutions to this problem. Software Simulation Method The software simulation method can simulate the timing of serial communication using timers and the host's I/O ports, based on the serial communication transmission format, to achieve the purpose of expanding the serial port. During reception, the start bit needs to be detected, which can be done using a polling method, or, in a host with interrupt functionality on the port, using port interrupts. Timing processing during reception and transmission can use either polling or timer interrupt methods. To ensure data integrity, anti-interference processing can be added at the start signal detection point of asynchronous transmission during reception, and multiple sampling can be used when receiving each bit. Expanding the Serial Port Using Parallel-to-Serial Converters Serial Port Expansion Based on Intel 8251: The Intel 8251 is a general-purpose synchronous/asynchronous transmitter (USART) whose operation can be programmed and has independent receivers/transmitters. It can operate in synchronous or asynchronous serial communication modes, automatically completes frame formatting, and has parity and error detection circuitry. Serial Port Expansion Based on TL16C554: The TL16C554 is a 4-channel asynchronous transceiver integrated chip manufactured by TI. Control of the TL16C554 serial channel is achieved by programming the control registers LCR, IER, DLL, DLM, MCR, and FCR. These control words determine the character length, number of stop bits, parity, baud rate, and modem interface. The control registers can be written in any order, but IER must be written last because it controls interrupt enable. The baud rate generator (BRG) within the serial channel allows the clock to be divided by any number between 1 and 65535. The BRG determines the standard baud rate based on one of its three different common frequencies. The 16C55x series chips also include the 16C550 and 16C552, which can expand one and two serial ports respectively. Expanding Serial Ports Using Serial Ports Serial Port Expansion Based on the GM8123/25 Series Chips: The GM8123/25 series serial port expansion chips can implement serial port expansion entirely in hardware. The communication format is configurable and compatible with standard serial communication formats. The GM8125 can expand to five standard serial ports, with the serial port expansion mode selected via external pins: single-channel working mode and multi-channel working mode. In single-channel mode, there is no need to set the chip's communication format. The sub-serial ports and the main serial port operate at the same baud rate. Only one set of sub-serial ports and the main serial port can communicate at a time. The working sub-serial port is selected by the address lines. Single-channel working mode is suitable for systems where all slave devices do not need to communicate simultaneously, and the communication process is entirely controlled by the master. In multi-channel mode, all sub-serial ports have the same baud rate, allowing all sub-serial ports to communicate with the main serial port simultaneously. The main serial port operates at six times the baud rate of the sub-serial ports. During transmission, the address lines select the sub-serial port used to send data. During reception, the sub-serial port actively responds to data sent by the slave device, which is then sent to the master device via the main serial port. Simultaneously, the address lines return the address of the sub-serial port that received the data. After receiving data from the sub-serial port, the master device can determine which slave device sent the data based on the address line status. In multi-channel operation mode, the chip's operating mode must be configured before data communication, including serial port frame format and communication baud rate settings. The chip's operating mode can be configured through the interaction of the serial port and control pins. When pin MS is 0 and STADD2 to STADD0 are 000, a command word is written; when pin MS is 1 and STADD2 to STADD0 are 000, a command word is read. During operating mode configuration, the chip's frame format and main serial port baud rate remain consistent with the previous data communication. After reset, the frame format is 11 bits, and the main serial port baud rate is 7200bps. The SP2338 is a general-purpose asynchronous serial port expansion chip designed using low-power CMOS technology. It can easily expand a host's original single serial port into three new full-duplex serial ports. The SP2338 is suitable for multi-serial port systems with one start bit, eight data bits, and one stop bit; its frame format is not programmable. The host selects any one of the three sub-serial ports by changing the states of the ADRI1 and ADRI0 address lines. The addresses of the three sub-serial ports are 00, 01, and 10, respectively. Address 11 is used to execute the SP2338 chip's own reset instruction 0x35 or 0xB5, sleep instruction 0x55 or 0xD5, and delay instruction 0x00. Writing any data to any of the RX0 to RX3 receive ports will wake up the SP2338; however, since the SP2338's wake-up time is approximately 25ms, the data used for chip wake-up will not be received by the host. Therefore, a single byte of data can be sent to wake up the chip, and normal data transmission can begin after a 25ms delay. Unused input ports, such as RX0, RX1, and RX2, must be connected to VCC; unused output ports, such as TX0, TX1, and TX2, must be left floating; unused ADRI0 and ADRI1 must be connected to GND. The host's data transmission and reception timing is as follows: After receiving a byte, the host TX3 should immediately read the status of the SP2338's output addresses ADRO0 and ADRO1 to determine which sub-serial port the received data came from; when sending data, the host first selects a sub-serial port through ADRI0 and ADRI1, and then writes the data to be sent to TX3. [align=center] Figure 1 Schematic diagram of the serial port expansion method designed in this paper[/align] Expansion method designed in this paper In the circuit design process, this paper designs a scheme suitable for its own system needs to expand one serial port into three serial ports, as shown in Figure 1. Among them, 4001 is a quad 2-input NOR gate, and 40106 is a hex Schmitt trigger. Pins 4 and 9 of the 4001 are the host's RXD and TXD respectively. Pins 2 and 9 of the 40106 are the sub-serial port's TXD0 and RXD0, pins 6 and 11 are the sub-serial port's TXD1 and RXD1, and pins 4 and 13 are the sub-serial port's TXD2 and RXD2. Based on the connection diagram and Boolean algebra derivation, the state of RXD is equal to the AND operation of the states of pins 9, 11, and 13 of the 40106. When any one of pins 9, 11, or 13 of the 40106 has a data signal, since in asynchronous serial communication, the pin is high when there is no data transmission, RXD can receive the data state from the pin with the data signal. The states of pins 2, 4, and 6 of the 40106 are equal to the state of TXD, so pins 2, 4, and 6 of the 40106 can be used as the sub-serial port's TXD. This design is suitable for situations where the host simultaneously sends data to multiple serial devices, while the slave devices do not simultaneously send data to the host. Adding a few more signal lines allows identification of which slave device the data is being sent to and from. In the system presented here, the host initiates the communication, and the source of the received data is predictable; therefore, only three additional signal lines are needed to enable the slave devices. Comparison of Several Methods When expanding the serial ports of a system, using a multi-serial-port microcontroller is the most obvious approach. Because the serial port is integrated within the microcontroller, the device is small and has high anti-interference capabilities. However, multi-serial-port microcontrollers are typically expensive, and if the model is unfamiliar to the developers, they need to relearn and purchase the corresponding development tools, which prolongs the product development cycle and increases development costs. Software simulation methods consume fewer system resources, are low-cost, and easy to implement. However, they have a lower sampling rate, making it difficult to guarantee data accuracy, and generally cannot simulate excessively high baud rates. Parallel port expansion of serial ports offers powerful functionality, providing modem control signals and high communication speeds, but it is complex to control, consumes significant MCU port resources, and is relatively expensive. Serial port expansion using a serial port, on the other hand, simplifies control, minimizes control lines, requires less host system resources, and offers strong versatility, stable performance, and guaranteed data accuracy. The GM812x has drawbacks: it does not meet ultra-low power requirements; in multi-channel mode, all sub-serial ports must be set to a uniform baud rate, making it unsuitable for systems where slave devices have inconsistent baud rates and require simultaneous operation. While the SP2338 meets low power requirements, its sub-serial port baud rates also need to be set to uniform values, and it cannot program data frame formats, with a maximum baud rate of only 9600bps. The method proposed in this paper uses sub-serial ports with the same serial characteristics as the parent port, is simple to use, consumes fewer system resources, is easy to control (at least two control signals are needed to expand three serial ports), and offers good stability. Its power consumption depends on the 4001 and 40106, both in the mA range. Its maximum baud rate depends on the response speed of 4001 and 40106. The maximum response latency of 4001 and 40106 is 250ns, so theoretically the maximum baud rate can reach 4Mbps. This method has been successfully applied to a three-meter remote transmission system. The disadvantage of this method is that it cannot be used in systems where the slave devices have inconsistent baud rates and are required to work simultaneously. Conclusion This paper designs a method for expanding serial ports to solve the problem of insufficient host serial port resources encountered in practical applications. This method has been successfully applied to a three-meter remote transmission system. In solving this problem, this paper also compares other solutions.
Read next

CATDOLL 139CM Charlotte (TPE Body with Soft Silicone Head)

Height: 139cm Weight: 23kg Shoulder Width: 33cm Bust/Waist/Hip: 61/56/69cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22