
SERIAL PORTS SECTION 4
Page 4-4 RPC-330
Access CO M0 and C OM1 buffers in one of three ways:
1. INPUT statement. This removes a ll characters in
the buffer up to the term inator cha racter and puts
them into a variable.
When using the INPUT statement, program
execution is suspended until a < cr> (Enter key) is
received. W hether this is a problem depends on
your particular application.
INPUT strips bit 7. This means ASCII characters
from 0 to 127 are received.
2. GET function. Characters ar e rem oved one at a
time as an ASCII value. A 0 is returned when the
buffer is empty. Use the C OM function to
determine if the buffer is empty or if a 0 is an
ASCII value.
If you don' t read the b uffer an d the buffer fills, all
subsequent characters are discarded. GET m ay be
used anywhere in the program.
3. COM$(n) retrieves all characters in the buffer,
including other control codes (except CR).
ACCESSING COM0 AND COM1
The port INPUT and GE T functions retrieve data using
the UIn command. UI0 routes inputs to C OM0 while
UI1 routes inputs to the COM1 port. PRINT outputs are
set by the UOn command. UO0 p rints out C OM0 while
UO1 outputs COM1. PRINT #1, is an alternative way
to print to COM 1.
The following show how UIn and UOn work.
100 UI0 Set to COM0
110 INPUT A Get data from COM0 port
520 UI1 Switch to COM1 port
530 INPUT B Get data from COM1 port
800 REM Print to COM0
810 PRINT "Temperature:",T
900 REM Print to COM1
910 PRINT #1, "Set pressure at:",CA
Power up default is set to COM0.
DISABLING CONTROL-C
Program execution is terminated by entering a
< Cntl> < C> . To disable < Cntl> < C> so program
execution is not terminated, execute the following
statement:
DBY(38) = DBY(38) .OR. 1
COMMANDS
The following is a list of RPBASIC-52 commands used
for serial I/O. These commands and functions are
explained in the BASIC-52 Programm ing Manual and
RPBASIC-52 Software Supplement in this manua l.
Command Function
CLEAR COM$ Clears serial input buffer
COM$ Returns string from buffer
COM Returns number of characters
in buffer
CONFIG BAUD Sets serial port parameters
GET Returns a character from the
serial buffer
INPUT Receives string from port
LIST Outputs program listing
ON COM$ Branches to a subroutine when
specified parameters are met
PRINT Outputs data in various
formats
PRINT #, Prints to a specified port
SPC Print out n number of spaces
STR Various string commands.
Useful for networking and
output formatting.
TAB Tabs to predetermined
positions
UI0 Reroute inputs to COM0
UI1 Route inputs to COM1
UO0 Rerou te PRIN T statement to
COM0
UO1 Route P RINT statement to
COM1
USING PRINT formatting statement
SERIAL PORT PIN OUT
Pin outs for J1 and J2 are shown below. Unused pins
are open.
J1 & Name Direction
Kommentare zu diesen Handbüchern