Specifications
BASIC Stamp II Application Notes
Page 354 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
Shiftout requires just five pieces of information to do its job:
• The pin number of the data connection.
• The pin number of the shift-clock connection.
• The order in which the bits should be sent—least-significant bit
(lsb) first or most-significant bit (msb) first. For the ’595, we chose
msb first, since the msb of the output is farthest down the shift
register from the data input. For other devices, the order of bits is
prescribed by the manufacturer’s spec sheet.
• The variable containing the data to output.
• The number of bits to be sent. (If this entry is omitted, Shiftout will
send eight bits).
Note that once the data is shifted into shift register, an additional
program step—pulsing the Latch line—is required to move the data to
the output lines. That’s because the 74HC595 is internally similar to the
schematic in figure 3. The two-step transfer process prevents the
outputs from rippling as the data is shifted.
The 74HC595 also has two control lines that are not used in our
demonstration, but may prove useful in real-world applications. The
Reset line, activated by writing a 0 to it, simultaneously clears all of the
shift register flip-flops to 0 without affecting the output latch. The
Output-enable (OE) line can effectively disconnect the output latch,
allowing other devices to drive
the same lines. A 0 on OE con-
nects the outputs; a 1 discon-
nects them.
Serial ADC with Shiftin. Fig-
ure 5 and listing 2 demonstrate
how to use Shiftin to obtain
data from an 8-bit serial ana-
log-to-digital converter, the
ADC0831.
Shiftin requires the same five
pieces of information as
BS2 pin 0
BS2 pin 1
BS2 pin 2
ADC
0831
1
2
3
4
8
7
6
5
CS
Vin(+)
Vin(–)
GND
Vcc
CLK
DO
Vref
0–5V in
+5
Figure 5. Schematic for
ADC
0831.
BS
2.
2: Using Shiftin & Shiftout










