UART Interface for 8051 Serial Communication - Page 1
Forum section: electronics / general

author: EVblog1
author_rank: Contributor
timestamp: June 29, 2025, 10:45:28 am
content: I just want to check my understanding of UART and get your advice on which interface would be most suitable for my setup.Here’s what I’ve understood so far:UART is a peripheral inside the microcontroller that enables serial communication using TX and RX lines. It doesn’t use a clock signal, and communication happens using frames which include a start bit, data bits, an optional parity bit, and stop bits. The baud rate defines how many bits are transferred per second and must be the same on both ends.I’m working with an 8051 microcontroller and want to send data to my laptop using Keil. I have three interface options:CP2102 USB-to-TTL converterUSB to RS232 adapterRS485 converterNow, the AT89S52 runs on 5V logic, and I noticed the CP2102 operates at 3.3V logic. That’s where I’m a bit stuck I couldn’t find the exact schematic of my CP2102 module.Can I connect the CP2102 directly to the 8051 UART pins? Or should I use a voltage divider or logic level shifter to protect the CP2102 RX pin?Also, among the three interfaces, which one and why would you recommend for basic UART communication from 8051 to laptop?

author: ledtester
author_rank: Super Contributor
timestamp: June 29, 2025, 11:36:59 am
content: Quote from: EVblog1 on June 29, 2025, 10:45:28 amAccording to:https://learn.sparkfun.com/tutorials/cp2102-usb-to-serial-converter-hook-up-guide/all#:~:text=All%20of%20the%20serial%20interface%20pins%20are%205V%20tolerant.the serial interface pins are 5V tolerant.This is reaffirmed by the datasheet:https://www.silabs.com/documents/public/data-sheets/CP2102-9.pdfin the Absolute Maximums section.So the MCU TX pin can send 5V to the CP2102 RX pin.And even though the CP2102 TX pin only produces 3.3V, this should be high enough to register as a logic high on a 5V MCU.

author: Sorama
author_rank: Frequent Contributor
timestamp: June 29, 2025, 12:07:54 pm
content: We use 8051 compatible processors too on our automation controllers, but always interface with it though a max232 rs232 converter ic.

author: neillnz
author_rank: Contributor
timestamp: June 29, 2025, 11:42:01 pm
content: I use this:https://ftdichip.com/products/ttl-232r-5v-we/Being a genuine FTDI product is is not the cheapest option but it works perfectly.

author: EVblog1
author_rank: Contributor
timestamp: July 06, 2025, 06:32:48 am
content: I tested it we can directly connect the CP2102 to the 8051 UART pins, no level shifter or voltage divider is needed and UART communication works fine. I was able to receive the data correctly on the serial terminal.Thank you all for your help!

author: Sorama
author_rank: Frequent Contributor
timestamp: July 06, 2025, 07:19:40 am
content: Still I would advice to put something in between on a socket.If there is over voltage or lightning it’s easier to swap a driver in a socket than to swap a (soldered?) processor.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: July 07, 2025, 09:54:58 am
content: Quote from: neillnz on June 29, 2025, 11:42:01 pmPlease define "works perfectly". Quite a long time ago the FTDI chips were quite popular, and the Chinese started making clones of them. FTDI reacted by bricking devices which used the cloned chips by deleting USB descriptors in those chips, and after that got too much backlash, they reversed that, but started implementing various other anti features such as injecting ascii characters in the data stream. For more info, search for "FTDIgate". I was not affected by this, as I am using Linux, and don't use the FTDI drivers at all, but none the less, I still avoid using IC's from that company. CP210x and CH340 all work fine on my linux box.I can't really blame FTDI for wanting to do something against other companies using their driver software, but lots of consumers do not have any influence on what IC's are inside the gadget they buy, and they are duped by this behavior none the less.-------------------------------------------USB to RS485 is not really suitable RS485 uses differential signalling over two wires, and it also combines the Rx and Tx wires onto the same differential pair. You can use RS485, but then you also have to use an RS485 driver on the 8051 side, and this also needs a pin to change the direction of the RS485 driver. RS485 is pretty cool, you should look into it some day, but not just yet.USB to RS232 drivers are a bit "old fashioned". RS232 was invented some 50 -odd years ago and uses pretty high signal voltages. Officially something like +7 to 12V and -7 to -12V. but over time these high voltages have been sort of scrapped from the standard, and (probably non "officially" compliant) versions use something close to 0V and 5V. What is important is that RS232 inverts the signals, So for the RS232 chips, you also have to invert the signals again before they go into your 8051.CP2102 (or CH340) should work, and so would the FTDI chips. The versions with "TTL" outputs are not inverted, and as a result you also do not have to invert the signals between these adapters and your 8051. When you go from a 3V3 IC to a 5V IC with CMOS inputs, then the input signals are a bit borderline, but usually it works, but it's not a very robust solution. It's also far from ideal to roue microcontroller pins directly to a connector. You can do this on your bench (in your lab), but uC pins are quite fragile, and with connectors (and long wires) you introduce ESD events and other electrical disturbances onto your PCB, and for a reliable solution there should be extra protection and filtering on all signals (and power lines) that enter or leave your PCB.