Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable multiple serial over usb for rp2040 #452

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

westinpigott
Copy link
Contributor

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);

@hathach
Copy link
Member

hathach commented Sep 5, 2024

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

@westinpigott
Copy link
Contributor Author

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

@nerdyscout
Copy link

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

@hathach hathach closed this Nov 13, 2024
@hathach hathach reopened this Nov 13, 2024
@westinpigott
Copy link
Contributor Author

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 )

Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of forgot this, I think rp2 has enough sram to change it to 2. So let merge this one

@hathach hathach merged commit f8ac813 into adafruit:master Nov 15, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants