5: BASIC Stamp Command Reference – SHIFTIN
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 311
Here is a simple example:
Result VAR BYTE
SHIFTIN 0, 1, MSBPRE, [ Result ]
Here, the SHIFTIN command will read I/O pin 0 (the Dpin) and will
generate a clock signal on I/O 1 (the Cpin). The data that arrives on the
Dpin depends on the device connected to it. Let's say, for example, that a
shift register is connected and has a value of $AF (10101111) waiting to be
sent. Additionally, let's assume that the shift register sends out the most
significant bit first, and the first bit is on the Dpin before the first clock
pulse (MSBPRE). The SHIFTIN command above will generate eight clock
pulses and sample the data pin (Dpin) eight times. Afterward, the Result
variable will contain the value $AF.
By default, SHIFTIN acquires eight bits, but you can set it to shift any
number of bits from 1 to 16 with the Bits argument. For example:
Result VAR BYTE
SHIFTIN 0, 1, MSBPRE, [ Result \4 ]
Will only input the first 4 bits. In the example discussed above, the Result
variable will be left with %1010.
Some devices return more than 16 bits. For example, most 8-bit shift
registers can be daisy-chained together to form any multiple of 8 bits; 16,
24, 32, 40... To solve this, you can use a single SHIFTIN instruction with
multiple variables. Each variable can be assigned a particular number of
bits with the Bits argument. As in:
ResultLow VAR WORD
ResultHigh VAR NIB
SHIFTIN 0, 1, MSBPRE, [ ResultHigh\4 , ResultLow\16]
The above code will first shift in four bits into ResultHigh and then 16 bits
into ResultLow. The two variables together make up a 20 bit value.
A
SIMPLE
SHIFTIN
EXAMPLE
.
C
ONTROLLING THE NUMBER OF BITS
RECEIVED
.
Содержание BASIC Stamp 2e
Страница 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...