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 rewuire 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)
   *FX 8,4          (sets transmit speed of the 2nd port to 1200)

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
v0.69 Altered INVS code. Previously, if the input and output buffers were far apart, the outgoing bytes could end up being put in the incoming buffer
v0.72 Added handler to listen for buffer, flushing OBSytes too.

Buffer Flushing

The two OSByte commands to flush buffers will work regardless of the setting of the *COM1 or *COM2 switch. So:

   *FX 15,0 ... will flush all buffers, including the second serial
                card's
   *FX 15,1 ... will flush the current input buffer
   *FX 21,n ... will flush buffer n, including the second serial card's
                in the case of n=9 or n=10
Any of the other OSBytes listed below must be preceded by a *COM2 for them to have any effect on the second serial card.

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)
     Choosing *FX2,0 disables RS423 input interrupts
     Choosing *FX2,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 *FX2,1 and *FX3,7
     to redirect keyboard and screen activity to the port as this only
     works with the built in serial interface.

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

   FX 8 (set transmit rate)
     Rates between 75 and 19200 baud are possible. The call returns with
     the X and Y register set to the old ULA contents (see *FX242
     below). The default, set with *FX8,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 
     implement 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 192 (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 hardware is used in RS423 data mode.
                            &40 if 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 %msrrrttt
     Where m=motor relay state (always 0, 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.