You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SerialPIO(SoftwareSerial) receive path was convoluted and required
a lot of work on the host to get the actual data out. It also wasn't
always sampling on the proper edge leading to errors whenever clocks
or hold times shifted slightly.
Rewrite the SerialPIO RX path to explicitily wait for start bit,
pause 1/2 bit time, then idle for a full bit time for all bits.
Takes more PIO instruction memory but works flawlessly even with
mismatched clocks.
Tested with a loopback from HW UART to SW UART with a 5% clock
mismatch @ 19200 baud without reception errors, whereas the
original code would fail with less than a 0.5% variation.
Fixes#2928
````
SoftwareSerial s(15, -1);
void setup() {
Serial1.setTX(0);
Serial1.begin(19200 + 1920/2, SERIAL_8N1);
s.begin(19200, SERIAL_8N1);
}
void loop() {
Serial.println("---");
Serial1.write("Had we but world enough and time", 32);
uint32_t now = millis();
while (millis() - now < 500) {
while (s.available()) {
auto c = s.read();
Serial.printf("%02x '%c'\n", c, c);
}
}
}
````
0 commit comments