Specifications

BASIC Stamp II
Page 216 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
To summarize: DIRS determines whether a pin’s state is set by exter-
nal circuitry (input, 0) or by the state of OUTS (output, 1). INS always
matches the actual states of the I/O pins, whether they are inputs or
outputs. OUTS holds bits that will only appear on pins whose DIRS
bits are set to output.
In programming the BS2, it’s often more convenient to deal with indi-
vidual bytes, nibbles or bits of INS, OUTS and DIRS rather than the
entire 16-bit words. PBASIC2 has built-in names for these elements,
listed below. When we talk about the low byte of these words, we mean
the byte corresponding to pins P0 through P7.
Figure M-1. Interaction of DIRS, INS and OUTS
The DIRS register controls which I/O pins are inputs and which are outputs. When
set to input (0), the corresponding bit in the OUTS register is disconnected and
ignored.
When set to output (1), the corresponding bit in the OUTS register is connected.
NOTE: “X” indicates state could be a 1 or a 0 and does not affect other elements.
“?” indicates state is unknown and could change erratically.
Table M-2. Predefined Names for Elements of DIRS, INS and OUTS
DIRS INS OUTS The entire 16-bit word
DIRL INL OUTL The low byte of the word
DIRH INH OUTH The high byte of the word
DIRA INA OUTA The low nibble of low byte
DIRB INB OUTB The high nibble of low byte
DIRC INC OUTC The low nibble of high byte
DIRD IND OUTD The high nibble of high byte
DIR0 IN0 OUT0 The low bit; corresponds to P0
...(continues 1 through 14)... Bits 1 - 14; corresponds to P1 through P14
DIR15 IN15 OUT15 The high bit; corresponds to P15