Hi,
After many days I’ve been able to implement a secondary UART on an Adafruit ItsyBitsy M4.
A very minimal serial loopback test sketch written in Arduino IDE does not operate the same way in PlatformIO which is leading me to think that there’s a difference in the way the code is being compiled between the two.
After switching on verbose output in Arduino IDE, I have tried to identify differences between the build flags and compare them to the gcc-flags.json
. I’m not too sure what they mean, and don’t know whether they’re C or CPP flags!
Here’s the sketch:
#include <Arduino.h>
#include "wiring_private.h" // pinPeripheral() function
Uart Serial2(&sercom5, 13, 12, SERCOM_RX_PAD_1, UART_TX_PAD_0); // 13(D13 =>PA22 => Sercom 5.1) , 12(D12 =>PA23 => Sercom 5.0)
void SERCOM5_0_Handler()
{
Serial2.IrqHandler();
}
void SERCOM5_1_Handler()
{
Serial2.IrqHandler();
}
void SERCOM5_2_Handler()
{
Serial2.IrqHandler();
}
void SERCOM5_3_Handler()
{
Serial2.IrqHandler();
}
void setup() {
// put your setup code here, to run once:
pinPeripheral(12, PIO_SERCOM_ALT);
pinPeripheral(13, PIO_SERCOM_ALT);
Serial.begin(115200);
Serial2.begin(9600);
while (!Serial.available());
Serial.print("\nStarting Serial2 Monitoring...\n");
while(true) {
Serial2.write("\n--- TESTING PORT ---");
while (Serial2.available()) {
Serial.print("\nREAD: ");Serial.print(char(Serial2.read()));
}
delay(1000);
Serial.write(". ");
}
}
void loop() {
// put your main code here, to run repeatedly:
}
Versions:
Arduino IDE: 1.8.8
Adafruit SAMD Boards package: 1.2.9
Arduino SAMD boards: 1.6.20
PlatformIO Atmelsam core: 3.4.2
PlatformIO Core: 4.0.0a3
gcc flags JSON file:
{
"execPath": "/Users/rav/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++",
"gccDefaultCFlags": "-fsyntax-only -std=gnu11 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Os -ffunction-sections -fdata-sections -Wall -mthumb -nostdlib --param max-inline-insns-single=500 -mcpu=cortex-m4 -DPLATFORMIO=40000 -DARDUINO_ARCH_SAMD -DARDUINO_ITSYBITSY_M4 -DADAFRUIT_ITSYBITSY_M4_EXPRESS -D__SAMD51J19A__ -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -DCRYSTALLESS -DF_CPU=120000000L -DUSBCON -DARDUINO=10805 -DUSB_VID=0x239A -DUSB_PID=0x802B -DUSB_PRODUCT=\"Adafruit ItsyBitsy M4\" -DUSB_MANUFACTURER=\"Adafruit\"",
"gccDefaultCppFlags": "-fsyntax-only -fno-rtti -fno-exceptions -std=gnu++11 -fno-threadsafe-statics -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Os -ffunction-sections -fdata-sections -Wall -mthumb -nostdlib --param max-inline-insns-single=500 -mcpu=cortex-m4 -DPLATFORMIO=40000 -DARDUINO_ARCH_SAMD -DARDUINO_ITSYBITSY_M4 -DADAFRUIT_ITSYBITSY_M4_EXPRESS -D__SAMD51J19A__ -D__SAMD51__ -D__FPU_PRESENT -DARM_MATH_CM4 -DCRYSTALLESS -DF_CPU=120000000L -DUSBCON -DARDUINO=10805 -DUSB_VID=0x239A -DUSB_PID=0x802B -DUSB_PRODUCT=\"Adafruit ItsyBitsy M4\" -DUSB_MANUFACTURER=\"Adafruit\"",
"gccErrorLimit": 15,
"gccIncludePaths": "/Users/rav/.platformio/packages/framework-arduinosam/cores/adafruit,/Users/rav/.platformio/packages/framework-arduinosam/system/samd/CMSIS/CMSIS/Include,/Users/rav/.platformio/packages/framework-arduinosam/system/samd/CMSIS-Atmel/CMSIS/Device/ATMEL,/Users/rav/.platformio/packages/framework-arduinosam/variants/itsybitsy_m4,/Users/rav/.platformio/packages/framework-arduinosam/libraries/__cores__/adafruit/HID,/Users/rav/.platformio/packages/framework-arduinosam/libraries/__cores__/adafruit/I2S/src,/Users/rav/.platformio/packages/framework-arduinosam/libraries/__cores__/adafruit/SAMD_AnalogCorrection/src,/Users/rav/.platformio/packages/framework-arduinosam/libraries/__cores__/adafruit/SDU/src,/Users/rav/.platformio/packages/framework-arduinosam/libraries/__cores__/adafruit/SPI,/Users/rav/.platformio/packages/framework-arduinosam/libraries/__cores__/adafruit/USBHost/src,/Users/rav/.platformio/packages/framework-arduinosam/libraries/__cores__/adafruit/Wire,/Users/rav/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include,/Users/rav/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/4.8.4,/Users/rav/.platformio/packages/toolchain-gccarmnoneeabi/arm-none-eabi/include/c++/4.8.4/arm-none-eabi,/Users/rav/.platformio/packages/toolchain-gccarmnoneeabi/lib/gcc/arm-none-eabi/4.8.4/include,/Users/rav/.platformio/packages/toolchain-gccarmnoneeabi/lib/gcc/arm-none-eabi/4.8.4/include-fixed,/Users/rav/.platformio/packages/tool-unity,/Users/rav/Desktop/TestSercom5/include,/Users/rav/Desktop/TestSercom5/src",
"gccSuppressWarnings": false
}