4
\$\begingroup\$

This question already has an answer here:

I always need to communicate with the TTL UART port on the MCU with a computer. When I talked about that, people always refer the UART port as an RS-232 port. Are they correct? If not, what is the difference between them?

Also, can I use a RS-232-to-USB converter for a TTL UART port?

\$\endgroup\$

marked as duplicate by Ignacio Vazquez-Abrams, tcrosley, CL., ThreePhaseEel, uint128_t Dec 11 '16 at 17:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    \$\begingroup\$ About 7 to 10 volts, plus or minus \$\endgroup\$ – Passerby Dec 11 '16 at 8:08
5
\$\begingroup\$

The port on your USB<->RS-232 converter will output something like +/-9V and can accept +/-25V or short circuit without damage.

The UART on your MCU uses logic level (0V/3.3V or 0V/5V typically). Applying less than 0V or more than Vcc can destroy the MCU chip.

Also the logic levels are inverted between the two types (excepting an option on a very few MCUs).

To bidirectionally invert and convert between the UART levels and RS-232 levels one would typically use a chip such as the MAX232 (for 5V logic). The MAX232 also generates its own +/-9V supplies from a single +5V supply using a charge pump voltage doubler.

TL;DR:

No you cannot use the USB-RS-232 (aka USB-serial) cable to connect the two. There are USB-TTL Serial converters available cheaply. There are some gotchas with the cheapest Chinese ones as far as 3.3V operation goes, be sure to research it a bit. Adafruit carries such devices for $10. I think you can find them at Digikey and other sources as well.

enter image description here

Since the hardware interface is not defined by any standard at the MCU end they are typically furnished with uncommitted fly wires with female terminals to mate with 0.025" square pins as you would find on a 0.1" pitch header. I bought half a dozen similar devices for my firmware programmer and she's been using them to talk to various development boards.

\$\endgroup\$
6
\$\begingroup\$

UART = Universal Asynchronous Receiver/Transmitter. It is the basic chip (or virtual function in a microcontroller) which encodes the data bits serially into a standard format with a start bit, stop bit(s), speed, etc. But "UART" is only PART of what "RS-232" is.

RS-232 adds the legacy voltage values to the binary values (0/1 or hi/lo, or "mark" and "space" in RS-232 talk). A TTL UART will output (and input) only TTL levels, essentially 0 bit = 0V and 1 bit = 5V. And many modern-day gadgets (Arduino, et.al.) simply use TTL voltage levels for serial communication. But the "proper" definition of RS-232 used a rather HIGHER and BIPOLAR voltages to define zero and one. Specifically:

  • 0 bit = "space" = +3V ~ +15V
  • 1 bit = "mark" = -15V ~ -3V

Those voltages date back to the old electromechanical days of Teletype machines which were a miraculous monstrosity of mechanical marvel. And those rather high voltages were needed control the electro-mechanical bits.

But in modern days, the old RS-232 protocol remains as a useful standard, but those old high bipolar voltages are rather a thing of the past. And it seems rather likely that a whole new generation is growing up that will never remember anything about those old voltage levels and will think that RS-232 is an old legacy 5V protocol. Especially when power voltages are all migrating toward 3.3V logic levels.

Ref: https://en.wikipedia.org/wiki/RS-232#Voltage_levels

\$\endgroup\$
  • 1
    \$\begingroup\$ Actually the bit about the history of the voltage levels is wrong. The reason +/- 15V was chosen was to increase signal-to-noise ratio. It's not about the noise in the transmission, rather it's about getting above the noise floor of the circuits. Another example of this design choice was early PLCs (industrial computers). Some used 20V RAM, yes RAM to overcome the noise floor of all the electrical equipment in a factory. \$\endgroup\$ – slebetman Dec 11 '16 at 11:32
  • \$\begingroup\$ Although R.C. mentioned it in the two last sentences, I'd reiterate: UART on 3.3V uCs is also 3.3V, a detail that's IMO worth highlighting if one doesn't want to fry his chips; most USB<->UART solutions I've seen allow to change the levels here; although 3.3V ain't strictly "TTL level", I've commonly seen those "TTL UARTs" outputting a 3.3V high signal. OTOH, many RS-232-compliant hardware used nowadays accept TTL-ish levels (i.e. they interpret 0V as valid logical high), allowing to use them with those "TTL UARTs" with only signal inversion, which is then usually done in software. \$\endgroup\$ – vaxquis Dec 11 '16 at 13:17
1
\$\begingroup\$

I always need to communicate with the TTL UART port on the MCU with a computer. When I talked about that, people always refer the UART port as a RS-232 port. Are they correct? If not what is the difference between them?

Reading between the lines, you may be talking about the case where you have a board with an MCU which can be accessed (download code, debug, etc) via the USB port on your computer. It is quite common now to operate that way.

If so, it's likely that your operating system is setting up a "virtual RS-232" port for your device. This isn't actually an RS-232 port, at all. Instead, it's some software running as a driver under your operating system which emulates the details of an old-style "serial port" driver. This software communicates with a separate MCU (one that is also on the board with your MCU) via a USB-to-serial converter chip (there are a number of manufacturers for those, as well.) The separate MCU is what is actually connected to your MCU's UART port pins. Likely, it's also connected to your MCU's JTAG pins, too, so that debugging can take place. There is additional software in this separate MCU that handles the details of both debugging AND UART communications with the operating system of your computer.

So. Yeah. People refer to that as an RS-232 port, when they are thinking about this from the point of view of how the operating system + driver software causes it to appear to an application program running on that operating system. You could then use any standard application which knows how to open up an RS-232 port using the standard function calls that the operating system provides for that purpose and it would work fine. So it is an RS-232 port from the point of view of that application program.

But in reality, it's not.


Separately, a UART is a "universal asynchronous receiver/transmitter" and traditionally referred to an IC chip or else to a functional block in an MCU. Either way, it was usually hardware designed to make it easy for software you write to handle the asynchronous serial protocol used (start bit, data bits, and one or more stop bits.) It's possible to bit-bang the protocol, but it is a real pain and high speed becomes more or less unobtainable then.

You will also see USARTs -- universal synchronous/asynchronous receiver/transmitter -- on some MCUs, as well. It just means they can do more than a UART, but that they include the UART capabilities as well.

RS-232 is a set of specifications about voltages, loading, and so on. It specifies a bunch of signalling details, as well, covering quite a few different available signal lines. But it is better to see RS-232 as an electronics specification defining voltage ranges for mark and space, noise margins, allowable receiver loading details, and various other details involved in translating between analog signal ranges and discrete digital ones and not so much about some specific UART's serial protocol.

I'm just going to refer you to Wiki pages for details (which you should have read before asking here, I think.) These are: RS-232 and UART. I have no real desire in duplicating that work.

\$\endgroup\$

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