SERIAL PORTS

You can access C OM0 and COM 1 buffers in three w ays:

1.INP UT sta tement. This re moves a ll charac ters in the buffer up to the term inator cha racter and puts them into a variable.

When using the INPUT statement, program execution is susp ended 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 rec eived.

2.GET function. Char acters ar e rem oved one at a time as an ASCII value. A 0 is returned when the buffer is e mpty. Use the C OM function to determine if the buffer is empty or if a 0 is an ASCII value . Use UIn to select the serial port for G E T.

If you don' t read the b uffer an d 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

INPU T and GET functions retrieve data using the UIn comm and. UI0 r outes inputs to C OM 0 while U I1 inputs from the CO M1 port. PRINT outputs are set by the UOn command. UO0 prints out COM0 while UO1 outputs COM1 using the PRIN T comm and. PR INT #1, is an alternative way to print to COM 1.

The following show how UIn and U On work.

100 UI0Set to COM0

110 INPUT A Get data from COM0 port

520 UI1Switch to COM1 port

530 INPUT B Get data from COM1 port

800

REM

P r in t t o C O M 0

810

PRINT "Temperature:",T

900 REM Print to COM 1

910PRINT#1, "Set pressure at:",CA

Power up default is set to COM 0.

SECTION 4

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 statemen t:

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.

Comm and

Function

C L E AR C O M $

Clears serial input buffer

C O M $

Returns string from buffer

COM

Returns number of characters

 

in buffer

CONFIG BAUD

Sets serial port parameters

GET

Returns a character fr om the

 

serial buffer

INPUT

Receives string from port

LIST

Outputs program listing

PRINT

Outputs data in various

 

form ats

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

Rerou te PRIN T statem ent to

 

C O M 0

UO1

Route P RINT statement to

 

C O M 1

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

Page 4-4 RPC -320

Page 18
Image 18
Remote Technologies RPC-320 manual Accessing COM0 and COM1, Disabling CONTROL-C, Serial Port PIN OUT