Syntax
#include
<SHIFT.bas>
' source in /Program Files/Coridium/BASIClib
SUB SHIFTOUT (OUTpin, CLKpin, LSBfirst, cnt)
Description
SHIFTOUT can be used for devices that are not covered by SPI, I2C or
1-Wire. Data is shifted out on OUTpin, and a positive clock is
sent on CLKpin for each bit.
While most other hardware functions use bytes, SHIFTOUT is oriented for bit
control. The shiftCounts of each shiftValues defines the number of bits
that will be shifted out (1 - 32). If shiftCounts is 0, it is assumed to
be 8.
- Mode = 0 data is shifted out MSB first
- Mode = 1 data is shifted out LSB first
NOTE*** these shift modes are compatable with
SHIFTIN, BUT not the same as PBASIC
Data is shifted out of the device at 300 Kbits/sec.
Example
#include <SHIFT.bas>
#include
<SPI.bas>
...
DIM inlist(20) as string
DIM outlist(20) as
string
' mixed SPI, SHIFT example for a 93LC46 connected to
pins 11-14
high
14
' CS to 93LC46
shiftValues(0) = $260
shiftCounts(0) = 10
SHIFTOUT(12,13,0,1) '
write enable
low 14
shiftValues(0) =
$280 '
count still 10
outlist(0) = $41
high 14
SHIFTOUT(12,13,0,1)
' set write to address 0
SPIOUT (-1, 13, 12, 0, 1, outlist) ' send a byte of
data
low 14
wait(20)
' allow for write time
high 14
shiftValues(0) = $300
SHIFTOUT(12,13,0,1)
' read addr 0
SPIIN (-1, 11, 13, 12, 0, -1, "", 10,
inlist) ' read 10 bytes of data
low 14
Differences from other BASICs
- none from Visual BASIC
- simplified from PBASIC
See also