■ FIGURE 6. 74HC597 Pins.
is sort of the sister chip to the 595 in that it reverses the process.
It adds one non-SPI control line that is required to load the
data from the parallel pins to the shift register before
clocking the data out. For our purposes, we hook this line
to the ST_CP line so that we latch bits and load bytes in one
operation which doesn’t seem to hurt anything [www.nxp.
com/documents/data_sheet/74HC_HCT597_CNV.pdf].
Using the 74HC595 — Control 16 LEDs
Figure 1 shows a bit of a rat’s nest of wires on
breadboards. The two ICs on the left are 595s and are
used to control the 16 LEDs. The schematic for this is
shown in Figure 7, but please note that this doesn’t show
the IC VCC and GND connections with pins 14 and 8,
respectively. Since our goal is to get some preliminaries on
SPI, I’ve named the pin signals with their SPI equivalents.
// Set alternate LEDs on off
// 0x5555 HEX <> 0101010101010101 binary
Uint16_t myVar = 0x5555;
// Clear slave select
// so data won’t show while shifting
clear_ss();
// output 16 bits to the 595
for (i=0; i<=15; i++)
{
// Put bit on mosi_pin
if(is_bit_set(myVar, i)
set_mosi_bit();
else
clear_mosi_bit()
// Toggle the clock to output it
toggle_clock();
}
// Set slave select to transfer data
// from serial to parallel registers
set_ss();
■ FIGURE 7. Serial-In-Parallel-Out Schematic.
Since our purpose at this
point is to get the 595 working,
we’ll defer looking at the SPI
macros in the code snippet
(hey are in the source code).
Using the 74HC597
— Read an eight-bit
DIP Switch
We will test this IC using
the circuit shown in Figure 8.
We use the 597 by first
toggling the storage register
clock input pin 12 (ST_CP) to
shift the parallel port input pin
states (D0-D7) to the parallel
register. Next, we toggle the
parallel load line pin 13 (/PL)
which causes the 597 to move
the data present in the parallel
input register to the serial shift
register. Finally, we toggle the
shift register clock input pin 11
(SH_CP) eight times to shift the
62
November 2010