SHIFTOUT
 
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 array defines the number of bits that will be shifted out (1 - 32) for each corresponding element of the listOUT array.  If shiftCounts is 0, it is assumed to be 8 bits.

NOTE***  these shift modes are compatible 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 inbuf(20) as string
DIM outbuf(20) as string

'  mixed SPI, SHIFT example for a 93LC46 connected to pins 11-14

IO(14)=1                              ' CS to 93LC46
listOUT(0) = &H260
shiftCounts(0) = 10
SHIFTOUT(12,13,0,1)                 '  write enable  
IO(14)=0

listOUT(0) = &H280                 ' count still 10
outbuf(0) = $41
IO(14)=1
SHIFTOUT(12,13,0,1)                 ' set write to address 0
SPIOUT (-1, 13, 12, 0, 1, outbuf) ' send a byte of data
IO(14)=0

wait(20)                                     ' allow for write time

IO(14)=1
listOUT(0) = &H300
SHIFTOUT(12,13,0,1)                 '   read addr 0
SPIIN (-1, 11, 13, 12, 0, -1, "", 10, inbuf) ' read 10 bytes of data
IO(14)=0



Differences from other BASICs

See also