128
\$\begingroup\$

Most of the time RS-232 and UART come together in serial communication theories. Are they both the same? From my readings I concluded UART is a hardware form of the RS-232 protocol. Am I correct?

\$\endgroup\$
2

5 Answers 5

132
\$\begingroup\$

No, UART and RS-232 are not the same.

UART is responsible for sending and receiving a sequence of bits. At the output of a UART these bits are usually represented by logic level voltages. These bits can become RS-232, RS-422, RS-485, or perhaps some proprietary spec.

RS-232 specifies voltage levels. Notice that some of these voltage levels are negative, and they can also reach ±15V. Larger voltage swing makes RS-232 more resistant to interference (albeit only to some extent).

A microcontroller UART can not generate such voltages levels by itself. This is done with help of an additional component: RS-232 line driver. A classic example of an RS-232 line driver is MAX232. If you go through the datasheet, you'll notice that this IC has a charge pump, which generates ±10V from +5V.

enter image description here (source)

\$\endgroup\$
4
  • 9
    \$\begingroup\$ The RS-232 definition I have read does not talk about a sequence of bits or timing at all. I fact I have never found an official standard that describes the asynchronous NRZ start-stop protocol. \$\endgroup\$ Commented May 15, 2014 at 6:28
  • 3
    \$\begingroup\$ RS-232 does not specify sequence of bits. \$\endgroup\$
    – slebetman
    Commented May 15, 2014 at 15:03
  • 5
    \$\begingroup\$ Apparently, the development of UART character format was so dominated by the Bell telephone company that no variants sprang up. As a result, the start/data/parity/stop bit format was never the subject of an independent standard. Industry-wide usage was so uniform that no "official" definition was required. This was not true of the physical links, and so RS-232 was developed. \$\endgroup\$ Commented May 15, 2014 at 20:29
  • 5
    \$\begingroup\$ The UART character formats predate Bell's modems, it was in Teletype hardware (eight bit with parity) in ASCII, and Baudot before that. \$\endgroup\$
    – Whit3rd
    Commented Dec 11, 2016 at 9:21
62
\$\begingroup\$

UART (or USART) - Universal (Synchronous) Asynchronous Receiver/Transmitter

This is, essentially, a serial communications interface. The "universal" part means that it can be configured to support many different specific serial protocols. The term is generic, and does not represent a specific standard. At minimum it means that it has a TX and an RX line, which sends a serial data stream and receives a serial data stream.

RS-232 - A standard defining the signals between two devices, defining the signal names, their purpose, voltage levels, connectors and pinouts.

This is a specific interface standard that allows for equipment interoperability. While two pieces of hardware may have UARTs, you don't know that they'll connect without damage, or communicate properly unless you know they have the same pinout and voltage standards, or include a converter or specially wired cable specific to the interconnection of these two specificl devices. To avoid the need for special converters or cables, the manufacturers may choose to follow the RS-232 standard. You know, then, that a standard RS-232 cable will connect the two.

However, neither the UART, nor the RS-232 standard define what is sent on the TX and RX lines. Generally, when people use RS-232, they use a simple 8 bit NRZ encoding with one start bit and one stop bit. Most equipment today manufactured uses this encoding, but there's no requirement to do so. You can find older equipment that includes parity bits, or uses 7 or 9 bits. The UART can be configured to support these various protocols on its TX and RX lines.

UARTs do not typically interface directly with RS-232. You will need to convert the output of the UART to the +/-12V standard that RS-232 requires. A complete RS-232 interface will typically involve both a UART and an RS-232 level converter. Further, the RS-232 standard includes the definition of several other signalling pins besides TX and RX, which you may need to use depending on the equipment you need to connect to. These will also need to be level converted, and your UART may, or may not, support these signals. If it does not you will have to control them with your software/firmware directly.

So while a UART may help you implement an RS-232 interface, it is not an RS-232 interface itself.

\$\endgroup\$
3
  • \$\begingroup\$ Standard RS-232 cable? There is not any such thing. In my equipment bag I carry about a dozen adapters for RS-232. RS-232 specifies a DB-25 connector, but I have seen DD-9, RJ45, din8 and other connectors, and other than hooking a modem to a pc I have never been able to use a COTS cable for any rs232 project. Fortunately 90% of the time a couple adapters will do or a custom cable, they are easy to make. \$\endgroup\$
    – hildred
    Commented May 15, 2014 at 18:40
  • 1
    \$\begingroup\$ Just for the record: I think the 'S' in USART stands for "Synchronous", not "Serial". See here. USARTs are "estensions" over the older UARTs chips which allow also synchronous communication modes. \$\endgroup\$ Commented Jul 3, 2014 at 22:01
  • 1
    \$\begingroup\$ The only "standard" RS-232 connector is the 25-pin D-shell connector, but compliance to that standard is rare. As @hildred wrote, computers and peripherals have used a wide variety of connectors over the years. In general, I would pretend that there is no standard connector and only assume that RS-232 means the voltages and signals will be compatible. \$\endgroup\$
    – David C.
    Commented Jun 17, 2020 at 19:42
25
\$\begingroup\$

The UART functions to convert parallel data from PC bus lines to serial data for transmission via line drivers to RS-232, RS-422, and RS-485 devices. The clock pin of the UART chip is feed by a programmable clock source. The clock speed is determined by the baud rate configuration that the device will be using. The clock speed is 16 X the baud rate. Placing an oscilloscope probe on the clock pin of a UART chip and determining the frequency, then dividing by 16 is one way to determine an unknown baud rate.

\$\endgroup\$
1
  • 9
    \$\begingroup\$ +1 for "converting parallel data to serial data", no other answer here mentions this. \$\endgroup\$ Commented May 31, 2016 at 19:09
4
\$\begingroup\$

RS-232 is a specification only. It defines the signalling requirements for serial communication, by laying out rules and guidelines regarding:

  • Physical wiring, the interconnections between RS-232 compliant devices. Some RS-232 variants also specify which types of connectors and cable you must use.
  • Electrical characteristics of the signals carried by those interconnections (voltage levels, slew rates, impedance etc)
  • Purpose and meaning of those physical lines, such as TX, RX, DCD, CTS etc.

RS-232 does not cover anything to do with the digital electronic hardware you use to implement and comply with those specifications, and importantly it does not cover data framing or error correction or any "datalink layer" type aspects. In other words, RS-232 is closest to a "physical layer" specification, in the OSI model.

You sometimes hear the term "RS-232 protocol", but it is not a protocol, it's a signalling standard.

The actual hardware you use to implement RS-232 compliant communications falls broadly into two categories, neither of which form part of the RS-232 specification (except in the sense that if they do anything that violates RS-232, you can't legitimately call your system "RS-232"):

  • Line transceivers. These are the devices that will translate between the RS-232 compliant signals, which are robust, bipolar (voltages going both negative and positive with respect to ground), and the sensitive digital logic circuitry inside the communicating device, which is usually a UART operating with standard 3.3V or 5V logic levels. Line transceivers also fall under the "physical layer" of the OSI model.

  • UART. This is complex digital logic, usually operating with standard 5V or 3.3V logic levels, and which is responsible for encoding and decoding parallel data into and from serial form. It takes care of framing (start and stop bits), error correction (parity bits), data rate (baud rate), flow control (controlling signals like DCD, CTS, RTS etc.) and many other aspects. As such, it could be viewed as part of the "datalink layer" in the OSI model.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Yes, "physical layer" and "data link layer", those are better words. \$\endgroup\$ Commented Sep 3, 2022 at 13:59
  • \$\begingroup\$ Don't you think it would be more accurate to say "RS-232 is a specification that defines the signalling requirements for serial communication...". It's more than just a specification. \$\endgroup\$
    – SteveSh
    Commented Sep 3, 2022 at 14:15
-2
\$\begingroup\$

RS-232 is before UART.

UART is a device that can define a logical protocol for communication while RS-232 is a device that serves as a physical media for communication.

When we say UART + RS232, it actually means a communication protocol runs on some media, with the chips like MAX232 to adapt the voltages.

We can also use UART + USB (edit) We can also use USB-base chips to provide some virtual UART functionality (edit), with the chips from Prolific Technology, FTDI, Microchip, etc. where we replace the simple RS-232 media with a more complex/recent USB media. We don't even need the hardware UART because it can be implemented over USB in a pure software way.

See below picture. Note that on the right side there's no hardware UART but only hardware USB (edit) the hardware UART is integrated into such chips and a new USB UART driver is used on the embedded side.(edit). And with some extra drivers.

enter image description here Image is from here.

\$\endgroup\$
5
  • \$\begingroup\$ There are multiple issues with this answer. First of all UART is a circuit which implements asynchrohous communications, but asynchronous comms itself existed before RS-232, think of eletromechanical devices. Also FTDI USB chips don't replace RS-232 media with USB media. They are USB UART chips which enable you to make an adapter that allows your PC to have RS-232 comm interface. The UART is implemented by hardware by the FTDI chip, it is not implemented in software. And the diagram does not relate to using FTDI chips but the MCU implementing USB CDC and PC talking CDC with it. \$\endgroup\$
    – Justme
    Commented Sep 3, 2022 at 10:24
  • \$\begingroup\$ @Justme "...to make an adapter that allows your PC to have RS-232 comm interface" I think you mean USB comm interface? And thanks for pointing out FTDI chip still has the UART as hardware. I didn't know that detail. I thought it should be possible to implement the UART protocol in software and leverage USB as a transport. The picture is meant to show how USB can be used as if it is a RS-232. \$\endgroup\$ Commented Sep 3, 2022 at 12:16
  • 1
    \$\begingroup\$ @smwikipedia No I really meant you can use USB UART chip with RS-232 transceiver. You are again confusing things. The picture shows how USB can be used to provide a virtual UART with only USB CDC protocol. There is no UART or RS-232 anywhere, and even then, the RS-232 part would not make sense. Please read existing answers to figure out what each term means and how they relate to each other. \$\endgroup\$
    – Justme
    Commented Sep 3, 2022 at 12:33
  • \$\begingroup\$ @Justme Yes. The picture does show USB is used as a virtual UART with some extra software drivers on both host and embedded sides. It replaces the hardware UART and RS-232 totally. \$\endgroup\$ Commented Sep 3, 2022 at 13:34
  • \$\begingroup\$ The rest of the problems still exist. RS-232 is not a "device" but a specification for a physical interface. And FTDI like chips don't provide virtual UART, they really provide an actual physical UART through USB interface. If you put a MCU and use CDC over USB, then it is a virtual port because there is no UART anywhere. So right side picture has CDC, no UART. \$\endgroup\$
    – Justme
    Commented Sep 3, 2022 at 17:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.