Hello,
I am starting a project that is very COMM heavy. I need SPI, I2C, and 2 Uarts. I am using the Feather M4 Express board from Adafruit Adafruit Feather M4 Express.
I am trying to use the defaults:
I2C (Pin 17/18:SDA/SCL)
SPI (Pin 11/12/13:SCK/MOSI/MISO)
Serail1 (PIN 14/15:RX/TX)
and I would like Serial2 (Pin 22/23:D10/D11)
I have tried to follow the example at Creating a new Serial by Adafruit, but I have no luck.
my code is:
#include "wiring_private.h" // pinPeripheral() function
#define PIN_SERIAL2_RX 11 // PA21 Pin 23
#define PAD_SERIAL2_RX (SERCOM_RX_PAD_3)
#define PIN_SERIAL2_TX 10 // PA20 Pin 22
#define PAD_SERIAL2_TX (UART_TX_PAD_2)
Uart Serial2( &sercom3, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX );
void SERCOM3_0_Handler()
{
Serial2.IrqHandler();
}
void SERCOM3_1_Handler()
{
Serial2.IrqHandler();
}
void SERCOM3_2_Handler()
{
Serial2.IrqHandler();
}
void SERCOM3_3_Handler()
{
Serial2.IrqHandler();
}
void setup() {
Serial.begin(115200);
Serial2.begin(115200);
// Assign pins 3 & 4 SERCOM functionality
pinPeripheral(PIN_SERIAL2_RX, PIO_SERCOM_ALT);
pinPeripheral(PIN_SERIAL2_TX, PIO_SERCOM_ALT);
}
uint8_t i=0;
void loop() {
Serial.print(i);
Serial2.write(i++);
if (Serial2.available()) {
Serial.print(" -> 0x"); Serial.print(Serial2.read(), HEX);
}
Serial.println();
delay(1000);
}
the Hardware has a jumper between pin Pin 22/D10 and 23/D11.
I have run the example code on the webpage on a Feather M0 basic and works perfectly, but when I modify it for the M4 I get nothing back on Serial2, Just the counting up numbers on Serial.
Output:
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
as I get with the M0.
I can not see where I am going wrong. Just wondering if someone has any ideas?
Thanks for the help in advance.