A SERVICE OF

logo

SERIAL PORTS SECTION 4
Page 4-4 RPC-320
You can access C OM0 and COM1 buffers in three w ays:
1. INPUT statement. This removes all characters in
the buffer up to the term inator character and puts
them into a variable.
When using the INPUT statement, program
execution is suspended until a < cr> (Enter key) is
received. Whether 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 removed one at a
time as an ASCII value. A 0 is returned when the
buffer is empty. Use the COM function to
determine if the buffer is empty or if a 0 is an
ASCII value. Use UIn to select the serial port for
GET.
If you don' t read the buffer and the buffer fills, all
subsequent characters are discarded.
3. COM$(n) retrieves all characters in the buffer,
including other control codes (except CR).
ACCESSING COM0 AND COM1
INPUT and GET functions retrieve data using the UIn
command. UI0 routes inputs to COM0 while UI1 inputs
from the COM1 port. PRINT outputs are set by the
UOn command. UO0 prints out COM0 while UO1
outputs COM1 using the PRINT command. PR INT #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 COM 1
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 Programming Manual and
RPBASIC-52 Software Supplement in this manual.
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
PRINT Outputs data in various
formats
PRINT #, Prints to a specified port
SPC Print out n number of spaces
STR String handling commands
TAB Tabs to predetermined
positions
UI0 Reroute inputs to COM0
UI1 Route inputs to COM1
UO0 Reroute PRIN T statement to
COM0
UO1 Route PRINT 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
J2 from card
3 Tx Out
4 RTS* In