ESP32 C3 dual UART or over native USB?

okw123
Posts: 8
Joined: Sat Aug 24, 2024 1:08 pm

ESP32 C3 dual UART or over native USB?

Postby okw123 » Mon Aug 26, 2024 11:22 am

I just designed a custom board with ESP32 C3 (chip, not module) with a UART-to-RS232 module connected to U0RX/U0TX (pin27/28).
The problem is, I need print for debug messages, but this automatically ends up on the same U0RX/TX. I use Aruindo IDE and/or PlatformIO. As I read in the datasheet, C3 only have 1 hardware UART?
I have experience with ARM, and they have RTT (Real Time Transfer). Over RTT I can print debug messages without sacrificing a UART resource or dedicate extra pins. Anything like this possible over the native USB interface (gpio18/19)?

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 C3 dual UART or over native USB?

Postby ESP_Sprite » Tue Aug 27, 2024 12:01 am

The native USB interface will show up as a serial port; it's indeed intended for debugging as you describe. Just change your menuconfig configuration (under 'logging' iirc) to make the USB-serial-JTAG the primary log output. However.... the C3 actually has *two* UARTs, so you can also simply use the 2nd one for your device while keeping the 1st one for logging. Maybe you're thinking it only has one because the pinout only indicates one set of TX/RX pins? The ESP32 can route most peripherals to any GPIO pin, so the 2nd UART doesn't have a dedicated set of pins.

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32 C3 dual UART or over native USB?

Postby lbernstone » Tue Aug 27, 2024 7:19 pm

The configuration for arduino-esp32 has the console sent to both the usb-cdc and uart0. Changing this requires recompiling the sdk. If you can use different pins on uart1 as ESP_Sprite suggested, that would be easiest. Otherwise, you can look into using Arduino as an ESP-IDF component.

Who is online

Users browsing this forum: No registered users and 55 guests