5: BASIC Stamp Command Reference – SERIN
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 287
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. Tables 5.73, 5.74 and 5.75 show appropriate
BaudMode settings for different BASIC Stamps. For example, with the BS2,
to receive one data byte through pin 1 at 9600 baud, 7E, inverted:
SerData VAR BYTE
SERIN 1, 24660, [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 optional
Plabel argument:
SerData VAR BYTE
SERIN 1, 24660, 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
BadData. Note that a parity error takes precedence over other InputData
specifications (as soon as an error is detected, SERIN aborts and goes to
the Plabel routine).
In all the examples above, the only way to end the SERIN instruction
(other than RESET or power-off) is to give SERIN the serial data it wants.
If no serial data arrives, the program is stuck. However, you can tell the
BASIC Stamp to abort SERIN if it doesn’t receive data within a specified
number of milliseconds. For instance, to receive a decimal number
through pin 1 at 9600 baud, 8N, inverted and abort SERIN after 2 seconds
(2000 ms) if no data arrives:
Result VAR BYTE
SERIN 1, 16468, 2000, NoData, [DEC Result]
Debug CLS, ? Result
STOP
NoData:
DEBUG CLS, "timed out"
U
SING THE SERIAL TIME
-
OUT
FEATURE
.
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...