BASIC stamp manual v2.2

SEROUT – BASIC Stamp Command Reference
Page 418 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
On the BS1, serial communication is limited to: no-parity, 8-data bits and
1-stop bit at one of four different speeds: 300, 600, 1200 or 2400 baud.
Table 5.105 indicates the Baudmode value or symbols to use when
selecting the desired mode.
Baudmode
Value
Symbol Baud Rate Polarity and
Output Mode
0 T2400 2400 TRUE (always driven)
1 T1200 1200 TRUE (always driven)
2 T600 600 TRUE (always driven)
3 T300 300 TRUE (always driven)
4 N2400 2400 INVERTED (always driven)
5 N1200 1200 INVERTED (always driven)
6 N600 600 INVERTED (always driven)
7 N300 300 INVERTED (always driven)
8 OT2400 2400 TRUE (open drain, driven high)
9 OT1200 1200 TRUE (open drain, driven high)
10 OT600 600 TRUE (open drain, driven high)
11 OT300 300 TRUE (open drain, driven high)
12 ON2400 2400 INVERTED (open source, driven low)
13 ON1200 1200 INVERTED (open source, driven low)
14 ON600 600 INVERTED (open source, driven low)
15 ON300 300 INVERTED (open source, driven low)
Table 5.105: BS1 Baudmode
Values.
On all BS2 models, serial communication is very flexible. The Baudmode
argument for SEROUT accepts a 16-bit value that determines its
characteristics: 1-stop bit, 8-data bits/no-parity or 7-data bits/even-parity
and virtually any speed from as low as 300 baud to greater than 100K
baud (depending on the BASIC Stamp model). Table 5.106 shows how
Baudmode is calculated, while Table 5.107, Table 5.108, and Table 5.109
show common baud modes for standard serial baud rates.
Step 1: Determine the
bit period (bits 0 – 11)
BS2, BS2e and BS2pe: = INT(1,000,000 / baud rate) – 20
BS2sx and BS2p: = INT(2,500,000 / baud rate) – 20
BS2px: = INT(4,000,000 / baud rate) – 20
Note: INT means 'convert to integer;' drop the numbers to the right of the
decimal point.
Step 2: Set data bits
and parity (bit 13)
8-bit/no-parity = 0
7-bit/even-parity = 8192
Step 3: Select
polarity (bit 14)
True (noninverted) = 0
Inverted = 16384
Step 4: Select driven or
open output (bit 15)
Driven = 0
Open = 32768
Table 5.106: Baudmode calculation
for all BS2 models. Add the results
of steps 1, 2, 3 and 4 to determine
the proper value for the Baudmode
argument.
1
All
2