Specifications
BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 215
2
tains the states of the 16 output latches. DIRS controls the direction
(input or output) of each of the 16 pins.
If you are new to devices that can change individual pins between in-
put and output, the INS/OUTS/DIRS trio may be a little confusing, so
we’ll walk through the possibilities.
A 0 in a particular DIRS bit makes the corresponding pin, P0 through
P15, an input. So if bit 5 of DIRS is 0, then P5 is an input. A pin that is an
input is at the mercy of circuitry outside the Stamp; the Stamp cannot
change its state. When the Stamp is first powered up, all memory loca-
tions are cleared to 0, so all pins are inputs (DIRS = %0000000000000000).
A 1 in a DIRS bit makes the corresponding pin an output. This means
that the corresponding bit of OUTS determines that pin’s state.
Suppose all pins’ DIRS are set to output (1s) and you look at the con-
tents of INS. What do you see? You see whatever is stored in the vari-
able OUTS.
OK, suppose all pins’ DIRS are set to input (0s) and external circuits
connected to the pins have them all seeing 0s. What happens to INS if
you write 1s to all the bits of OUTS? Nothing. INS will still contain 0s,
because with all pins set to input, the external circuitry is in charge.
However, when you change DIRS to output (1s), the bits stored in OUTS
will appear on the I/O pins.
These possibilities are summarized in the Figure M-1 below. To avoid
making the table huge, we’ll look at only one bit. The rules shown for
a single bit apply to all of the I/O bits/pins. Additionally, the external
circuitry producing the “external state” listed in the table can be over-
ridden by a Stamp output. For example, a 10k resistor to +5V will place
a 1 on an input pin, but if that pin is changed to output and cleared to
0, a 0 will appear on the pin, just as the table shows. However, if the
pin is connected directly to +5V and changed to output 0, the pin’s
state will remain 1. The Stamp simply cannot overcome a direct short,
and will probably be damaged in the bargain.










