I'm using a custom board based on feather M0. I'm trying to use Serial for pins PB22-TX and PB23-RX and Serial1 for pins PA10-TX and PA11-RX, and finally SerialUSB for programming and debugging.
Serial1 is working, but Serial seems to out the bytes through the USB and not for Serial pins that I expected: PB22-TX and PB23-RX.
I read there is a tutorial explaining how to adapt sketches to M0: Sketches to M0 & M4. https://learn.adafruit.com/adafruit-fea ... ches-to-m0
Well, I'm trying to avoid what this tutorial seems to fix or adafruit feather core as fixed using Serial and SerialUSB.
How can I undo this option to use Serial and SerialUSB??
create your own variant like this
Ok. I tried to navigate to variants of feather M0 but I could not change issue using Serial is like SerialUSB... there has to be a #define in another file.
Actually, I want to undo what this post explains:
so in my_boards I refer for M0 to Arduino SAMD package. the customized board is based on M0. in Arduino boards package Serial is configured for M0 Pro with EDBG chip. my M0 doesn't have an EDBG chip so I wanted to have Serial as SerialUSB.
so I removed the SERCOM configuration for Serial in variant.h/.cpp and I added
#define Serial SerialUSB
Arduino boards such as the Due and Zero have both a native USB and a USB to Serial port, named "SerialUSB" and "Serial" respectively.
With the advent of smaller boards such as the Arduino's MKR series and Adafruit's Feather/Itsy Bitsy only the native USB port has been retained. Adafruit have opted to call the native USB port "Serial", rather than "SerialUSB".
The Feather's UART pins on TX1 (PA10) and RX0 (PA11) pins are named "Serial1".
As you mention, addition Serial ports can be added following Adafruit's tutorial. However, if your custom board is based on the Adafruit Feather M0 basic, rather than the Adafruit Feather M0 Express, then the UART on pins PB22 and PB23 has already been implemented for you in the core code as "Serial5".
Ok. Thank you for fast reply and comments.
I have checked that with Sparkfun SAMD21 Dev Breakout I can use SerialUSB, Serial and Serial1 as I want to, so I might change my customized board based on Sparkfun Dev Breakout instead on an Adafruit Feather M0. So, I only have to configure the pinout of my firmware to Sparkfun SAMD21 Dev Breakout.
It's not possible to change "Serial1" without modifying the board's "variant.h" and "variant.cpp" files, as this has already been defined in the core code on practically every M0 board.
Switching between "Serial" and "SerialUSB" for the native USB port is a minor consideration and can be changed by simply adding the code:
#define Serial SerialUSB
...at the beginning of your sketch.
If your custom board is based on the Adafruit M0 basic, you also get "Serial5" on PB22 and PB23 as well, just by calling:
Ok. I didn't see the Serial5 definition in variant.h.
It's working. So, now I can use 3 Serials as I wanted to.
Thank you for support.