Author Topic: UART Interface for 8051 Serial Communication  (Read 1975 times)

0 Members and 1 Guest are viewing this topic.

Offline EVblog1Topic starter

  • Regular Contributor
  • *
  • Posts: 145
  • Country: 00
UART Interface for 8051 Serial Communication
« on: June 29, 2025, 10:45:28 am »
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 converter

USB to RS232 adapter

RS485 converter

Now, 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?
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 4280
  • Country: us
Re: UART Interface for 8051 Serial Communication
« Reply #1 on: June 29, 2025, 11:36:59 am »

Now, 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?


According 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.pdf

in 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.
 
The following users thanked this post: EVblog1

Offline Sorama

  • Super Contributor
  • ***
  • Posts: 1218
  • Country: be
Re: UART Interface for 8051 Serial Communication
« Reply #2 on: June 29, 2025, 12:07:54 pm »
We use 8051 compatible processors too on our automation controllers, but always interface with it though a max232 rs232 converter ic.
 
The following users thanked this post: EVblog1

Offline neillnz

  • Regular Contributor
  • *
  • Posts: 54
  • Country: nz
Re: UART Interface for 8051 Serial Communication
« Reply #3 on: June 29, 2025, 11:42:01 pm »
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.
 
The following users thanked this post: EVblog1

Offline EVblog1Topic starter

  • Regular Contributor
  • *
  • Posts: 145
  • Country: 00
Re: UART Interface for 8051 Serial Communication
« Reply #4 on: July 06, 2025, 06:32:48 am »
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!
 

Offline Sorama

  • Super Contributor
  • ***
  • Posts: 1218
  • Country: be
Re: UART Interface for 8051 Serial Communication
« Reply #5 on: July 06, 2025, 07:19:40 am »
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.
 
The following users thanked this post: EVblog1

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5404
  • Country: nl
Re: UART Interface for 8051 Serial Communication
« Reply #6 on: July 07, 2025, 09:54:58 am »
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.

Please 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.
« Last Edit: July 07, 2025, 10:10:31 am by Doctorandus_P »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->