Mkr Zero crashes when sending data over Serial2

So I have extended the Serial ports of my Arduino by following these instructions: https://www.arduino.cc/en/Tutorial/SamdSercom
I already had an Project where this worked totally fine! But now my Arduino always crashes when sending data over serial2.

Here is an Example code:

#include <ctype.h>
#include "wiring_private.h"  //https://www.arduino.cc/en/Tutorial/SamdSercom#adding-a-new-communication-interface

Uart Serial2 (&sercom3, 1, 0, SERCOM_RX_PAD_1, UART_TX_PAD_0); // Create the new UART instance assigning it to pin 1 and 0

unsigned long start = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(57600);
    while(!Serial){;}
  Serial2.begin(38400);
  pinPeripheral(1, PIO_SERCOM); //Assign RX function to pin 1
  pinPeripheral(0, PIO_SERCOM); //Assign TX function to pin 0
  pinMode(LED_BUILTIN, OUTPUT);
Serial.println("Started");
  delay(100);
  Serial.println("Started");
 }

void loop() {
	Serial.println("test");
	Serial2.print("test");
	delay(100);
}

When I run the code it prints:
Started
Started
test

But when I run it without Serial2.print, it prints “test” every 100ms as it should!

What could cause this problem?

Oh I solved it I was very dumb!
Sorry for wasting youre Time:
If sombody ever stumbles around this Problem:
When I copied the Serial 2 definition form my other code I forgot to copy the Handler Callback:

void SERCOM3_Handler()
{

  mySerial.IrqHandler();
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.