Specifications

BASIC Stamp II
Page 314 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
The unwanted x data is stored in yOffset, then replaced by the desired
y data. This is a sneaky way to filter out a number of any size without
using an extra variable. With a little creativity, you can combine the
inputData modifiers to filter and extract almost any data.
Using Parity and Handling Parity Errors
Parity is an error-checking feature. When a serial sender is set for even
parity—the mode the BS2 supports—it counts the number of 1s in an
outgoing byte and uses the parity bit to make that number even. For
instance, if it is sending the seven bits %0011010, it sets the parity bit to
1 in order to make an even number of 1s (four).
The receiver also counts up the data bits to calculate what the parity
bit should be. If it matches the parity bit received, the serial receiver
assumes that the data was received correctly. Of course, this is not nec-
essarily true, since two incorrectly received bits could make parity seem
correct when the data was wrong, or the parity bit itself could be bad
when the rest of the data was OK.
Many systems that work exclusively with text use (or can be set for) 7-
bit/even-parity mode. Table I-3 shows appropriate baudmode settings.
For example, to receive one data byte through pin 1 at 2400 baud, 7E,
inverted:
serData var byte
Serin 1,24972,[serData]
That instruction will work, but it doesn’t tell the BS2 what to do in the
event of a parity error. Here’s an improved version that uses the op-
tional plabel:
serData var byte
serin 1,24972,badData,[serData]
debug ? serData
Stop
badData:
debug "parity error"
If the parity matches, the program continues at the Debug instruction
after Serin. If the parity doesn’t match, the program goes to the label