BASIC Stamp Architecture – Memory Organization
Page 48
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
circuit connected the I/O pin to ground, the corresponding bit of INS
would be low. If a pin was set to an output mode and the pin's state was
set to a high level (within OUTS), the corresponding bit of INS would be
high. If, however, that same pin was externally connected directly to
ground, the corresponding bit of INS would be low; since we're reading
the state of the pin itself and the BASIC Stamp cannot override a pin that is
driven to ground or 5 volts externally. Note: The last example is an error,
is a direct short and can cause damage to the BASIC Stamp! Do not
intentionally connect output pins directly to an external power source or
you risk destroying your BASIC Stamp.
To summarize: DIRS determines whether a pin’s state is set by external
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 BASIC Stamp, it’s often more convenient to deal with
individual bytes, nibbles or bits of INS, OUTS and DIRS rather than the
entire 16-bit words. PBASIC has built-in names for these elements, shown
in Table 4.2.
Here's an example of what is described in Table 4.2. The INS register is 16-
bits (corresponding to I/O pins 0 though 15). The INS register consists of
two bytes, called INL (the Low byte) and INH (the High byte). INL
corresponds to I/O pins 0 through 7 and INH corresponds to I/O pins 8
though 15. INS can also be though of as containing four nibbles, INA,
INB, INC and IND. INA is I/O pins 0 though 3, INB is I/O pins 4 though
7, etc. In addition, each of the bits of INS can be accessed directly using
the names IN0, IN1, IN2… IN5.
The same naming scheme holds true for the OUTS and DIRS variables as
well.
As Table 4.2 shows, the BASIC Stamp's memory is organized into 16
words of 16 bits each. The first three words are used for I/O. The
remaining 13 words are available for use as general-purpose variables.
Just like the I/O variables, the general-purpose variables have predefined
names: W0 through W12 and B0 through B25. B0 is the low byte of W0; B1
is the high byte of W0; and so on through W12 (B24=low byte, B25=high
P
REDEFINED
"F
IXED
" V
ARIABLES
.
S
UMMARY OF THE FUNCTION OF
DIRS, INS
AND
OUTS.
Summary of Contents for BASIC Stamp 1
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...