Serial communication
Meepo
Posts: 24
I'm trying to read 4-byte packets from a serial line. These are TTL-level signals sent by another stamp. I'd like to be able to do other tasks while waiting for the bytes. Right now, if someone could just help me with the basics, reading 4 bytes & displaying the decimal values with DEBUG, I'd be all set...
Comments
The BASIC Stamp does not have a FIFO Buffer so you won’t be able to do other tasks while waiting for the bytes. The closest you could come would be to implement handshaking so the BASIC Stamps only communicate when ready. As for the serial example, please see the BASIC Stamp Manual or the Help File under the SERIN/SEROUT commands. There is an example under both commands for connecting two BASIC Stamps together and sending data. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Your other comment "do other tasks while waiting" may be a problem. The Stamp can only do one thing at a time. If it's doing other tasks, it won't be listening to the serial line and will miss data being sent. You could use some other I/O pins for an "interrupt" and acknowledgment where the other Stamp sets one line to HIGH to indicate that it has data. In between the "other tasks", the second Stamp can check this line and, if it's high, it can set the acknowledge line to HIGH to indicate that it is listening (and immediately do a SERIN). The first Stamp would then set its "interrupt" line to LOW and send the data. The second stamp would set its acknowledge line to LOW and go back to its "other tasks".
This will give you a simple buffered serial input port, that you can then read with a SHIFTIN when data is ready.