What's difference between RS232 and UART in context of programming ?

Thread Starter

John99407

Joined Jul 12, 2019
77
Hi,
RS232 and UART both are serial protocol, UART and RS-232 are not the same but I do not understand how RS232 is different then RS232. UART is responsible for sending and receiving a sequence of bits.
What's basic difference between RS232 and UART in context of programming ?
 

cmartinez

Joined Jan 17, 2007
8,218
UART is a communications protocol, whilst RS232 defines the physical signal levels. That is, while UART has everything to do with logic and programming, it has nothing to do with the electronics per se. Whilst RS232 refers to the electronics and hardware needed for serial communications.

Google "rs232 signal levels and pinout".
 
Last edited:

OBW0549

Joined Mar 2, 2015
3,566
UART is a communications protocol,
Ummm... no.

whilst RS232 defines the physical signal levels.
That part is true.

That is, while UART has everything do with logic and programming, it has nothing to do with the electronics per se.
A UART is the physical piece of hardware that handles the sending and receiving of the serial data. It can either be on a chip by itself, such as a 16650 or 8250 or numerous others, or implemented as an on-chip peripheral on a microcontroller chip. But a UART is not a communication protocol; it implements one.

Whilst RS232 refers to the electronics and hardware needed for serial communications.
RS-232 is a physical interface specification that ensures devices can be interconnected and successfully send and receive signals, without letting out any of the Magic Smoke.
 

SamR

Joined Mar 19, 2019
5,031
To simplify, RS232 is the standard, UART is the hardware. There have been several UART chips over the years as baud rates increased.
 

MrChips

Joined Oct 2, 2009
30,704
This is where the confusion arises. No wonder that the newcomer is confused.

RS-232 is the standard. Not only does it define voltage levels and rise and fall times, it goes so far as defining the type of connector and the pins assigned to each signal. Later revisions of the RS-232 standard defined data encoding protocol.

UART is a chip that implements part of the RS-232 standard protocol, not the electrical part. Thus it is common practice to refer to the UART as a protocol even though it is just a piece of hardware.

From a programming perspective, which is what the TS is inquiring, the software interacts with the UART module in order to send and receive serial data confirming to the NRZ (non-return-to-zero) communication coding mechanism. Strictly speaking in order to avoid confusion, RS-232 should be reserved for discussion of the voltage conversion interface that converts the 0-5V (TTL) signals to -5V to +5V (or greater, such as -15V to +15V). There are other voltage standards such as RS-422 and RS-485 which are also in use for serial communications.

https://ipc2u.com/articles/knowledge-base/the-main-differences-between-rs-232-rs-422-and-rs-485/
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
Thus it is common practice to refer to the UART as a protocol even though it is just a piece of hardware.
The old/original software protocol offered many options for the data format, up to 8 bit data, parity/no parity - software handshake (as opposed to hardware) - binary/ASCII and the later MODBUS/CANBUS etc.
It was often said it has so many options that it is hardly a standard! ;)
Max.
 

cmartinez

Joined Jan 17, 2007
8,218
But a UART is not a communication protocol; it implements one.
Thanks for the clarification. I stand corrected.

UART is a chip that implements part of the RS-232 standard protocol, not the electrical part. Thus it is common practice to refer to the UART as a protocol even though it is just a piece of hardware.
My initial comment falls in that category.

A UART is something you program, RS232 is something you physically connect.
Bingo! :)
 

nsaspook

Joined Aug 27, 2009
13,079
I recall using it this way, back then! ;)
Also using the RTS, CTS, DSR for working with tape punch readers etc, i.e. turn them on remotely.
Now, and for a while, Null-Modem with handshake jumpered is used due to high speed peripherals.
Max.
You still see RTS, CTS flow-control at the logic signal level when interfacing things like BLE modules to control data flow when the RF drops out momentarily.
http://www.summitdata.com/blog/uart-flow-control-rtscts-necessary-proper-operation-wireless-modules/
 

BobaMosfet

Joined Jul 1, 2009
2,110
Hi,
RS232 and UART both are serial protocol, UART and RS-232 are not the same but I do not understand how RS232 is different then RS232. UART is responsible for sending and receiving a sequence of bits.
What's basic difference between RS232 and UART in context of programming ?
Think of it this way- uart is short-range communication (usually inches or less) between ICs. RS232 is long-range communication (up to several feet). You talk to an RS232 IC using uart so that you can easily communicate very simply, and let the RS232 IC to the heavy lifting for distance and a more robust signal control that uart.

Check a datasheet for a MAXIM MAX232CPE ttl/uart to RS232 tranceiver.
 
<Mod:Site promotion link Deleted>

UART (TTL)

Microcontrollers work between 0V and Vcc with Vcc being 3.3V or 5V. These voltage levels are called TTL (Transistor-Transistor Logic) representing 0V as a logic 0 and Vcc as a logic 1. UARTs that are output on a microcontroller’s pins, like your typical Arduino UART connection, use TTL to differentiate between a 0 or a 1 while sending or receiving data. Not all systems and standards expect TTL signals which is the root of a lot of confusion with UART vs RS232 and serial to usb converters.

RS232

RS232 (Recommended Standard 232) is just a standard that defines what voltage levels should specify a logic 0 or logic 1 in UART serial communication. Instead of using TTL, RS232 defines a logic 0 as a voltage between +3V and +15V, and logic 1 as a voltage between -3V and -25V. This is why trying to read RS232 directly out of a microcontroller will not work. These higher voltage signal levels make the protocol somewhat less susceptible to noise. Because of this, RS232 signals can communicate across a longer distance than TTL signals.

One other key feature of RS232 is the connector type. Almost all RS232 in industry (that I've seen) use D-Subminiature (often called D-Sub for short), 9-pin connectors called DE-9 connectors. If you see a serial port going to a 9-pin D-Sub connector you can pretty much assume it is RS232. Although there are many other signals aside from Tx and Rx that are defined in the RS232 standard (like RTS - Request to Send and CTS - Clear to Send), most often they can be ignored.

Adapters and Converters

There are lots of chips that convert TTL UART levels to RS232 and vise versa. Some of the most common are made by FTDI and Maxim Integrated Products. These ICs relies on external capacitors in a charge pump configuration to create the positive and negative voltage needed for RS232. These chips connect to your microcontrollers UART Rx and Tx pins so from a programming prospective, there is no change between TTL and RS232.

You can also buy serial to USB adapters for TTL or RS232 so that you can interface with the UART from a standard computer. When buying a RS232 to USB converter, make sure to double check that the D-Sub connector has the correct male or female screw terminals for your needs.
 
Last edited by a moderator:

Jon Chandler

Joined Jun 12, 2008
1,029
Thank you @braden_sun for succinctly covering the question the TS has asked. When it comes to interfacing with a microcontroller, UART serial is the serial I/O at the 5v or 3.3 volts the micro uses. This signal can interface directly to boards and modules designed to be directly connected to a microcontroller.

RS-232 is in the same data format as UART I/O (baud rate, data bits, stop bits), but the 0v & 3.3V or 5V levels are inverted and shifted to +5-12V and –5-12V levels, which is often used for connecting to devices like modems, printers and voltmeters (like a Fluke benchmeter). Often DB9 or DB25 connectors are used for these devices.

A chip like a MAX232 (numerous varieties) is usually used to convert between UART and RS232 voltage levels.
 

dendad

Joined Feb 20, 2016
4,451
Just to add my ore to the pond..
Wikapedia has a pretty good definition I think. https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter

The programmable part to get raw data and out of the CPU. Electronicd as a dedicated chip or implemented inside the controller....
"A universal asynchronous receiver-transmitter (UART /ˈjuːɑːrt/) is a computer hardware device for asynchronous serial communication in which the data format and transmission speeds are configurable. It sends data bits one by one, from the least significant to the most significant, framed by start and stop bits so that precise timing is handled by the communication channel."

Then for the other part. The physical bits. These "RSxxx" standards define electrical and mechanical specs of the hardware.

"The electric signaling levels are handled by a driver circuit external to the UART. Two common signal levels are RS-232, a 12-volt system, and RS-485, a 5-volt system. Early teletypewriters used current loops."

There are still more protocol levels that define how the signal packets are encoded that run on top of all this. Like MODBUS etc.
 

Ian0

Joined Aug 7, 2020
9,667
Back in the original Intel v. Motorola days, UART was the Intel term and Motorola called it a Asynchronous Communications Interface Adaptor (an example being the 6850). Nowadays, the term SCI (Serial Communications Interface) is frequently used when it is a peripheral included within a microcontroller.
 
Top