Using SoftwareSerial library (Arduino IDE) on XIAO

Hi
I am trying to move a sketch from Arduino Nano over to Seeeduino XIAO and I have noticed that the SoftwareSerial library does not behave the same on XIAO as it does on Arduino Nano when reading data.

Below I have included a table of pairs of data I am reading from Arduino and from XIAO generated from the same source. The 0x7E is a byte sent to determine that the next byte is a code of a sensor and I would expect the value pairs between the 2 microprocessors to be the same.

The code I have used to produce the above is as follow

#include <Streaming.h>
#include <SoftwareSerial.h>

#define PIN_SPORT 9

SoftwareSerial sport = SoftwareSerial(PIN_SPORT, PIN_SPORT, true);

void setup(){
sport.begin(57600);
Serial.begin(115200);
Serial << “Initialised…” << endl;
}

void loop(){
if (sport.available()){
byte data = sport.read();
Serial << String(data, HEX) << " ";
if (data == 0x7E){
//while (sport.available() && sport.peek() != 0x7E){
while (!sport.available());
// Make sure all bytes are read before the next sensor inidcation byte is reached
data = sport.read();
Serial << String(data, HEX) << " ";
//}
}
Serial << endl;
}
}

Apologies for the luck of indentation but I cannot make the text look proper when generating this message in the forum.

I have been scratching my head for about 3-4 days now looking at the SoftwareSerial library code but cannot find any obvious reasons as to why I would be getting different results, unless if it has to do with the interrupt generated in the library for reading data.

Some more ideas and advice would be very much appreciated, as it seems very strange to me if the library does not work, making Software Serial not working at all in XIAO

Many thanks

Michael

Hi everyone,

After a lot of investigation, I have now come to the conclusion that the SoftwareSerial library is slower in XIAO in comparison to the Arduino (at least the nano where I have tested this).

Not sure I understand why, as my understanding is that XIAO has a bit more powerful CPU from Arduino.

Any thoughts?