2nd Serial Port Manual

By Robert Sprowson

Originally published in EUG #56

This file describes the ROM image 2NDSERIAL, which drives the associated second serial port card hardware which contains a 6850 serial chip so the machine can have two ports in use simultaneously. The image requires at least one 2k bank of Sideways RAM or to be put onto a ROM to work.

Instructions

At any command prompt, eg. the BASIC prompt ">", type

On a Master: *SRLOAD U.2NDSERI 8000 (socket#)
             *INSERT (socket#)
             where (socket#) may be 7, 6, 5 or 4
On a machine with SWRAM: *LOAD U.2NDSERI 8000
                         and press CTRL-BREAK to initialise.
On reset, the software will claim 3 pages of memory for its private use. One page of this is for new buffer management software and the other two are for serial input/output buffers, which means it cannot be in the 'hidden' workspace on a Master series machine.

You can control all the settings you would expect to be able to do with the normal on-board serial port such as baud rates, data formats, etc... Firstly, you must type *COM2 at the command line, so that changes to settings you make refer to the new serial port, then simply issue any *FX calls which you rewire to set up the serial port (referring to the BBC MICRO USER GUIDE).

To switch back to controlling the built-in serial port, issue a *COM1 command. So, for example, setting baud rates:

   *COM1            (talk to the on-board serial port)
   *FX 7,3          (sets receive speed of internal port to 300)
   *FX 8,4          (sets transmit speed of internal port to 1200)
   *COM2            (directs osbyte to the second serial port)
   *FX 7,6          (sets receive speed of the 2nd port to 4800)

Technical Information

The following conditions prevail at power up:

   OSBytes refer to:         COM1, the internal port
   Baud rate:                9600 transmit and receive
   Parity:                   None
   Stop bits:                1
   Data bits:                8
The input buffer id is 9 and output buffer id is 10.

Events will be generated which may be of interest to the programmer if an RS423 error occurs or a buffer becomes full or empty:

"RS423 error" .... the lost byte is passed in Y, the second serial
                   card's 6850 register is passed in X shifted right by
                   1 place
"Input buffer full" .... the unsuccessful byte is in Y and X=9
"Output buffer empty" .. enters with X=10

Known Problems/Future Enhancements

No known problems.
Could implement the remaining three unimplemented OSBytes.

History

v0.63 Modified test code to allow it to be run from ROM
v0.68 Added OSByte interface

Supported FX Calls

When preceded by a *COM2 command, the following OSBytes are listened for by the second serial card firmware. You may either type them directly at the command line with *FX or by calling the Osbyte routine from your own programs.

For calls with A > 165, the operation performed is:
newvalue = (oldvalue AND Y) EOR X

and returns with:
A = preserved
X = oldvalue
Y = undefined

   FX 2 (Select input stream)
      *FX 2, 0 disables RS423 input interrupts
      *FX 2, 2 enables RS423 input interrupts
      Note that to read or write bytes from the serial port you must use
      OSByte 138 to insert bytes into the output buffer and OSByte 145
      to get bytes from the input buffer, you cannot use *FX 2, 1 and
      *FX 3, 7 to redirect keyboard and screen activity to te port as 
      this only works with the built in serial interface.

   FX 7 (Set receive rate)
      Rates between 75 and 19200 baud are possible. This call returns
      with the X and Y register set to the old ULA contents (See *FX 242
      below). The default, set with *FX 7, 0 is 9600 baud.

   FX 8 (Set transmit rate)
      Rates between 75 and 19200 baud are possible. This call returns 
      with the X and Y register set to the old ULA contents (See *FX 242
      below). The default, set with *FX 8, 0 is 9600 baud.

   FX 156 (Read/write 6850 control register plus OS copy)
      This call writes to the control register of the 6850 chip and the
      OS copy. By consulting the 6850 data sheet, it is possible to im-
      plement serial standards other than the "8N1" default.
         The action of this OSByte is:
            (register) = ((oldregister) AND Y) EOR X

      returning with X = (oldregister) and A, Y preserved.

   FX 181 (Determine action on receiving escape/soft key)
      Unimplemented. No expansion of escape or soft keys occur.

   FX 191 (Read/write RS423 in use flag)
      This call tests whether the RS423 hardware is busy, returning with
      bit 7 set if it is free, bits 0 to 6 are undefined. Value 'busy'
      means that either transmit or receive interrupts are enabled,
      writes to this location are ignored.

   FX 191 (Read/write 6850 control register OS copy only)
      This call reads or writes the OS copy of the control register on
      the 6850 chip. Do not write to this location as it would make the
      copy inconsistent with the value in the chip.

   FX 203 (Read/write input buffer handshake ceiling)
      If the number of free bytes in the input buffer falls below the
      number held in this location the RTS line will go high to stop any
      further bytes being sent from the other computer.
         It contains 9 by default on soft and hard resets.

   FX 204 (Read/write serial suppression flag)
      Unimplemented. The second serial card RS423 input cannot be 
      suppressed.

   FX 205 (Read/write hardware use flag)
      This location contains &00 if the hardware is used in RS423 data
      mode &40 if the hardware is used in cassette mode. It will always
      contain 0 for the second serial card.

   FX 232 (Read/write IRQ mask)
      Unimplemented. The IRQ mask is always 255, and handled internally.

   FX 242 (Read/write serial ULA register OS copy only)
      This call reads or writes the second serial card's serial ULA. The
      byte is set out as %msrrrtttm where:
         m=motor relay state (always 0, there is no relay on the card)
         s=system select (always 1, the card is always in RS423 mode)
         rrr=receive baud rate (see table)
         ttt=transmit baud rate (see table)

      The baud rates read from the ULA are:
         %000 = 19200      %001 = 1200
         %100 =  9600      %101 =  300
         %010 =  4800      %011 = 150
         %110 =  2400      %111 =  75

     Do not write to this location as it would make the copy 
     inconsistent with the value in the ULA.