The current project (Mega) uses Pins 0/1 (RX/TX) for debugging and communication with an external PC via USB, Pins 65/66 via SoftwareSerial as RX/TX to communicate with an Adafruit Metro Mini, and Pins 67/68 via SoftwareSerial as RX/TX to communicate with HC06 BT module. Everything works perfectly. So far so good...
When switching to GCM4E, I am not getting the serial communication between the GCM4E and the Metro Mini / HC06 to work. Following the GCM4E pin out diagram, the pins used for Serial Communication with the Mega can also be used for Serial Communication with the GCM4E:
Pin 57 --> SERCOM_ALT 4 Pad 0 --> Sercom4 TX
Pin 58 --> SERCOM_ALT 4 Pad 2 --> Sercom4 RX
Pin 59 --> SERCOM_ALT 0 Pad 0 --> Sercom0 TX
Pin 60 --> SERCOM_ALT 0 Pad 2 --> Sercom0 RX
As the GCM4E uses a 3.3V logic, I also switched the Metro Mini to 3.3V. But this does not help. I use the following test-sketch to establish a basic serial communication (in this case via Pins 57/58), but it does not work:
Code: Select all
```cpp
/////////////////////////////////////////////
// Master Adafruit Grand Central M4 ATSAMD51
/////////////////////////////////////////////
#include <Arduino.h>
#include "wiring_private.h" // pinPeripheral() function
Uart BTSerial (&sercom4, 58, 57, SERCOM_RX_PAD_1, UART_TX_PAD_0); // BT Serial connection
void SERCOM4_Handler()
{
BTSerial.IrqHandler();
}
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect
}
Serial.println("Serial Communication Test");
BTSerial.begin(9600);
// Assign pins 10 & 11 SERCOM functionality
pinPeripheral(57, PIO_SERCOM_ALT);
pinPeripheral(58, PIO_SERCOM_ALT);
while (!BTSerial) {
Serial.println("Waiting for BTSerial to connect"); // wait for BTserial port to connect
}
Serial.println("BTSerial connected");
BTSerial.println("Slave Test");
}
void loop() {
if (Serial.available())
{ // If anything comes in Serial (USB),
BTSerial.write(Serial.read());
}
if (BTSerial.available())
{ // If anything comes in SoftwareSerial,
Serial.write(BTSerial.read()); // read it and send it out Serial1 (pins 0 & 1)
}
}
```
What am I doing wrong - any help?