This design builds on a previously published Idea for Design (“Talk To Multiple Devices With One UART”). Our solution allows you to increase the number of USARTs (universal synchronous, asynchronous receiver/transmitters) available on a microcontroller with minimum hardware.
Typical 8- and 16-bit microcontrollers have one programmable USART for communication. But designers may need more USARTs for communication with two peripherals. A masterslave circuit communicating serially might also need another USART for connection to a computer.
Solutions include using dedicated serial ICs, designing software USARTs, and using remappable pins, I2C, or serial peripheral interface (SPI). However, these alternatives require strict timing sequences, and the pins required may be needed for other purposes. The circuit in the figure shows an alternative high-speed switching circuit that increases the number of available USARTs using minimum hardware and I/O pins.
Transistors Q1, Q2, Q3, and Q4 represent the receiver circuit block; Q5, Q6, Q7, and Q8 represent the transmitter circuit; and Q9 and Q10 form a TTL hex inverter. The inverter never sources current, so there’s no need for a totem-pole output. An I/O pin from the microcontroller is connected to Q9 and serves as the selection pin for the USARTs.
When the I/O pin is at logic zero, Node 1 is at logic low and Node 2 is at logic high. Thus, Q2 and Q3 are cut off, and the states of Q1 and Q4 depend on the instantaneous logic level of RXD1. When RXD1 is low, Q4 conducts and Q1 is cut off, and when RXD1 is high, Q1 conducts and Q4 is cut off. Therefore, at any time, either Q1 or Q4 conducts (is in the active region), and the voltage logic at RXD1 is made available at RXD, while RXD2 is completely cut off. Similarly, when the I/O pin is at logic one, Node 1 is high and Node 2 is low; Q1 and Q4 are completely cut off, and either Q2 or Q3 conducts. Therefore, RXD2 is connected directly to RXD.
The transmit circuit functions in a similar way. The table shows this operation.
High-speed transistors such as the 2N2907 and 2N2222 are preferable in order to minimize the propagation delay in the inverter, thus eliminating the need for the firmware to account for this delay. Very high transmission speeds (230.4 kbits/s) are possible with the use of such fast transistors. Additionally, with small modifications and the use of BJT-pairs and microcontroller pins, the designer can create more than two programmable USARTs.
This circuit is essentially a two-way switching circuit. The switching can also be accomplished with either tri-state buffers or multiplexers-demultiplexers. But these may cause power-supply problems because most of today’s systems run on 3.3 V or below. Also, these dedicated ICs require a lot of space. The circuit described here avoids these problems.