Playing With Electricity

Author(s): Harvey Taylor
Publication: ZX-Appeal
Date: February 1986
Pages: 7, 12

THE SERIAL PROBLEM – A CONTINUING SAGA

There is a problem with the serial ports on the QL. Sinclair calls them full, bidirectional RS-232 interfaces & one would hope that meant everything it is supposed to, but Sinclair cheapness has struck a low blow. Instead of doing the proper thing and using a full Uart, Sinclair uses the 8049 Intelligent Peripheral Controller (IPC) for input and part of a custom Undifferentiated Logic Array (ULA) for output. The problem arises from the fact that the 8049 has a lot to do & cannot watch the input line all the time. It is liable to miss characters. To get around this Sinclair has implemented the DTR pin; when the 8049 is busy it pulls DTR low. Any hardware wishing to talk to the QL has to monitor DTR. Most modems are not set up to do this. Consequently most modems show a lot of errors. A further problem arises from the fact that, while parity and baud rate are under program control, the number of stop bits is not. The QL always uses 2 stop bits. Most North American BBS’s use 1 stop bit. These factors make it difficult to set up any of the simpler kinds of modems, such as Steve Ciarcia’s TMS99532 based project.

My reason for writing this article is to search out any solutions other people have tried in trying to circumvent these limitations. If you have got a modem working with a QL with any degree of success, please drop me a line.

This is a brief description of what I have tried myself. My first attempt was to simply to “stick an ultra simple TMS99532 modem on the serial ports. This resulted in such a high level of errors in reception and transmission that I was unable to log onto any local BBS. (Sigh)

My second attempt was to design a slightly more complicated modem incorporating (2) two Uarts. One Uart was set to 2 stop bits and 300 baud like the QL, the other set to the parameters of whatever BBS I was communicating with. Once data was available on one Uart, the data available pin would go high, which triggered a one shot to strobe the write pin on the other Uart as well as clearing the Data available flip flop on the first. The result of this project was scarcely better than the first. I was still unable to log onto any BBS.

My third attempt was to utilize the DTR line as well as the Data Available pin on the second Uart to strobe the Data into the first Uart which ran at 9600 baud. The effect of this is to use the second Uart as a one byte buffer. Surprisingly this shortcut method works to a degree. Now however the original board is so hacked up that I will have to build another. My present board has a problem with its power supply & I want to try direct connect. This may be all which is keeping me from BBS land. As the present device is it is too unreliable to implement Xmodem.

It would seem that the next level would be to design a smart buffered modem which is capable of monitoring the DTR line on the QL. This will involve an extensive project with a dedicated controller chip like a Z8 or suchlike. I have not yet started work on this sort of a device. Coincidentally the two QL modems for sale in Britain incorporate a form of buffering between the modem and the QL.

Let me repeat my plea. If you have found another way around this conundrum, drop me a line , please! { H. Taylor/ QL Conundrums/ [address omitted] }

The circuit diagram is the latest semi-buffered design described above & the code is the simple terminal I have been using.

QL CAD circuit diagram of the semi-buffered modem
QL CAD circuit diagram of the semi-buffered modem
*
*            QL   TERMINAL
*
*                 Harvey Taylor
*                 started Sept 4/85
*
                  GET      'FLP1_STANDARD_HDR3'
PRIORITY          EQU      127
MT_RELJB          EQU      09
*
JOB_DEFN          BRA.S    START
                  DC.L     0
                  DC.W     $4AFB
                  DC.W     8
                  DC.B     'TERMINAL'

START             MOVEQ    #THIS_JOB,D1 * set job priority to highest
                  MOVEQ    #PRIORITY,D2
                  QDOS     MT_PRIOR,1
                  BNE      ERROR

                  MOVEQ    #0,D1          * SUSPEND BASIC
                  MOVEQ    #-1,D3         * timeout
                  MOVE.L   #0,A1
                  QDOS     MT_SUSJB,1
                  BNE      ERROR

                  LEA      CON_PAR,A1     * open the main console
                  VECTOR   UT_CON,A2
                  BNE      ERROR
                  LEA      CHAN_CON,A1
                  MOVE.L   A0,(A1)        * SAVE CONSOLE ID
                  MOVE.L   A0,A4          * IN A4 TOO

                  MOVEQ    #-1,D3         * enable a cursor in
                  QDOS     SD_CURE,3      * the main console
                  BNE      ERROR

                  LEA      DEVNAME,A0     * open ser2hr
                  MOVEQ    #THIS_JOB,D
                  MOVEQ    #2,D3
                  QDOS     IO_OPEN,2
                  BNE      ERROR
                  LEA      CHAN_SER,A1
                  MOVE.L   A0,(A1)        * SAVE SERIAL CHANNEL ID
                  MOVE.L   A0,A5          * IN A5 TOO

                  MOVE.W   #9600,D1       * BAUD RATE
                  QDOS_n   MT_BAUD,1      * NO ERROR RET

HELLO             LEA      SCR_PAR,A1
                  VECTOR   UT_SCR,A2      * open info screen
                  BNE      ERROR
                  LEA      CHAN_SCR,A1
                  MOVE.L   A0,(A1)

SND_MSG1          MOVE.W   #2,D1
                  MOVE.W   #0,D2          * set print size of info screen
                  QDOS     SD_SETSZ,3
                  BNE      ERROR

                  MOVEQ    #-1,D3         * timeout
                  LEA      MSG1,A1
                  QDOS     IO_SSTRG,3     * print msg
                  BNE      ERROR

MAINLOOP
CHK_SERIAL        MOVEQ    #0,D3          * TIMEOUT
                  MOVE.L   A5,A0          * SERIAL CHAN ID
                  QDOS     IO_PEND,3
                  BEQ      GET_SERIAL
                  CMPI     #-1,D0         * NOT COMPLETE
                  BEQ      CHK_KBRD
                  BRA      ERROR_M

* OTHER ERROR TESTS OF IO_PEND HERE

GET_SERIAL        QDOS     IO_FBYTE,3
                  BNE      ERROR_M
                  BSR      PRINT_IT

CHK_KBRD          MOVE.L   A4,A0
                  MOVE.W   #0,D3
                  QDOS     IO_PEND,3
                  BEQ      GET_KBRD
                  CMPI     #-1,D0
                  BEQ      MAINLOOP
                  BNE      ERROR_M

GET_KBRD          QDOS     IO_FBYTE,3
                  BNE      CHEK_ERR
                  CMPI     #232,D1
                  BEQ      CL_EXIT

* INSERT OTHER TESTS HERE

                  BRA      SEND_IT
CHEK_ERR          CMPI     #-1,D0
                  BEQ      MAINLOOP
                  BRA      ERROR_M

SEND_IT           BSR      PRINT_IT
                  MOVEQ    #0,D3
                  MOVE.L   A5,A0
                  QDOS     IO_SBYTE,3
                  BNE      ERROR_M
                  BRA      MAINLOOP

PRINT_IT          MOVE.B   D1,D2
                  MOVE.L   A4,A0
                  MOVE.W   #0,D3
                  QDOS     IO_SBYTE,3
                  BEQ      P_EXIT
                  BSR      ERROR_MSG
P_EXIT            MOVE.B   D2,D1
                  RTS
*
ERROR_M           BSR      ERROR_MSG
                  BRA      MAINLOOP

CL_EXIT           LEA      CHAN_SCR,A0
                  MOVE.L   (A0),A0
                  MOVE.W   #MSG2LEN,D2
                  MOVEQ    #-1,D3
                  LEA      MSG2,A1
                  QDOS     IO_SSTRG,3
                  BNE      ERROR
                  BRA      EXIT

ERROR_MSG         MOVE.L   D0,-(A7)
                  LEA      SCR_ERR,A1
                  VECTOR   UT_SCR,A2
                  MOVE.L   (A7)+,D0
                  VECTOR   UT_ERR,A2
                  QDOS     IO_CLOSE,3
                  RTS

ERROR             BSR      ERROR_MSG
*
EXIT              LEA      CHAN_SCR,A0
                  MOVE.L   (A0),A0
                  QDOS     IO_CLOSE,2
                  LEA      CHAN_CON,A0
                  MOVE.L   (A0),A0
                  QDOS     IO_CLOSE,2
                  LEA      CHAN_SER,A0
                  MOVE.L   (A0),A0
                  QDOS     IO_CLOSE,2
* CON CHAN ID
* TIMEOUT

* NOT COMPLETE


* F1=EXIT

eg. F2,F3 etc.

* NOT COMPLETE

* ONLY EF=-10?

* IS THIS THE TIMEOUT TO USE?
* SER CHAN ID


* CON CHAN ID


* D1 PRESERVED FOR SENDIT


* SAVE ERROR CODE
* OPEN ERROR SCREEN

* REPORT ERROR
* CLOSE ERROR CHANNEL
SUSP_JOB          MOVEQ    #THIS_JOB,D1
                  MOVEQ    #-1,D3              * INDEFINITE TIMEOUT
                  MOVE.L   #0,A1               * NO FLAG BYTE
                  QDOS     MT_SUSJB,1

                  MOVEQ    #0,D1
                  QDOS     MT_RELJB,1          * RELEASE BASIC
                  MOVEQ    #0,D0               * INSURANCE
                  RTS
*
MSG1              DC.B     '        QL TERMINAL'
MSG1END
MSG1LEN           EQU      MSG1END-MSG1
                  CNOP     0,4
MSG2              DC.B     ' OFFLINE '
MSG2END
MSG2LEN           EQU      MSG2END-MSG2
                  CNOP     0,4
*
CHAN_SCR          DS.L     1
CHAN_SER          DS.L     1
SCR_PAR           DC.B     4                   * BRDR COLOR
                  DC.B     2                   * BRDR WDTH
                  DC.B     0                   * PAPER COLOR
                  DC.B     4                   * INK
WIN_BLK           DC.W     360                 * WIDTH
                  DC.W     14                  * DEPTH
                  DC.W     76                  * X-ORIGIN
                  DC.W     0                   * Y-ORIGIN

                  CNOP     0,4
CON_PAR           DC.B     2
                  DC.B     2
                  DC.B     0
                  DC.B     4
                  DC.W     480
                  DC.W     212
                  DC.W     16
                  DC.W     16
                  DC.W     128                 * BUFFER LENGTH
                  CNOP     0,4

SCR_ERR           DC.B     4
                  DC.B     1
                  DC.B     0
                  DC.B     2
                  DC.W     480
                  DC.W     24
                  DC.W     16
                  DC.W     232
                  CNOP     0,4

DEVNAME           DC.W     6
                  DC.B     'SER2'
                  DC.B     'h'
                  DC.B     'r'
                  CNOP     0,4

                  END