Go Down

Topic: Update Software Serial documentation (Read 1 time) previous topic - next topic



Please consider adding the following limitations:

- All interrupts are disabled during byte transmission.  Interrupts that occur during this time will fire when the byte is done transmitting, but it's possible to miss interrupts that fire multiple times during a single byte transmission.
- Any data received during a transmission may be malformed as the receiver requires interrupts.

This can be verified in arduino 1.0 SoftwareSerial.cpp:
Line 451: cli();  // turn off interrupts for a clean txmit
Write 8 bits to tx port
Line 487: SREG = oldSREG; // turn interrupts back on

For now, updating the documentation so later users don't get frustrated trying to figure out why the software serial port isn't working when they do a simply loopback test.  For instance, the example program only works for individual characters with time inbetween them.  Run it and send "test" to the serial port and you'll get the "t" and then a few more garbage characters back.

If someone wants to tackle this problem more generally here are two solutions:
- Don't disable interrupts.  Rather than using delays use a timer, or poll micros() and time based on that
- Creating a interrupt based transmit routine (probably the best solution, but consumes a timer)

Also, would be nice if the receive routine had at least framing error detection (missing stop bit).

And yes, I know, it's open source so I can fix the routine myself (and I probably will) however until it's fixed in the arduino software package, it should be noted in the documentation.

Go Up