Specifications

BASIC Stamp II
Page 324 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
checking to see whether the receiving device was ready for it. If the
receiver wasn’t ready, the data was sent anyway, and lost.
With flow control, the serial receiver can tell Serout when to send data.
BS2 flow control works on a byte-by-byte basis; no matter how many
bytes Serout is supposed to send, it will look for permission to send
before each byte. If permission is denied, Serout will wait until it is
granted.
By permission we mean the appropriate state of the flow-control pin—
fpin—specified in the Serout instruction. The logic of fpin depends on
whether an inverted or non-inverted baudmode is specified:
Go Stop
Inverted 10
Noninverted 01
Here’s an example that demonstrates fpin flow control. It assumes that
two BS2s are powered up and connected together as shown in figure
I-20.
' SENDER: data out pin 1, flow control pin 0
' Baudmode: 9600 N8 inverted
Serout 1\0,16468,["HELLO!"] '
Send the greeting.
' RECEIVER: data in pin 1, flow control pin 0
' Baudmode: 9600 N8 inverted
letta var byte
again:
Serin 1\0,16468,[letta] ' Get 1 byte.
debug letta ' Display on screen.
pause 1000 ' Wait a second.
goto again
Without flow control, the sender would transmit the whole word
“HELLO!” in about 6ms. The receiver would catch the first byte at most;
by the time it got back from the first 1-second Pause, the rest of the
data would be long gone. With flow control, communication is flaw-
less since the sender waits for the receiver to catch up.
In figure I-20, pin 0, fpin, is pulled to ground through a 10k resistor.