UART high speed question 4MHz

zliudr
Posts: 358
Joined: Thu Oct 03, 2019 5:15 am

UART high speed question 4MHz

Postby zliudr » Sat Feb 12, 2022 4:42 am

I'm considering interfacing ESP32 with Teensy that can do very fast UART. I read from hardware reference that ESP32 can do 5MHz UART. I didn't find any reference that requires the pins to be specific for this speed though. So am I correct to assume that the UART hardware can be attached to any pins and work at 5MHz baud? Thanks.

zliudr
Posts: 358
Joined: Thu Oct 03, 2019 5:15 am

Re: UART high speed question 4MHz

Postby zliudr » Sun Feb 13, 2022 6:04 am

Well, I gave this a test. I can confirm that 4MBaud works under Arduino IDE, Teensy to ESP32. I used IO4 for ESP32 RX. I didn't test TX since I was just holding a jumper wire to connect the boards. I wonder if the default set up uses DMA transfer. That would be sweet! Should I declare a static array with some DMA attribute or malloc with capability set to DMA ram or something?

michcfr
Posts: 30
Joined: Mon Jan 29, 2018 5:55 pm

Re: UART high speed question 4MHz

Postby michcfr » Mon Feb 28, 2022 1:44 pm

Hello,
I did the same but between two ESP32: one ESP32 sends n bytes and the other sends back the n bytes.
The max speed was 600 kbaud. How did you get 4MBaud?

thx for the response

alkorismus
Posts: 8
Joined: Tue Feb 26, 2019 1:55 am

Re: UART high speed question 4MHz

Postby alkorismus » Tue Mar 01, 2022 2:44 am

Hi, I read this (original) post some days ago, but now I decide to share something about my experience.

I am interested with UART communication on the ESP32, and so I did some basic tests, nothing very systematic, and was only able to get stable serial to work at about 460 Kbaud... (Arduino IDE code on ESP to Python code on the "host-device" side)

I ONLY tested data FROM the ESP32 to a "host-device", in this case a RPI4 SBC.

At 921 Kbaud, it sometimes give errors, so, it works but I could not find a way to achieve it as "stable"... so I went down to 460K...
Also, around 600K it does seems OK... but I did not stay there, going back to 460K, 230K, where I can confirm, sending data from ESP32 was/is stable.

I tested on a ESP32-WROOM-32D (on DevKitC) and ESP32-WROOM-32E (on ESP-CAM), and the results are similar...

The DevKitC is using the USB/Serial Adapter, and the ESP-CAM is directly connected with the RPI4 GPIO tx/rx pins (no USB here)...

My interest now is to send data from ESP32 to a "host-desktop" machine, so I only tested this way (ESP to PI4).

So, what I am saying is that my little results are within the "same envelope" as michcfr, 460K, 600K...

Of course, I am interested to have it work, as far as possible...

I will also run/try later, to see how far I can get serial to work, in terms of the length of the wires, ESP32 TX to PI4 RX (or some USB/Serial Adapter)... I want to get a good understanding about this issue, because I intend to have some ESP-CAM sending pictures BY-WIRES, instead of just WIFI.

The idea here is to use the on-chip tx/rx I/O, with on-board tx/rx I/O on some SBC device, just connecting them by wires. Excluding so, the use of any special cable-device for long range communication.

I am now running some tests with WIFI, and after some data on that, I will go/try the "serial long wires" thing...

I even entertain the possibility to invent some kind of "discret" buffer on the wires, repeated at some space interval, so that, in the end, it is achievable to transfer data to some distance (I am talking about 10 meters plus/minus)... of course, some "speed" will be nice to have, otherwise it won't help with my objective...

Not sure how far this experiment will go, but this is the current idea...

After finishing some WIFI tests, I will publish the results, the methods and the scripts/code used, so that anybody can reapeat the tests and collect their own data... NOW, I am thinking that, such kind of (data) results, methods and script tools are also useful for UART, so that, we will end up building a "knowledge base" around the subject...

The ESP32 works well at 921 Kbaud to receive programming (upload firmware), so, from this we can assume that RECEVING data at such speed is VERY STABLE... it would be nice to also achieve such stable behavior when SENDING data...

Better, if we build some tests, collect data and use common methods and tools (scripts), we will end up with the knowledge to get the best results from the ESP device... and THIS IS my quest now...

I have posted about the WIFI issue here:
https://www.esp32.com/viewtopic.php?f=12&t=26240

I like to close the message with a quote from Lord Kelvin, on the subject of data and science:
“When you can measure what you are speaking about, and express it in numbers, you know something about it, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind; it may be the beginning of knowledge, but you have scarely, in your thoughts advanced to the stage of science.”
Regards,
thanks zliudr, michcfr for sharing,
Valter

zliudr
Posts: 358
Joined: Thu Oct 03, 2019 5:15 am

Re: UART high speed question 4MHz

Postby zliudr » Tue Mar 01, 2022 3:39 am

Are we talking about the same thing?

ESP32 dev board talking to a host PC/RPI via USB is going through the CP2102 chip, which has a max baud rate of 921600 so if you go near or beyond this rate on ESP32, the CP2102 chip will not be able to carry that UART traffic to your host PC/RPI!

RPI's internal serial port should also have some limitation possibly lower than 4MBaud that ESP32 can do.

What I tested was between ESP32 and Teensy 4.1 both at 4MBaud, not USB-UART IC or RPI involved.

michcfr
Posts: 30
Joined: Mon Jan 29, 2018 5:55 pm

Re: UART high speed question 4MHz

Postby michcfr » Tue Mar 01, 2022 9:19 am

I think we have to dissociate the two cases:
-UART to UART communication with one wire TX/RX. This is the subject of this topic
-UART to UART/USB adapter (CP2102)

For the latter case, maybe the RTS/CTS usage may enhance the throughput because of hard flow control.

zliudr: what esp32 lib are you using for the UART?

michcfr
Posts: 30
Joined: Mon Jan 29, 2018 5:55 pm

Re: UART high speed question 4MHz

Postby michcfr » Tue Mar 15, 2022 12:48 pm

A little up...

zliudr
Posts: 358
Joined: Thu Oct 03, 2019 5:15 am

Re: UART high speed question 4MHz

Postby zliudr » Mon Mar 28, 2022 5:04 pm

Sorry I didn't see this. I was just using ESP32 arduino so the uart library is just the Serial1 code. There's no complicated library to use it.

Who is online

Users browsing this forum: No registered users and 80 guests