Hi everyone,
I am trying to create multiple UARTs on an ItsyBitsy M4 board using the sercoms, but I cannot get it to work. I also searched this forum, but the given answers wont work either.
Here is my code (from the Adafruit Sercom Tutorial (link)
#include <Arduino.h> // required before wiring_private.h
#include "wiring_private.h" // pinPeripheral() function
#define SERIAL2_RX 10
#define SERIAL2_TX 11
Uart Serial2 (&sercom1, SERIAL2_RX, SERIAL2_TX, SERCOM_RX_PAD_2, UART_TX_PAD_0); //rx, tx
void SERCOM1_0_Handler()
{
Serial2.IrqHandler();
}
void SERCOM1_1_Handler()
{
Serial2.IrqHandler();
}
void SERCOM1_2_Handler()
{
Serial2.IrqHandler();
}
void SERCOM1_3_Handler()
{
Serial2.IrqHandler();
}
void setup() {
Serial1.begin(115200);
Serial2.begin(115200);
// Assign SERCOM functionality
pinPeripheral(SERIAL2_RX, PIO_SERCOM);
pinPeripheral(SERIAL2_TX, PIO_SERCOM);
}
uint8_t i=0;
void loop() {
Serial1.print(i);
Serial2.write(i++);
if (Serial2.available()) {
Serial1.print(" -> 0x"); Serial1.print(Serial2.read(), HEX);
}
Serial1.println();
delay(1000);
}
There is a jumper between RX and TX on serial 2 (Pin D11 and D10).
The Output is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
where is should be:
1 -> 0x1
2 -> 0x2
3 -> 0x3
4 -> 0x4
5 -> 0x5
6 -> 0x6
7 -> 0x7
8 -> 0x8
9 -> 0x9
10 -> 0xA
11 -> 0xB
12 -> 0xC
13 -> 0xD
14 -> 0xE
Neither RX nor TX of Serial 2 work. Do you have an idea where my mistake is? Thanks alot for the help