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

Please add Arduino support for Serial2, Serial3, etc, on the M4 Express boards #3

Open
Andy2No opened this issue Jan 28, 2024 · 3 comments

Comments

@Andy2No
Copy link

Andy2No commented Jan 28, 2024

This have been discussed several times in the Adafruit forum, and appears to still be unresolved. There is apparently no definition for Serial2, Serial3 etc, for these board variants, and no documentation on how to make them work, despite there being configurable SERCOMs that should support them.

For example, search the forum for the words;

M4 Serial2

Here's a search link to do that:

https://forums.adafruit.com/search.php?keywords=serial2+m4&sort=BestMatch

@dhalbert
Copy link

dhalbert commented Jan 28, 2024

Have you seen this: https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports ? It was written before SAMD51 boards came out but it should work the same.

@Andy2No
Copy link
Author

Andy2No commented Jan 28, 2024

I hadn't. Thanks. I'm still not clear how to apply it to each particular M4 board Adafruit makes though, and I'm not clear why Serial was redefined, on the second page, instead of defining Serial2. Is there a reason for that?;

https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/muxing-it-up

Apart from the individual board and chip details, the recommendation seems to be for us to produce new variants, with the added feature. Perhaps I'm misunderstanding that part.

I would hope that us mere mortals would have the opportunity to just define a new Serial object with a pair of valid pins, e.g. just using this line from that page, but with a more sensible name;

Uart Serial2( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;

Is that possible? If so, perhaps all that's needed is a new page of documentation that relates to the current M4 boards, with a table of details for each one.

It would be nice to have a table clearly stating which pins can be used for each board.

@dhalbert
Copy link

dhalbert commented Jan 28, 2024

Uart Serial2( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;

That kind of example is given in https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/creating-a-new-serial. There is also discussion on that page of the SAMD51.

The problem is that the correspondence between pins, pads, and functionality on the SAMD boards is not very regular at all. Also, since SERCOMs can also do I2C, SPI, etc. you may end up blocking out some pins, but only because you've chosen other pins to do other functions. It's very interlocking and not predictable without looking at pinmux tables.

You can do that by hand. You can also use the CircuitPython program given here https://learn.adafruit.com/circuitpython-essentials/circuitpython-uart-serial#wheres-my-uart-2985036 to give you an idea of which pins to use, but you'll still need to specify the pads.

CircuitPython allocates the SERCOMs dynamically, but it can also run into interlocking assignment difficulties because of the order in which it chooses SERCOMs: https://learn.adafruit.com/circuitpython-essentials/circuitpython-uart-serial#trinket-m0-create-uart-before-i2c-2986086

Other chips like the nRF52840 and the ESP line have a full or almost full crossbar, so you can use almost any pin for anything.

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

No branches or pull requests

2 participants