Adafruit_TinyUSB_Arduino icon indicating copy to clipboard operation
Adafruit_TinyUSB_Arduino copied to clipboard

Enable multiple serial over usb for rp2040

Open westinpigott opened this issue 1 year ago • 2 comments

We utilize multiple serial ports on RP2040 boards. We do so today by manually editing the library (the change is committed). I can verify the RP2040 has no problem running multiple USB Serial Interfaces at the same time.

Example below how to initialize in .ino file for 2 Serial ports at same time,

#include <Adafruit_TinyUSB.h>
Adafruit_USBD_CDC USBSer1;

// In setup method
// Setup Serial
Serial.begin(115200);
// initialize 2nd CDC interface
USBSer1.begin(3686400);

westinpigott avatar Sep 03 '24 18:09 westinpigott

enable multiple CDCs take more memory, most people don't need it, that is why it is not enabled by default.

hathach avatar Sep 05 '24 10:09 hathach

Ok. That makes sense. What is the recommended way to enable multiple when needed? Just edit the library file like I did?

westinpigott avatar Sep 05 '24 11:09 westinpigott

is this still a thing? haveing this in place I would assume the issue is solved?

#ifndef CFG_TUD_CDC #define CFG_TUD_CDC 1 #endif

nerdyscout avatar Nov 13 '24 10:11 nerdyscout

An update. There is a strange bug when running the serials at fairly high baud (3,000,000+). Occasionally if you try to write out on one while receiving on the other, it will result in a complete lock up of the Rp2040.

I’m not sure if this is a library issue or a hardware issue. I suspect there is a way to do it using the PIOs onboard, but I never came back around to the issue. Just figured out how to multiplex the different signals over the single serial line.

TLDR; this works fine at lower baud speeds (<1M probably )

westinpigott avatar Nov 13 '24 12:11 westinpigott