
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 buffer an d the buffer fills, all
subsequent characters are discarded. INKEY$(n)
may be used anywhere in the program.
3. COM$(n) retrieves all characters in the buffer,
including < cr> ' s and other control codes. 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
program:
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 selects.
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 formats. D ata
to send and receive from a device can be anywhere 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 function supports the following form 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
uses the MAX186/188 to return the result of an A/D
calculation. Functionally, it is the same as the AIN
command.
If your form at needs are different, ther e is a
CAMBASIC program (SPIDE MO2. BAS) that you can
use as a basis to read and write to other SPI devices.
Comm and format 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 output length in bits.
When zero, no data is shifted out. 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. 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.
The table below shows 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
Komentáře k této Příručce