I wanted to test the range of baudrates of the AltSoftSerial library, and connected it to a hardware serial port on a Mega. Input from the hardware port is sent to the Serial Monitor. Then I varied the baudrates between these, and found an astonishing problem. When a startup message is sent from the AltSoftSerial port at 115200 baud, this message is garbled. The first character looks correct, also the last character (CR/LF?) may be correct, but garbage arrives in between. Single characters (input and echo in Serial Monitor) are correctly transmitted.
Is this a known problem, what could be the trouble source?
What can I do to find out more?
Sending multiple characters seems to fail with baudrates above 38400. With higher baudrates the signals sometimes look good, but the sending routine can get stuck even after the start bit, and can hang in marking state. This may be due to concurrent interrupts in full-duplex mode, when the next character is received while the transmitter is sending the stop bit of the previously received (and echoed) character.
When I switched to half-duplex mode, sending at 76800 baud worked fine. But with 115k the sender is stuck when the first transmitted bit (LSB) is zero (equal to start bit). How can this happen only with the first bit, not with following sequences of bits?
Any ideas what could be improved in the sender code?