Serial.println() with XIAO SAMD21

Why is in this example “test1” not written to the serial port? I see only “test2”. I’m using the serial monitor in Arduino IDE.

void setup() {
  Serial.begin(38400);
  Serial.println("test1");
}

void loop()
{
  Serial.println("test2");
  delay(1000);  
}

connect device open serial monitor press reset button you should see test1 and test2 both.

probably chip is running too fast it prints that statement before you have fully established he serial monitor conncetion

try lowering serial speed to 19200 or even 9600

try adding this code, it will wait until the serial monitor connects to proceed
but you would need to remove or disable the function if you are not connected to serial “in the field” because the code will not start if not connected to serial mon (sometimes it will, sometimes not) also you could just add a delay before to give a little time

like delay(5000);

// Open serial communications and wait for port to open:
Serial.begin(19200);
while (!Serial) // wait for serial port to connect.
{//Begin while()
Serial.println("\nSerial Setup…");
}// End while()

Thank you. It works fine with
while (!Serial) ;