Remote Processing CAMBASIC User Manual

Page 151

Advertising
background image

Comm ands - 118

SPI

F U N C T IO N

SYNTAX:

a = SPI(channel,out_length,data, delay,in_length)

Where:
channel = 0 to 2, the SPI channel number.
out_length = 0 to 16, data output leng th in bits. W hen zer o, n o data is shifted ou t. data can be any
value but must be included.
data = 0 to 65,535, comm and/data to send to SPI device.
delay = time to wa it before r etrieving inf orm ation from SPI por t after the last b it is shifted out.
Time in micro-seconds is calculated as follows: time = delay * 1.1 + 4. If 0, there is no delay.
Use 0 if there is no data to retrieve (i.e. sending to D/A).
in_length = 0 to 16, data input length in bits. W ill return a number from 0 to 65535.

PURPOSE:

Writes to and receives data from SPI port. This port is not on all boards. Refer to hardware
manua l.

REMARK S:

SPI (Serial Peripheral Interface) is used to comm unicate with a number of IC’s. These include
D/ A’s, A/D ’s, U ART ’s, a nd other d evices. The num ber of po rts is har dwar e depende nt.

The SPI fun ction is used to read and wr ite data. U nfortunately, SPI has a var iety of data formats.
Data to send and receive from a device can be anywhere from 8 to 24 bits. The clock polarity can
idle high or low and the phase when data is latched.

The SP I function supp orts the follow ing form at:

Clock idle polarity: low
Clock-data phase: low

This form at supports the M axim M AX186/ 188 and Burr-Br own AD S7843 IC’s.

If your form at needs are differ ent, the C AMBA SIC prog ram (SP IDEM O. BAS) can be used as a
basis to read and wr ite to other SPI devices.

Some boards (such as the RPC -2350) have pre-assigned ports. Refer to your hardware m anual for
specific information.

Not all boards support this command (such as the RPC-150 and R PC-2300).

RELATED:

none

EXAMPLE:

10

SPI(2,8,&e8,10,12)

ERROR:

< Data neg> - for any parameters

Advertising