SHIFTOUT - BASIC Stamp Command Reference
Page 316
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
Demo Program (SHIFTOUT.bs2)
' This program uses the SHIFTOUT command to interface to the 74HC595 shift register as an
' 8-bit output port. The '595 requires a minimum of three inputs: data, clock, and latch. See
' the figure in the SHIFTOUT command description in the manual for wiring information.
' SHIFTOUT automatically handles the data and clock, pulsing the clock to shift data bits into
' the '595. An extra step (pulsing the latch input) is required to move the shifted bits in parallel
' onto the '595's output pins. Note: this code does not control the output-enable or reset lines
' of the '595. This means that before the BASIC Stamp first sends, the '595's output latches
' are turned on and may contain random data. In critical applications, you should hold
' output-enable high (disabled) until the BASIC Stamp can take control.
'{$STAMP BS2} 'STAMP directive (specifies a BS2)
DataP CON 0 ' Data pin to 74HC595.
Clock CON 1 ' Shift clock to 74HC595.
Latch CON 2 ' Moves data from register to output latch.
Counter VAR BYTE ' Counter for demo program.
' This loop moves the 8-bit value 'counter' onto the output lines of the '595, pauses, then
' increments counter and repeats. The data is shifted msb first so that the msb appears on
' pin QH and the lsb on QA. Changing 'msbfirst' to 'lsbfirst' causes the data to
' appear backwards on the outputs.
Again:
SHIFTOUT DataP,Clock,MSBFIRST,[Counter] ' Send the bits.
PULSOUT Latch,1 ' Transfer to outputs.
PAUSE 50 ' Wait briefly.
Counter = C 1 ' Increment counter.
GOTO Again ' Do it again.
2
e
2
sx
2
p
2
74HC595
To P0
1
2
3
4
5
6
7
8
16
15
14
13
12
11
10
9
QB
QC
QD
QE
QF
QG
QH
GND
VCC
QA
DATA IN
OE
LATCH
CLK
RESET
SQH
Vss
LEDs
470 (all)
Ω
Vdd
Vdd
Vss
To P2
To P1
NOTE: This is written for the BS2
but can be used for the BS2e,
BS2sx and BS2p also. Locate the
proper source code file or modify
the STAMP directive before
downloading to the BS2e, BS2sx or
BS2p.
Figure 5.40: SHIFTOUT Timing
Diagram. Refer to the SHIFTOUT
Quick Answers table for timing
information on t
h
, t
l
, t
a
and t
b
.
Содержание BASIC Stamp 1
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...