UART Serial Interface Circuit Design
A UART is the simplest way to move data between two devices: one wire each way, no clock, and a frame defined only by the timing of the bits. That simplicity is also its weakness, because both ends must agree on the rate and both must sample at the right moment. A serial link that fails intermittently is almost always a timing or an electrical problem rather than a protocol one.
How a UART Frame Is Built
A frame begins with a start bit, which is a transition from the idle high level to low, and the receiver uses that transition to synchronise its internal timing. The data bits follow, least significant first in the usual arrangement, then an optional parity bit and one or more stop bits that return the line to idle.
Because there is no clock, the receiver samples each bit at its centre, having measured the time from the start bit. The sampling point is at half a bit time after the edge, which gives the maximum tolerance to error in either direction. The receiver also normally oversamples the line, taking three samples around the centre and deciding by majority.
The idle level is high, which means a disconnected line looks like a permanent idle condition rather than a stream of data. A break condition, where the line is held low for longer than a frame, is used deliberately to signal a fault and can also be produced by a wiring error or by a driver that is left enabled.
Baud Rate and Clock Accuracy
baud rate is the number of symbols per second, and both ends must use the same value. The tolerance is set by the frame length: with ten bits in a frame, an error of a few percent accumulates over the frame until the sampling point drifts into the neighbouring bit. A common rule is that the total error from both ends should stay below two percent, and below one percent where a long frame is used.
The error comes from the clock source. An internal oscillator divided to the required rate often has a tolerance of a few percent over temperature, which is enough to break a link at the extremes even though it worked on the bench. A crystal based clock, or an oscillator with a specified tolerance over temperature, gives the margin needed for a reliable port.
Fractional dividers reduce the error by allowing the divisor to alternate between two values. Where the controller provides one, it should be used, because a rate that is off by two percent is only just inside the limit and leaves nothing for the drift of the other end. Measuring the actual baud rate on a scope, by looking at the width of a known character, confirms the setting.

Level Translation and Physical Layers
The logic level of the UART pins depends on the supply of the device, while the physical layer used on a cable is usually a higher voltage or a differential standard. level translation between the two is done by a dedicated transceiver rather than by resistors, because the transceiver also provides the drive strength and the protection that a cable requires.
For short links between boards in the same enclosure, the logic levels can often be connected directly, provided both devices use the same supply and the ground reference is shared. As soon as the link leaves the enclosure, a proper physical layer is needed, whether that is a single ended standard with a wide voltage swing or a differential one for longer runs.
Differential physical layers are preferred where the cable is long or the environment is noisy, because the receiver responds to the difference between the two conductors and rejects the common mode voltage that a long cable develops. The choice between them follows the same reasoning used for any serial interface that leaves the board.
Flow Control and Buffering
flow control prevents the receiver buffer from overflowing when the sender is faster than the receiver can process. Hardware flow control uses two additional signals, one from each direction, that indicate whether the receiving side is ready. It is immediate and reliable, at the cost of two more wires in the cable.
Software flow control uses special characters embedded in the data stream, which means the data itself has to be escaped if it contains those characters. It saves the two wires and is common on links where the payload is text, while it is a poor choice for binary data because the escaping adds complexity and can corrupt a stream if a character is lost.
Buffering is the alternative where neither form of flow control is available. A larger receive buffer absorbs bursts, and a protocol with acknowledgements allows the sender to retry when a frame is lost. This is how most robust serial protocols work, and it removes the dependence on the timing of the other end.

Isolation and Protection on a Serial Port
A serial port that connects to equipment in another cabinet is a path for ground difference current as well as for data. An isolated transceiver breaks that path, and it also protects the controller from faults on the cable. The isolation barrier follows the same rules as any other: no copper crosses it except through the device, and the creepage has to suit the working voltage.
Protection belongs on the connector side of the transceiver, placed close to the connector with a short return to ground. A series element limits the current during a transient and helps the clamp absorb the energy, and the devices must be chosen so that they do not conduct at the maximum signal level on the line.
Where the port is exposed to a user, an additional layer of protection and a defined creepage between the port and the user accessible parts may be required by the applicable safety standard. The partition between the protected and unprotected areas of the board, and the way the two grounds are joined, is the same discipline described in mixed signal board design.
Layout of the Serial Interface
Keep the transceiver close to the connector so that the unprotected side of the circuit is short. Route the logic side signals away from the cable side, and keep the two ground areas separate where the interface is isolated. Where the interface is not isolated, keep the cable side return separate from the digital return until they meet at one point near the connector.
Decouple the transceiver supply locally with a ceramic capacitor, and add a small series resistor or ferrite where the rail is shared with switching circuitry, because the transmit current is drawn in bursts at the bit rate. On a multi port board, give each transceiver its own decoupling rather than sharing a distant capacitor.
Test points on the logic side of each port make diagnosis straightforward, and they should be placed where a probe can reach them without touching the cable side. The interference that enters a serial link usually arrives through the cable, and the method for finding the path is described in our article on EMI suppression design.
Debugging a Serial Link
Start with the electrical basics: confirm that the idle level is correct, that the ground is connected, and that transmit and receive are not swapped. A link where the idle level is wrong will never work, and the fault is in the wiring or the transceiver rather than in the firmware.
Then look at a known character on a scope and measure the bit width. If the measured rate differs from the setting by more than a percent or two, the clock configuration is wrong. If the bit width is correct but the frame is corrupt, the problem is more likely a level or noise issue, and the shape of the waveform at the receiver tells the story.
If the link works for short messages and fails for long ones, the receiver is probably overrunning or the framing is being lost at the end of the message. Increasing the buffer, adding flow control, or reducing the baud rate identifies which. Where the port is installed in a humid environment, coating the board as described in conformal coating prevents leakage currents from producing faults that appear only in the field.
FAQ
How accurate must the baud rate clock be? Keep the total error below one percent where the frame is long or the temperature range is wide. An internal oscillator without a specified tolerance over temperature is a common source of intermittent failures.
Can I connect two boards at different logic levels directly? Not safely. Use a level translator, and check that the translator is suitable for the direction and the rate rather than a general purpose part intended for open drain buses.
Why does my serial port work until the motor starts? The motor disturbs the ground reference or couples noise into the cable. Check the ground connection and the cable routing before changing the baud rate.



