Archimedes Serial Port Application Note (Issue D) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Name: 0310052 Version: 0.02 History: 0.01: Undated : started. 0.02: 15-Feb-89: updated for release on SID Purpose ------- This application note is intended to assist the user in the use of the Archimedes serial port. It explains the relevant standards involved and how they apply to the Archimedes machine. Introduction ------------ The serial port electrical interface is generally based on the American EIA (Electronic Industries Association) standard RS 423. The interface functionality is based on the RS 232 standard. The RS 232 specification defines the interface between Data Terminal Equipment (DTE) and Data Communication Equipment (DCE) employing serial binary data. In the case of an Archimedes system using a modem, the computer is the DTE and the modem connected to the serial port is the DCE. When a serial printer is used, or another computer is connected to the Archimedes machine, both devices may appear as DTEs and the interconnections will be different. The RS 423 specification defines the electrical characteristics of an unbalanced digital interface circuit such as the Archimedes serial port. The RS 232 specification is very broad-based in scope, and defines the use of a 25-way connector with many connections between the DTE and DCE. In practice, many equipment manufacturers have found that only a small sub-set of these connections is necessary and connectors with far fewer pins have been used. Unfortunately, the selection of the sub-set is often arbitrary and there may be confusion over how to make the best use of the connections provided. Only two wires (plus ground) are actually needed, theoretically, to make a two-way serial data connection between the DTE and the DCE. The additional connections are primarily used to carry out 'hardware handshaking'. The 'handshaking' enables the two pieces of equipment to exert some direct control over each other to allow synchronisation of data flow. This synchronisation is necessary to avoid data loss. Increasingly, 'software handshaking' is used instead of 'hardware handshaking'. In this case, whilst data are transmitted along one data line, the other line is used to carry control information that allows the sender and the receiver to synchronise via software control at each end. Archimedes Serial Port ---------------------- The Archimedes serial port uses a 9-way connector (D-type plug) that is similar in function, but is not identical, to the 9-way port on the IBM PC/AT or derivatives. The same connecting lead can normally be used as that supplied for the PC/AT. The pin connections for the 9-way connector are as follows: Pin Function Voltage and Logic State 1 DCD Data Carry Detect +ve - On (Detected) 2 RXD Receive Data +ve - Logic "0" 3 TXD Transmit Data +ve - Logic "1" 4 DTR Data Terminal Ready +ve - On (Ready) 5 GND Ground Return (0V) 6 DSR Data Set Ready +ve - On (Ready) 7 RTS Request to Send +ve - On (Send) 8 CTS Clear to Send +ve - On (Clear) 9 RI Ringing Indicator +ve - On (Ringing) The Archimedes serial port applications include: Connection to another computer - DTE/DTE ---------------------------------------- In this case, both devices behave as DTEs and the RXD and TXD lines need to be transposed between the computers. Software handshaking will often be used, with some hardware control 'looped-back' locally: Connect pins 1, 4, and 6 (DCD, DTR, & DSR) together at each end Connect pin 2 (RXD) of the DTE (Archimedes machine) to TXD of the DCE (computer) Connect pin 3 (TXD) of the DTE (Archimedes machine) to RXD of the DCE (computer) Connect pin 5 (0V) of the DTE to 0V of the DCE Connect pin 7 (CTS) of computer A to pin 8 (RTS) of computer B Connect pin 8 (RTS) of computer A to pin 7 (CTS) of computer B Connection to a modem - DTE/DCE ------------------------------- In this case, the computer is the DTE and the modem is the DCE. The RXD and TXD lines are not transposed and the DCD, DTR, and DSR lines may be brought into use. The TXD, RXD, CTS, RTS, DCD, DTR, DSR, and 0V lines of one device are connected to the same pins on the other device. Note: In both of the above arrangements, the CTS line does not behave in quite the same way as for the existing Master Series or Model B computers. The CTS line on the Archimedes machine when disabled will cause an immediate cessation of data flow. For byte-oriented protocols, this may be undesirable as the last character may be corrupted. For applications where this is likely to be a problem, the DSR input should be used instead of CTS (i.e. the functions should be reversed). The DSR input, when disabled, allows completion of the current character. Connection to a serial printer ------------------------------ Both devices will typically be DTEs and some hardware handshaking may be needed. Connections will be similar to the 'computer-to-computer' method, but will vary between printer types. The printer manual should be consulted for guidance. Baud Rate, Parity and Start/Stop bit interval settings ------------------------------------------------------ For any transmission or reception to take place between serially connected equipment the transmit/receive rates must be set so that each end matches the other's expectations. The same requirement is generally true of parity setting and start-and-stop bit interval combinations. The Serial Controller chip within the Archimedes machine provides one internal timer for baud rate control. If the Receive and Transmit rates are programmed to be the same, then this timer is used for both. If different baud rates are needed for Transmit and Receive, then the internal timer is allocated to Transmit, and Receive is allocated a system timer. This system timer is not an exact multiple or sub-multiple of the internal timer. The use of different Receive and Transmit rates is therefore only recommended for lower speed usage, e.g. 1200/75 Viewdata. If only Receive is being used on the Archimedes machine, it is important to program Transmit to the same rate, even though not being used. This ensures that Arthur allocates the internal timer to Receive. Transmit and Receive rates can be set by *FX8,n (and *FX7,n respectively, if different Transmit and Receive rates are required), and set 'permanently' by *CONFIGURE BAUD. Parity setting and Start/Stop bit interval combination can be set by *FX156,n and set 'permanently' by *CONFIGURE DATA. Versions of ARTHUR ------------------ Early versions of Arthur, i.e. those prior to version 1.00, have a problem which can affect Received data. If it becomes necessary for Arthur to signal to a sender to stop sending data, due to a full buffer etc., then Arthur fails to re-enable the sender when the problem clears. A patch is supplied on the Welcome disk for machines supplied with Arthur version 0.3. Version 1.2 of Arthur also has a (different) problem, which is mainly circumvented by use of the RS423DRIVE patch, available on request from your supplier or from Acorn Computers Customer Services. Appendix 1 - Source of standards -------------------------------- Copies of the RS 232 and 423 standards may be purchased from the BSI in Milton Keynes, UK, or direct from the EIA in Washington DC, USA. There are related European and international standards as indicated below: RS 232 - Interface between data terminal equipment and data communication equipment employing serial binary data exchange RS 423 - Electrical characteristics of unbalanced voltage digital interface circuits CCITT V24 - Interchange circuits CCITT V28 - Electrical characteristics ISO 2110 - Pin connections for V24 circuits with V28 characteristics Appendix 2 - Settings of OS_Byte (*FX) 156 for the Archimedes machine --------------------------------------------------------------------- OS_Byte &9C (156) - Read/write asynchronous communications state On entry: R1 = 0 or new value R2 = 255 or 0 On exit: R1 = old value This call accesses the control byte of the RS 423 port. It acts in a similar fashion to the OS_Bytes in the range &A6-&FF, i.e. performs the operation: new value = (old value) AND R2 EOR R1 and returns the old value in R1. However, in addition to updating the status byte in RAM, it also updates the hardware register which controls the RS 423 characteristics. The call enables the current settings of the transmitter, receiver, interrupts and the RS 423 Request to Send (RTS) to be read or altered. When writing, the effect depends on the bits in R1: Bit 1 Bit 0 Effect 0 0 No effect 0 1 No effect 1 0 No effect 1 1 Reset transmit, receive, and control registers Bit 4 Bit 3 Bit 2 Word length Parity Stop bits 0 0 0 7 even 2 0 0 1 7 odd 2 0 1 0 7 even 1 0 1 1 7 odd 1 1 (see note 1) 0 0 8 none 2 (see note 2) 1 ( " " 3) 0 1 8 none 1 ( " " 4) 1 1 0 8 even 1 1 1 1 8 odd 1 note 1 - (*FX156,16) *CONFIGURE Data = 4 note 2 - default for the Archimedes machine and the Master 128 note 3 - (*FX156,17) *CONFIGURE Data = 5 note 4 - default for the Model B machine Bit 6 Bit 5 Transmission control 0 0 RTS low, transmit interrupt disabled 0 1 RTS low, transmit interrupt enabled 1 0 RTS high, transmit interrupt disabled 1 1 RTS at break level, transmit interrupt disabled Bit 7 Receive interrupt 0 Disabled 1 Enabled The default setting for bits 2-4 comes from the *CONFIGURE Data value, shifted left by two bits. The current value of this byte may be read (but not set) using OS_Byte &C0 (192). This information is subject to change without notice. No responsibility can be taken for any errors or omissions. The user or program writer should verify that any application program or connection is suitable for the intended environment(s). Further information on the use of the serial port is given in the Programmer's Reference Manual, available from your supplier.