Adding Serial Port to SAMD21 mini

I’m trying to setup a HW serial on pins 2 and 3 on the SAMD21 mini by following this guide :

but compiling the code give me these errors :

.pio/build/sparkfun_samd21_mini_usb/libFrameworkArduinoVariant.a(variant.cpp.o): In function SERCOM2_Handler': variant.cpp:(.text.SERCOM2_Handler+0x0): multiple definition of SERCOM2_Handler’

.pio/build/sparkfun_samd21_mini_usb/src/main.cpp.o:main.cpp:(.text.SERCOM2_Handler+0x0): first defined here

.pio/build/sparkfun_samd21_mini_usb/libFrameworkArduinoVariant.a(variant.cpp.o):(.bss.gpsSerial+0x0): multiple definition of `gpsSerial’

.pio/build/sparkfun_samd21_mini_usb/src/main.cpp.o:(.bss.gpsSerial+0x0): first defined here

I’ve triple checked defining the serial port and everything seems correct.

Any ideas would be appreciated.

In the guide it says to add this to varient.cpp

`Uart mySerial(&sercom2, 3, 2, SERCOM_RX_PAD_1, UART_TX_PAD_2);

void SERCOM2_Handler()
{
mySerial.IrqHandler();
}`

I think this is where the multiple definition is coming from. Removing this code allow for the code to compile.

1 Like