Chapter 4 serial ports – Remote Processing RPC-2350 User Manual

Page 24

Advertising
background image

CHAPTER 4

SERIAL PORTS

4-5

is empty.

In this mode, you have access to the full 256 bytes.
If you don' t read the b uffer an d the buffer fills, all
subsequent characters are discarded. INKEY$(n)
m a y be u se d an y w he r e in th e pr o g ra m .

3.

COM$(n) retrieves all characters in the buffer,
including < cr> ' s and other control co des. This
function is commonly used with ON COM$
multitasking statement. You can retrieve 128 of the
256 bytes in the serial buffer at one time.

DISABLING PROGRAM BREAK

Program execution can be interrupted by pressing the
< Esc> key. To disable this recognition so the program
does not terminate, put the following command in your
p r o gr a m :

1000 CONFIG BREAK port,1

Where port is 1 (J1) or 2 (J4 or P3).

SPI PORT

A software SPI port is provided at J11. SPI (Serial
Peripheral Interface) is used to communicate with a
number of IC’s. These include D /A’s, A/D ’s, U ART’s,
and other devices. J11 provides two chip selec ts.

The optional touch screen interface uses SPI port 1.

The SPI function is used to read and write data.
Unfor tunately, SPI has a v ariety of da ta form ats. D ata
to send and receive from a device can be anywher e from
8 to 24 bits. The clock polarity an d data phase c an idle
high or low when data is latched.

CAM BASIC SPI func tion suppor ts the following f orm at:

Clock idle polarity: low
Clock-data phase: low

This format supports the Maxim MAX186/188 and Burr-
Brown ADS7843 IC’s. The program SPIDEMO1.BAS
u se s t he M A X 18 6 /1 8 8 t o r e tu r n t he r es ul t o f a n A/ D
calculation. Functionally, it is the same as the AIN
command.

If your form at needs are differ ent, ther e is a
CAM BASIC program (SPIDE MO2. BAS) that you can

use as a basis to read and w rite to other SP I devices.

Comm and form at is:

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

Where:

channel = 0 to 2, the SPI channel number.

out_length = 0 to 16, data outpu t length in bits.
When z ero, no data is shifted ou t. data can be any
value but must be included.

data = 0 to 65,535, command/data to send to SPI
device.

delay = time to wait before retrieving information
from SPI port. T ime in micro-seconds is calculated
as follows: time = delay * 1.1 + 4. If 0 , the re 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.

The table below sho ws the location of SPI device selects.
A device is selected when a line goes low.

SPI port number

Location

0

Analog input (U10)

1

J11-4

2

J11-5

Advertising