a E i - Commodore Is Awesome
a E i - Commodore Is Awesome
a E i - Commodore Is Awesome
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
without<br />
<strong>Is</strong>o work<br />
nd PC20<br />
thing to<br />
,<br />
sfour<br />
and<br />
t innected<br />
I<br />
6. The<br />
lar con-<br />
B<br />
ferences<br />
Mthat<br />
this<br />
but it<br />
ve also<br />
in f ra me<br />
at 1200<br />
You've<br />
not her<br />
! On a<br />
s using<br />
m LISt<br />
IND/<br />
data.<br />
1<br />
. IV that<br />
uipting<br />
s<br />
.lso be<br />
14. the<br />
e<br />
!rs are<br />
!mory<br />
:uteri<br />
fined<br />
is/4).<br />
t any<br />
(It<br />
you<br />
tate•<br />
rani.<br />
:curs<br />
arge.<br />
Ning<br />
end<br />
of your program. So Beware!<br />
The format for the OPEN statement<br />
is shown below:<br />
OPEN Ifn.dev,sec,CH RS (control<br />
register)+CHR$ (command register)<br />
where:<br />
1fn = logical file number<br />
dev = device (2 for RS232)<br />
sec = secondary address (usually 0)<br />
S - stop bits<br />
0- one<br />
I - two<br />
R (plus 4 only)<br />
0- external clock<br />
1- internal clock<br />
(keep to 1)<br />
Table 2<br />
bit 7 6<br />
S D<br />
D - data bits<br />
DD<br />
00 - 8<br />
01 - 7<br />
10 - 6<br />
II - 5<br />
2400 baud is the maximum speed<br />
that is available on the <strong>Commodore</strong><br />
RS232 on the C128. The C64 vvill allow<br />
up to 1200 so this is the maximum<br />
baud rate that I will use in the<br />
PPP<br />
000 Disabled<br />
0010dd<br />
011 Even<br />
101 Mark (I)<br />
III Space (0)<br />
RS232<br />
= see below<br />
= see below<br />
The RS232 interface is device<br />
number two. In order to operate<br />
correctly, the system requires you to<br />
tell it how fast you wish to transfer<br />
data (baud rate) and the format of the<br />
data number of stop bits, number of<br />
data bits, parity). The control<br />
register tells the system the baud<br />
rate, stop bits and data bits as in Table 2.<br />
5 4 3 2<br />
D R B B<br />
B - baud rate<br />
BBBB<br />
0001<br />
0010<br />
0011<br />
0100<br />
0101<br />
0110<br />
01H<br />
1000<br />
1001<br />
1010<br />
1 0<br />
B B<br />
R - Rclock<br />
50<br />
75<br />
1 I()<br />
134.5<br />
150<br />
300<br />
600<br />
1200 (C64 max)<br />
1800<br />
2400 (max)<br />
Plus/4 capable of up to<br />
19200 baud<br />
bit 7 6 5 4 3 2 I 0<br />
P P P D T T R H<br />
P - Parity D - duplex H - handshake<br />
T - Transmit control R - receive control<br />
0 Full<br />
I Half<br />
'VT (Plus/4 only)<br />
00 IRQ Disabled; RTS= I ; TX off<br />
01 IRQ Enabled; RTS=0; TX On<br />
10 IRQ Disabled; RTS=0; TX On<br />
II IRQ Disabled; RTS=0; BRK<br />
Plus/4 users should refer to pages<br />
207-211 of the user manual for further<br />
details on their machine's RS232 interface_<br />
This machine can handle transfer<br />
rates of up to 19200 baud.<br />
Handshake determines how the<br />
interface will operate. We will be using<br />
3-line. X-line is where you are using<br />
control lines as well as the data lines.<br />
examples. If however you have any<br />
problems, try selecting 600 baud<br />
instead.<br />
The command register defines<br />
other interface parameters as follows<br />
H (non PLUS4)<br />
0 3-line<br />
I X-line<br />
R (Plus/4 only)<br />
0 IRQ on<br />
I IRQ off<br />
H (PLUS4)<br />
0 Receiver on<br />
1 Receiver off<br />
Table 3<br />
This makes things a bit complex so we<br />
will stick to 3-line.<br />
Duplex should be set to Full. This<br />
determines how the receive and<br />
transmit will behave.<br />
Parity is a kind of error check.<br />
When data is received, the system<br />
checks it to see if it agrees with the<br />
parity. If not, the parity error bit in the<br />
YOUR COMMODORE january 1987<br />
85<br />
variable ST (status) is set indicating<br />
some sort of error. These bits allow<br />
you to set the type of parity check<br />
required. Of course, both machines<br />
should be set to the same parity. In<br />
most cases, parity is not used and error<br />
checking is done in a different way<br />
(more on this later).<br />
This may seem a little complex but<br />
it isn't really. Lets suppose that we<br />
want to open an RS232 channel to run<br />
at 1200 baud, eight data bits, one stop<br />
bit, no parity. The OPEN statement<br />
would be:<br />
OPEN 2,2,0,CHRS(24)+CH RS(0)<br />
(non Plus/4)<br />
OPEN 2,2,0,CHRS(24)+CHRS(5)<br />
(Plus/4)<br />
and that is that! Simple, eh? In fact, if<br />
you stick to this particular format of<br />
eight data bits and no parity, you can't<br />
really go wrong. Just change the baud<br />
rate to suit.<br />
Incidentally, the <strong>Commodore</strong> 64<br />
programmers reference Guide tells<br />
you that the command<br />
register character is NOT required.<br />
It's probably safer to leave it in. My<br />
C128 sometimes won't work without<br />
it!<br />
Using PRINT# AND GET# we can<br />
write a fairly simple terminal program<br />
running at 1200 baud. Running this on<br />
two machines (assuming its two<br />
<strong>Commodore</strong>s) you will be able to type<br />
in a message on one keyboard and see<br />
it appear on the other machines display<br />
as well as your own. Figure 7<br />
shows the program while Figure 8<br />
shows a similar program for an IBM<br />
compatible machine running PCDOS<br />
or MSDOS and G BASIC.<br />
Figure 7 <strong>Commodore</strong> Basic mini<br />
terminal program<br />
10 OPEN 2,2,0,CHRS(24)-1-CHRS(0)<br />
11 REM PL0S4 USERS USE OPEN<br />
2,2,0,CH R$(24)-i-CH R$(5)<br />
20 PRINT "[CLS]"<br />
30 GETI42,AS<br />
40 IF A$"" THEN PRINT AS;<br />
50 GET 13$<br />
60 IF 13S"" THEN PRINT<br />
B$;:PRINT#2,BS:<br />
70 GOTO 30<br />
Figure 8 GM/BASIC mini terminal<br />
program<br />
10 OPEN -<br />
20 COM1: CLS<br />
30 1200, IF LOC( I )=0 THEN 50<br />
40 N,8,1 AS=INPUTS(1,#1);PRINT AS:<br />
-<br />
A<br />
S