BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – SERIN
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 409
' {$PBASIC 2.5}
result VAR Word
Main:
DO
SERIN 1, 24660, Bad_Data, 10000, No_Data, [DEC result]
DEBUG CLS, ? result
LOOP
Bad_Data:
DEBUG CLS, "Parity error"
GOTO Main
No_Data:
DEBUG CLS, "Timeout error"
GOTO Main
When you design an application that requires serial communication
between BASIC Stamp modules, you have to work within these
limitations:
When the BASIC Stamp is sending or receiving data, it can’t
execute other instructions.
When the BASIC Stamp is executing other instructions, it can’t
send or receive data. The BASIC Stamp does not have a serial buffer as
there is in PCs. At most serial rates, the BASIC Stamp cannot
receive data via SERIN, process it, and execute another SERIN in
time to catch the next chunk of data, unless there are significant
pauses between data transmissions.
These limitations can sometimes be addressed by using flow control; the
Fpin option for SERIN and SEROUT (at baud rates of up to the limitation
shown in Table 5.94). Through Fpin, SERIN can tell a BASIC Stamp sender
when it is ready to receive data. (For that matter, Fpin flow control follows
the rules of other serial handshaking schemes, but most computers other
than the BASIC Stamp cannot start and stop serial transmission on a byte-
by-byte basis. That’s why this discussion is limited to communication
between BASIC Stamp modules.)
Here’s an example using flow control on the BS2 (data through I/O pin 1,
flow control through I/O pin 0, 9600 baud, N8, noninverted):
serData VAR Byte
SERIN 1\0, 84, [serData]
C
ONTROLLING DATA FLOW.
All
2
All
2