Does software serial really work reliably at 115200 baud?
I need to have 2 serial devices attached at 115200 and cannot get software serial to work reliably.
I wrote a sketch to simply echo what was received and at 115200 I get ~0.2% of characters being echoed incorrectly. It works fine with 0% errors at 57600, but I really need 115200.
I jumped inside the software serial library and found this, amongst the code
// When the start bit occurs, there are 3 or 4 cycles before the // interrupt flag is set, 4 cycles before the PC is set to the right // interrupt vector address and the old PC is pushed on the stack, // and then 75 cycles of instructions (including the RJMP in the // ISR vector table) until the first delay. After the delay, there // are 17 more cycles until the pin value is read (excluding the // delay in the loop). // We want to have a total delay of 1.5 bit time. Inside the loop, // we already wait for 1 bit time - 23 cycles, so here we wait for // 0.5 bit time - (71 + 18 - 22) cycles. _rx_delay_centering = subtract_cap(bit_delay / 2, (4 + 4 + 75 + 17 - 23) / 4);
For 115200 this means _rx_delay_centering will be 1.
To me this means there is no room for anything else to 'get in the way' at 115200.
Now I'm no expert on AVR/Arduino (never seen the instruction set until today), but surely that means the 'millis' interrupt could/can stop serial receive at 115200?
As an experiment I inserted this into my sketch TIMSK0 = 0; // disable Timer0/millis Interrupt
Now the echo program runs at 115200 without errors.
Obviously that isn't the correct answer to get things going properly, but I'm lost, how do you get SoftwareSerial working at 115200 (and gee the doco says "It is possible to have multiple software serial ports with speeds up to 115200 bps.", how?)