Infrastructure

Serial and UART Are Not the Same Thing

A UART is a hardware block that frames bits. Serial is a way of sending them one at a time. RS-232 is a third thing entirely, a standard for what those bits look like as voltage. Three layers, one name, and a mistake that can damage hardware.

Ask three engineers what a serial port is and you will get three different answers without anyone noticing. One will describe the UART. One will describe the connector. One will describe the voltage standard. All three will think they are talking about the same thing, and in conversation they mostly are, right up until something breaks and you have to work out which layer broke.

They are genuinely separate layers. A UART is a piece of digital logic. Serial is a way of moving bits. RS-232 is a rule about voltage. You can combine them into a working link, which is exactly what a PC serial port used to be, but nothing requires the combination, and modern hardware takes the layers apart all the time.

Three layers wearing one name

The confusion has a structure, and it helps to name the parts:

The framing and timing layer. This is the UART, a universal asynchronous receiver/transmitter. It takes a byte, adds enough structure for the far end to find the byte boundaries, transmits the bits one after another, and reconstructs bytes on the way back. It deals in logic levels, not voltages.

The electrical layer. This defines what a one and a zero look like as actual voltage on a wire, and it is a completely separate specification. RS-232, RS-485 and plain TTL are three different answers to the same question. Wikipedia’s UART article draws the boundary precisely: “The electric signaling levels are handled by a driver circuit external to the UART.”

The functional layer. Which pins mean what, and who is allowed to assert them. ITU-T V.24 lives here, listing the interchange circuits between Data Terminal Equipment and Data Circuit-terminating Equipment.

In OSI terms the UART belongs to layer 2, the data link layer. The electrical standards are layer 1. That is not a metaphor, it is the actual split, and it explains why the same UART code works whether it is driving a 3.3 V wire to a sensor or a 25-pin cable to a modem: only the transceiver changes.

What the UART actually does

Strip away the acronym and a UART is a shift register with a clock and some opinions about framing.

It contains a clock generator running at a multiple of the bit rate, typically 8 or 16 times, so the receiver can sample in the middle of each bit period rather than at the edges where the signal is moving. It contains separate shift registers for transmit and receive, because full duplex means both directions run at once. It contains control logic, and often a small FIFO.

The receiver’s job is to find the start of a character without any shared clock. It watches the line for the falling edge that marks a start bit, then checks that the line is still low half a bit time later. If it is not, the pulse was noise and gets discarded. Once a start bit is confirmed, the receiver waits one bit time and samples again, once per bit period, shifting each result into a register.

Two devices have no timing system in common beyond the signal itself, so they continually re-derive timing from the data. Well-behaved UARTs resynchronise on every transition that is not treated as noise, which is how they tolerate a transmitter whose clock is slightly off. Simpler ones resynchronise only on the start bit and then trust their own clock for the rest of the character.

And because a character can arrive while the host is busy, most UARTs double buffer. The receiver holds one character while shifting in the next, and a FIFO holds several more, which is the difference between a design that works at 9600 baud and one that loses data.

Both ends must agree on the same settings or nothing sensible comes out: bit rate, data bits, parity, stop bits, flow control, and voltage. Mismatched framing produces a framing error flag, or in the awkward cases “an erratic stream of mutilated characters”.

The frame, bit by bit

A UART frame has five parts, and they were designed to be found by a receiver that has no idea when the next character will start.

The line rests idle high. This is a legacy from telegraphy, where a held-high line was evidence the line and transmitter were still intact.

A character begins with a start bit, which pulls the line low. This is the only signal the receiver needs, and it is why the scheme is called asynchronous: there is no clock wire, just a transition that says “watch now”.

Then come the data bits, five to nine of them depending on the code set, least significant bit first in most implementations, with documented exceptions such as the IBM 2741 printing terminal.

A parity bit is optional, and sits after the data.

Finally one or two stop bits hold the line high, marking the end of the character. Because the start bit is low and the stop bit is high, every character contains at least two guaranteed transitions, which is what keeps the timing honest.

Idle high also makes a useful failure mode free. If the line stays low for longer than a character’s worth of time, that is not a character at all, it is a break condition, and receivers report it as one.

The overhead is the part worth remembering. A common configuration is 8 data bits, no parity, 1 stop bit, written 8N1. That is one start bit plus eight data bits plus one stop bit: ten bits on the wire for eight bits of payload, an efficiency of exactly 80%. It follows that for 8N1 the number of characters per second is the bit rate divided by ten, so 9600 baud carries approximately 960 characters per second. Ethernet reaches about 95% on full-size frames and closer to 99% on jumbo frames, though for messages of a few bytes its fixed overhead pushes it well below the UART’s constant 80%.

Serial, parallel, and why there is a chip for this at all

Serial means one bit at a time down one conductor. Parallel means several conductors carrying several bits at once. On the face of it parallel is the obvious win: an eight-bit parallel channel moving data at the same clock rate as a serial one is eight times faster.

That advantage evaporates for two physical reasons. Clock skew means the bits do not arrive together, and the link can only run as fast as its slowest lane. Crosstalk between adjacent conductors gets worse as the cable gets longer, which caps parallel links at shorter distances than serial ones. The one place parallel keeps winning is latency, which is why DDR memory buses are still parallel.

What parallel does have going for it is simplicity: implementing a parallel port can be as little as a latch that copies data onto a bus. Serial needs a converter, and that converter is the UART. Wikipedia states the dependency plainly: most serial communication “must first be converted back into parallel form by a universal asynchronous receiver/transmitter before they may be directly connected to a data bus.”

So the UART exists because the inside of a computer is parallel and the outside is serial. Serial then won that fight on the outside for a boring and decisive reason: fewer wires means smaller, cheaper, more durable connectors. Parallel ATA gave way to Serial ATA, the IEEE 1284 printer port gave way to USB, and SCSI gave way to everything.

Where the UART came from

The framing scheme is older than the electronics by a wide margin, because it was invented for machines that had no electronics at all.

Émile Baudot designed a five-unit code in 1874, and by 1901 Donald Murray had reworked it for a typewriter-style keyboard. Five bits caps a code at 32 symbols, which is what the ITA2 teleprinter alphabet lived with, and it is why teleprinters needed shift states for letters and figures.

The other half of the scheme, the part that says a character is a discrete package with a start and a stop, came from the start-stop synchronising method that Morkrum patented in 1919. A teleprinter’s native mode was a series DC circuit interrupted like a telegraph line, and its terms for logic levels, mark and space, are the direct ancestors of the terminology still used for RS-232 signalling.

The first UART as such was built by Gordon Bell at DEC for the PDP series, starting with the PDP-1, and it was not a chip. It was an entire circuit board, called a line unit. According to Bell, the real innovation was sampling the incoming signal into the digital domain, which made timing far more reliable than circuits that used analogue timing components with potentiometers adjusted by hand. Those machines also pioneered software flow control using XON and XOFF characters, to save the cost of running extra wires through the backplane.

DEC condensed that board into an early single-chip UART, and Western Digital turned it into the WD1402A around 1971, the first widely available single-chip UART. The chip that put the UART in front of a mass audience was the National Semiconductor 8250, which sat on the original IBM PC’s Asynchronous Communications Adapter card.

The 8250 and its successor the 16450 had one buffer character per direction, and generated an interrupt for every byte received. At 9600 baud a character arrives roughly every millisecond, so a machine that disabled interrupts for longer than that, which plenty of DOS-era disk and video controllers did, would miss one and raise an overrun error. The 16550 fixed this with a 16-byte FIFO in each direction, and the datasheet describes the design in the language of relief: the FIFOs exist “to reduce the number of interrupts presented to the CPU”. A 16-byte buffer lifts the reliably achievable rate from 9600 to about 153,000 bit/s under the same one-millisecond interrupt latency, and a 32-byte buffer goes past 300,000 bit/s. The newer part also stores three bits of error data alongside each byte in the receive FIFO. The first 16550 shipped with a bug that made the FIFO unusable, which is why the fixed 16550A is the part people remember.

UART naming never converged, which is its own small warning about how badly this terminology travels. Intel called its 8251 a Programmable Communication Interface, because it was really a USART. MOS Technology sold the 6551 as an ACIA. Motorola used Serial Communications Interface. Zilog sold Serial Communication Controllers.

And the chip outlived the port that made it famous. As PCs dropped their RS-232 ports through the 2000s, the UART moved inside USB-to-UART bridge chips, with FTDI and Cypress among the established vendors and Silicon Labs (CP2102) and WCH (CH340) behind most of the inexpensive hardware people actually meet. A modern microcontroller usually has several UARTs on the die for talking to other chips, long after the connector vanished.

RS-232 is a different standard, and it does not define the frame

Now the part that surprises people.

RS-232 was introduced by the Electronic Industries Association in 1960, with revisions in 1963, 1965 and 1969, the last of which is the RS-232-C that everyone quotes. It defines electrical characteristics: logic levels, baud rate, timing, slew rate, voltage withstand, short-circuit behaviour, maximum load capacitance.

It deliberately does not define the rest. In the standard’s own scope, it does not specify “the character encoding (i.e. ASCII, EBCDIC, or others), the framing of characters (start or stop bits, etc.), transmission order of bits”.

Read that again. The standard named after the PC serial port does not define start bits, stop bits, or bit order. Those come from the UART. RS-232 is a specification for moving a signal reliably from one end of a cable to the other, and the meaning and structure of what travels inside that signal belongs to something else. On its own, RS-232 cannot transmit a byte.

The electrical rules are worth knowing because they explain most serial port failures:

Voltage. Valid signals sit in the range +3 to +15 V or -3 to -15 V; the zone between -3 and +3 V is not a valid level at all, and a compliant port can put up to 25 V open circuit. Data lines read negative as a one and positive as a zero, while control lines invert that. This is the layer where mistakes stop being bugs and start being damage, so it gets its own section below.

Polarity is inverted, and it is inverted twice. Data lines read a negative voltage as a one, called mark, and a positive voltage as a zero, called space. Control lines such as RTS and CTS use the opposite convention, where the asserted state is positive.

It is single-ended. Both ends reference a common ground, which is what limits its noise immunity and its reach.

Cable length is not specified, capacitance is. The standard caps the load capacitance a driver must tolerate instead of naming a distance. A common rule of thumb puts the practical limit near 15 metres (50 feet) on ordinary cable, extended to roughly 300 metres with low-capacitance cable, and beyond that the advice is to use a different standard such as RS-422.

The connector is a red herring. RS-232 recommended the 25-pin D-subminiature and made it mandatory from revision D, but most devices implement only a handful of the twenty defined signals, and a 25-pin connector does not imply compliance. The original IBM PC makes the point beautifully: a male D-sub on that machine was an RS-232 DTE port, while the female D-sub on the same machine was the parallel Centronics printer port. Same connector family, completely different interface.

The functional layer is separate again. ITU-T V.24 lists the interchange circuit definitions compatible with RS-232, and notably does not specify signal levels or timing, which are covered by ITU-T V.28. If you have ever wondered why a DB-25 serial pinout has so many wires that seem to do nothing, that is the functional layer’s business, not the electrical one’s.

RS-485 is a third thing

RS-485 is the answer for the cases where single-ended signalling runs out of road.

It is differential, meaning each signal is carried as the difference between a pair of conductors rather than as a voltage referenced to ground, which cancels much of the noise the pair picks up. It supports multiple drivers and receivers on one bus, so many devices can share a pair of wires, and it reaches far further than RS-232 at useful speeds. Wikipedia notes that RS-232 has “lower transmission speed, shorter maximum cable length, larger voltage swing, larger standard connectors” than RS-422, RS-485 and Ethernet.

RS-485 is a signalling standard. It says nothing about framing. The same UART drives it, with a different transceiver on the other side of that external driver boundary.

A USART is a UART with a clock, and some serial has no UART at all

The U is for universal, and the S that appears in USART is for synchronous. A USART can do everything a UART does, and can also operate synchronously against a shared clock line. That added clock is the whole distinction, and it is the reason Intel’s 8251 counts as a USART while the 16550 does not.

There are also serial buses that share the bit-at-a-time idea and have no UART in them whatsoever:

SPI is synchronous serial with a master and one or more slaves, a clock, and a chip-select line per device. Data is shifted out on clock edges, and the clock’s polarity and phase are configuration parameters that have to match at both ends.

I2C uses two wires, one data and one clock, with 7-bit addressing, and the controller generates the clock. Devices are selected by address rather than by a dedicated wire.

Neither frames characters with start and stop bits, because neither needs to: a shared clock tells the receiver when to look. That is the actual purpose of the asynchronous start and stop bits, and removing them removes the need for a UART.

Baud is not bit rate

This one is not just terminology, because the number has to match at both ends of a link.

Baud is a unit of symbol rate: signalling events per second. It is named after Émile Baudot, and was defined by the CCITT in 1926, replacing the earlier and less robust measure of words per minute. A symbol is not necessarily a bit. If a scheme has exactly two symbols, typically zero and one, then baud and bits per second coincide. If it has more, they do not: a 64QAM modem carries six bits per symbol, so its bit rate is six times its baud rate. The ratio is not always a whole number either. 4B3T coding runs at four thirds of the baud rate, and the eight-to-fourteen modulation on an audio CD runs at eight seventeenths of it.

Wikipedia is blunt about the common error: “The term baud has sometimes incorrectly been used to mean bit rate.” In a UART link the two really are equal, because one symbol is one bit, and that coincidence is why the sloppy usage has survived for decades. It is also why the setting is sometimes labelled baud and sometimes bit rate, and why arguing about the label has never once fixed a link. The value itself must match, whatever you call it.

The voltage layer is where hardware goes to die

Here is where the layers stop being an abstraction, and it is the part worth reading twice.

The voltage domains sitting under the name “serial” are not variations on a theme. They are different electrical universes, and only some of them can be joined without damage:

Interface A logic 1 is A logic 0 is Referenced to Notes
5 V TTL UART +5 V 0 V local ground no negative rail at all
3.3 V UART +3.3 V 0 V local ground the common case today
1.8 V UART +1.8 V 0 V local ground SoC and FPGA I/O banks
RS-232 negative, -3 V to -15 V (mark) positive, +3 V to +15 V (space) common ground -3 V to +3 V is not a valid level; up to 25 V open circuit
RS-485 A negative with respect to B A positive with respect to B the differential pair, plus a reference ground driver guarantees 1.5 V differential into 54 ohms; receivers detect down to 200 mV
20 mA current loop no current flowing 20 mA flowing optically isolated current, not voltage

Everything about that table is deliberate, and the polarity inversion is the part that catches people. On an RS-232 data line a one is a negative voltage, called mark, and a zero is a positive voltage, called space. Control signals such as RTS and CTS invert that convention again, so their asserted state is positive. Two conventions, opposite polarity, in the same standard, distinguished only by which category of circuit you are looking at.

Mismatch one: RS-232 into modern logic. An RS-232 driver puts out anywhere from ±3 V to ±15 V. A 3.3 V microcontroller pin usually has an absolute maximum rating around 3.6 V, and anything below roughly -0.3 V is outside what the pin survives. The mark state is a negative voltage, which is precisely what that pin cannot take. Wiring a 3.3 V UART directly to a DB-9 does not give you garbled characters. It gives you a damaged pin.

Mismatch two: TTL into an RS-232 receiver, which fails differently. Sending ordinary logic levels toward an RS-232 input sounds harmless, because the voltages are lower. It does not work, and the reason is subtler than “wrong level”. TTL levels of near +5 V and 0 V put the mark state inside the undefined window rather than inside the valid negative range, so the receiver is not being lied to about the polarity so much as handed a level the standard refuses to interpret. This exact combination turns up in the wild with NMEA 0183 GPS receivers and depth finders, and it is why a MAX232-class chip is the standard fix.

Mismatch three: grounds that are not at the same potential. This is the one that destroys equipment rather than a single pin, and it is why single-ended standards are pickier about installation than their pinouts suggest. Both ends of an RS-232 link reference a common ground, so both ends have to agree what zero volts means. Connect two machines on different circuits, or in two different buildings, and their grounds can sit at slightly different potentials. Worse, that difference comes with very low impedance behind it. Wikipedia’s wording on the RS-485 reference connection describes the consequence without hedging: grounds between buildings “may vary by a small voltage, but with very low impedance and hence the possibility of catastrophic currents”, enough current to melt signal cables, PCB traces and transceiver devices. The remedy is the same one that makes isolated interfaces valuable: do not connect the grounds, or limit the current if you must.

Mismatch four: drifting outside an RS-485 common-mode range. Differential signalling is robust, not invincible. RS-485 tolerates a common-mode voltage of -7 V to +12 V, and the standard is explicit that leaving that window results in “at best, signal corruption, and, at worst, damage to connected devices”.

The 20 mA current loop deserves its reputation for toughness for the same reason it looks archaic. Signalling with the presence or absence of current rather than the level of a voltage means ground potential differences mostly stop mattering, which is why teleprinters used it, why it survives in long runs, and why it is a natural fit for optical isolation.

All of this is why the standard expects an intervening driver circuit, and why the definition of a UART mentions one in its second sentence. A transceiver such as the MAX232 does three jobs at once: it translates between the logic levels and the line levels, it protects the internal circuitry from shorts and transients on an exposed connector, and it supplies enough current to meet the slew rate the standard demands. The high voltage swing in RS-232 is not gratuitous either. Single-ended signalling against a shared ground has poor noise immunity by nature, so the standard buys margin with a large swing and pays for it in power consumption and the need for positive and negative supplies.

For logic-level UARTs the rule is simpler but just as absolute: two UARTs work reliably when they share a voltage domain, and when they do not, an external level shifter is required. There is no negotiation and no degradation curve. Table the domains, shift between them deliberately, and never let a 5 V part drive a 1.8 V pin on the assumption that a signal within the range will be tolerated.

This is also why a USB-to-serial adapter is far more than a wire, and why its two ends are not interchangeable. It contains a UART and a level shifter, and the logic-level pins on the board side are not the same electrical thing as the DE-9 on the other.

What to take away

The next time a serial link fails, the useful first question is which layer is failing, because the layers have almost nothing to do with each other and neither do their failure modes:

  • A UART problem is a configuration problem. Wrong bit rate, wrong parity, wrong stop bits, wrong flow control. Both ends are speaking correctly and disagreeing about the format.
  • An RS-232 problem is an electrical problem. Too much cable capacitance, different ground potentials, no level shifting where there should be.
  • A functional problem is a wiring problem. The data pins are the two that matter, and the handshaking pins are what everyone gets wrong when they build a null modem cable by hand.

The real reason to keep the layers straight is the design freedom it implies. The same UART block, with the same framing code and the same registers, will talk happily over a 3.3 V trace to a nearby sensor, over an RS-232 cable to a legacy instrument, or across an RS-485 bus into a noisy industrial cabinet. Only the transceiver changes. That is not an accident of history, it is the entire point of separating a data link layer from a physical one, and it is what a generation of engineers lost track of when “serial port” became a single word for three stacked standards.


Sources: Wikipedia: Universal asynchronous receiver-transmitter; Wikipedia: RS-232; Wikipedia: RS-485; Wikipedia: Baud; Wikipedia: Teleprinter; Wikipedia: Parallel communication; Wikipedia: Serial Peripheral Interface; Wikipedia: I²C; ITU-T Recommendation V.24 (official page); Texas Instruments PC16550D datasheet, SNLS378C, rev. C (FIFO and baud generator figures; the part is retired and Texas Instruments no longer serves the document, so this is a mirrored copy); National Semiconductor AN-0493, A Comparison of the INS8250, NS16450 and NS16550AF Series of UARTs, Martin S. Michael, April 1989.

Comments are reviewed before they appear. Yours will be published once it has been approved.

Leave a Reply

Your email address will not be published. Required fields are marked *