trs80: Improve RS-232 driver

I could drive my RC2014 from my TRS-80 4P (using the Remote Shell
coming in the next commit)! A challenge I faced was that the RC2014
spits characters too fast and the CTS line of its ACIA modules
(both the 6850 and SIO/2 ones) are hard-wired to ground, making
flow control difficult. I solved this, for now, by lowering comm
speed.

This driver improvement makes CL<? faster and makes baud rate
configurable in CL$.
This commit is contained in:
Virgil Dupras 2021-01-03 13:56:53 -05:00
parent 772c0c4fe4
commit 0f83451193
3 changed files with 35 additions and 6 deletions

View File

@ -9,7 +9,7 @@ Load with "602 LOAD".
There is also the RECV program at B612. There is also the RECV program at B612.
( ----- 602 ) ( ----- 602 )
1 8 LOADR+ 1 9 LOADR+
( ----- 603 ) ( ----- 603 )
CODE (key?) ( -- c? f ) CODE (key?) ( -- c? f )
A 0x08 LDri, ( @KBD ) A 0x08 LDri, ( @KBD )
@ -100,10 +100,19 @@ EXX, ( unprotect BC ) ;CODE
: FD! ['] @WRSEC SWAP FD@! ; : FD! ['] @WRSEC SWAP FD@! ;
: FD$ ['] FD@ ['] BLK@* **! ['] FD! ['] BLK!* **! ; : FD$ ['] FD@ ['] BLK@* **! ['] FD! ['] BLK!* **! ;
: CL$ 0x02 0xe8 PC! ( UART RST ) 0xee 0xe9 PC! ( 9600 bauds ) ( ----- 611 )
0b01101100 0xea PC! ( word8 no parity RTS ) ; : CL$ ( baudcode -- )
0x02 0xe8 PC! ( UART RST ) DUP 4 LSHIFT OR 0xe9 PC! ( bauds )
0b01101101 0xea PC! ( word8 no parity no-RTS ) ;
: CL> BEGIN 0xea PC@ 0x40 AND UNTIL 0xeb PC! ; : CL> BEGIN 0xea PC@ 0x40 AND UNTIL 0xeb PC! ;
: CL< BEGIN 0xea PC@ 0x80 AND UNTIL 0xeb PC@ ; CODE _
0xea INAi, 0x80 ANDi, IFZ, PUSH0, ELSE,
0xeb INAi, PUSHA, PUSH1, THEN,
;CODE
: CL<? _ IF 1 EXIT THEN
0b01101100 0xea PC! ( RTS )
1 TICKS ( 100 us ) _
0b01101101 0xea PC! ( no-RTS ) ;
( ----- 612 ) ( ----- 612 )
( We process the 0x20 exception by pre-putting a mask in the ( We process the 0x20 exception by pre-putting a mask in the
(HL) we're going to write to. If it wasn't a 0x20, we put a (HL) we're going to write to. If it wasn't a 0x20, we put a

View File

@ -28,3 +28,16 @@ can be raised) very much. We have to take extra care, when
communicating from modern system, not to send too much data too communicating from modern system, not to send too much data too
fast. But for COS-to-COS communication, this simple system fast. But for COS-to-COS communication, this simple system
works. works.
# Broken hardware
Some designs are broken with this scheme. For example, the
RS2014 SIO module hard-wires CTS to GND because the FTDI
connector doesn't have such a pin (modern computers can always
handle the load).
In these cases, a solution would be to use Break signals as a
workaround, but I prefer avoiding complexity for now. So when
you deal with broken design, you'll have to sidestep it either
by implementing your own Break handling or by lowering com-
munication speed.

View File

@ -270,8 +270,15 @@ means there's a limit of 100 blocks per disk.
You'll need to send those blocks through RS-232. First, let's You'll need to send those blocks through RS-232. First, let's
initialize the driver with CL$. This driver does not require initialize the driver with CL$. This driver does not require
the TRS-DOS driver to be loaded. Also, it is hardcoded to the TRS-DOS driver to be loaded. Also, it is hardcoded to
"no parity, 8 bit words, 9600 bauds". Now, let's have the CL "no parity, 8 bit words". And takes a "baud code" as an argu-
take over the prompt: ment. It's a 0-15 value with these meanings:
00 50 01 75 02 110 03 134.5
04 150 05 300 06 600 07 1200
08 1800 09 2000 0a 2400 0b 3800
0c 4800 0d 7200 0e 9600 0f 19200
After CL$ is called, let's have the CL take over the prompt:
' CL> ' EMIT **! ' CL> ' EMIT **!
' CL< ' KEY **! ' CL< ' KEY **!