RisControl logo

  RisControl>>Printer port


     RisControl | Printer port


Stuart Tyrrell's parallel port info sheet for RISC OS machines
Many years ago, Stuart Tyrrell (of A6 and A9home fame) very helpfully put together a comprehensive guide to connecting to and programming the parallel port under RISC OS and made the guide available for all to use. The original link that the document was available from seems to be dead these days, so I've reproduced it here to ensure anyone who uses the parallel port for control purposes still has a version they can refer to - including me, as I can never seem to find my own copy when I need it.

================================================================================

 
 
    Title : Parallel Port access on Acorn machines
   Author : Stuart Tyrrell
  Version : 0.03
     Date : 28/04/96
Copyright : (c) Stuart Tyrrell 1994/1995/1996
    Email : stuart@stdevel.demon.co.uk
 
Here's a document I wrote some time back in response to questions about
parallel port access - It may be useful to someone, so I'm making it
available. This isn't a FAQ, and isn't likely to expand to a "hackers
guide to Acorn hardware" at any point in the future (or is it?) ;-)
but I'll try to keep it updated whenever I get time.
 
Copyright remains mine, but I give permission for this document to be
distributed by whatever means possible.
 
A background to parallel ports
------------------------------
 
The pinout of the standard Parallel port on Acorn machines is as follows :
 
Pin     Name            In/Out 
---     ----            ------
1       /STB            Out
2       D0              Out (+In)
3       D1              Out (+In)
4       D2              Out (+In)
5       D3              Out (+In)
6       D4              Out (+In)
7       D5              Out (+In)
8       D6              Out (+In)
9       D7              Out (+In)
10      /ACK            In
11      BSY             In
12      PE              (In)
13      SLCT            (In)
14      /AUTOFD         (Out)
15      /ERROR          (In)
16      /INIT           (Out)
17      /SLCTIN         (Out)
18-25   0V
 
Notes :
* Labels in brackets are only applicable to newer machines.
* Note labelling conventions of pins 13&17 are respect to printer, rather
  than computer.
 
The parallel port of most machines is primarily designed for the control of
printers. Data is transferred by means of an 8 bit data output from the
computer. This data is latched into the printer's buffer by means of the *STB
(*Strobe) signal. The printer then acknowledges "receipt" of this byte by
pulsing the *ACK (*Acknowledge) signal. If the printer is unable to accept
any further data, (for example if the printer's buffer is full), the BSY
(Busy) signal is asserted. Under this condition, no further *STB pulses are
send from the computer until the BSY signal is de-asserted.
 
If we consider (slow!) printer with a two byte buffer and we want to send
"ABCD", the following could occur :
 
             ______   ______   ______________   ______
 Data(7:0) -<_A____>-<_B____>-<_C____________>-<_D____>--
           __   ______   ______________   ______   ______
 *STB        |_|      |_|              |_|      |_|
           ______   ______   ______________   ______   __
 *ACK            |_|      |_|              |_|      |_|
                 __        ___________     __       __
 BSY       _____|  |______|           |___|  |_____|  |___
 
 (Note)      1    2            3      4
 
Notes :
 
1) The computer presents the data on the data lines, and pulses *STB.
2) The printer inserts the character into the printer buffer, and pulses *ACK
to indicate that it has done so. Note that BSY may or may not be asserted
during this time (this is printer dependant)
3) Here the printer buffer is full. The printer has asserted BSY to inform
the computer that it cannot accept any more characters.
4) The buffer has emptied (the printer has finally printed a character?), BSY
is de-asserted, and the cycle can continue as normal.
 
Note there are some timing restrictions (eg *STB pulse >0.5us). Full details
are in the centronics specifications.
 
Often the basic parallel interface was extended by the addition of a number
of other I/O lines, namely :
 
PE (Paper Empty) [In] - driven high by printer when paper out.
SLCT (Select) [In] - high when printer on-line, low when off-line.
*ERROR [In] - low when error occurs (eg print head overheat). Often SLCT.
*SLCTIN (Select In) [Out] - turns printer on line (low) or off-line (high).
*INIT (Initialise / Prime) [Out] - Low to initialise (reset) printer.
*AUTOFD (Auto Feed) - Low causes LF (chr.10) to also CR (chr.13)
 
In addition, many parallel ports now support bi-directional data flow on the
data lines.
 
 
General
-------
 
There are currently two implementations of the parallel port on Acorn
machines. The first comprises of discrete logic gates (generally a 74x374
latch for data output, a transistor for *STROBE and buffers for *ACK and
BSY). These machines implement the simplest form of the parallel port, above.
The second uses a 710/711 type device, and implements a full bi-directional
parallel port, including the extra signals such as *SLCTIN.
 
"Latch" machines : A300, A305, A310, A410, A440, A410/1, A440/1, A500, A540,
R140, R260, A3000 etc.
 
"711" machines : A5000, A3010, A3020, A4000, Risc PC.
 
 
"Latch" operation
-----------------
 
* Printer Data
 
The data latch is a write only location at &3350010. Writing to this location
immediately presents the data on the Data(7:0) pins.
 
Printer Data Latch (&3350010) :
 +--7--+--6--+--5--+--4--+--3--+--2--+--1--+--0--+
 |Data7|Data6|Data5|Data4|Data3|Data2|Data1|Data0|
 +-----+-----+-----+-----+-----+-----+-----+-----+
Data7....Data0 : Data to be written to port.
 
 
* Strobe Signal
 
The printer strobe is part of External Latch B. Again this is a write only
latch - there is no easily accessible RAM copy, so should be used with
caution!
 
External Latch B (&3350018) :
 +--7--+--6--+--5--+--4--+--3--+--2--+--1--+--0--+
 | HS3 | AUX2| AUX1|  PS | FDCR| CD2 | CD1 | CD0 |
 +-----+-----+-----+-----+-----+-----+-----+-----+
HS3 : Not used.
AUX2..AUX1 : Not used normally - Program High.
PS : Printer Strobe. High = output high.
FDCR : Floppy disk controller reset. Program high
CD2..CD0 : should be programmed low.
 
 
* Reading BSY
 
BSY can be read from IRQ status A (Read only) :
 
IRQ Status A (&3200010)
 +--7--+--6--+--5--+--4--+--3--+--2--+--1--+--0--+
 |  1  | TM1 | TM0 | POR | VFLY| PACK| RII | PBSY|
 +-----+-----+-----+-----+-----+-----+-----+-----+
PBSY : Printer busy input.
Note : PACK shows whether a printer acknowledge interrupt has been noted.
This is not generally reliable for reading *ACK, especially with interrupts
disabled. See method below.
 
 
* Reading *ACK
 
*ACK can be read from the Control Port. Although this port is read/write, we
are only interested in reading it.
 
Control Port (&3200000)
 +--7--+--6--+--5--+--4--+--3--+--2--+--1--+--0--+
 | VFLY| PACK|SMUTE|  -  |  -  | FDR | SCL | SDA |
 +-----+-----+-----+-----+-----+-----+-----+-----+
PACK : Status of acknowledge pin.
 
 
"711" Operation
---------------
 
Full documentation of the parallel device driver may be found in the
Risc OS 3 PRM's, pages 2-477 to 2-484.
 
The "711" device has three registers which may be accessed - the data
register, which holds the data which either appears or is read from
Data(0:7); The status register (read only) which shows the status of the
other input pins, and the control register which sets the outputs of pins
other than the data pins, and also the direction of data transfer etc.
 
The registers may be accessed using Parallel_Op :
 
Parallel_Op with R0=0 reads the Data and status registers.
In :
R0=0
Out :
R0=0
R1 = contents of data register
R2 = contents of status register
 
With R0=1, the data register is written :
In :
R0=1
R1=data
Out :
R0,R1 preserved
 
With R0=2, the control register is read/written :
In :
R0=2
R1=EOR Mask
R2=AND mask
Out :
R0=2
R1=old contents of control reg.
R2=new contents of control reg.
 
 
The address of the "711" device in the memory map may be found using
Parallel_HardwareAddress. R0 returns the base address of the 711 (&30109E0).
 
Note that all current "711" based machines have a base address of &30109E0.
This is not guaranteed for future machines, neither is the operation of
Parallel_HardwareAddress (indeed its use has changed between Risc OS 3.00 and
3.10). You are "strongly" urged to use the Parallel_Op SWI's - the addresses
are given here for information only.
 
"711" Data Register (&30109E0) :
 +--7--+--6--+--5--+--4--+--3--+--2--+--1--+--0--+
 |Data7|Data6|Data5|Data4|Data3|Data2|Data1|Data0|
 +-----+-----+-----+-----+-----+-----+-----+-----+
Data7....Data0 : Data to be written to port.
 
"711" Status Register (&30109E4) :
 +--7--+--6--+--5--+--4--+--3--+--2--+--1--+--0--+
 |*BUSY| *ACK|  PE | SLCT|*ERR |  -  |  -  |  -  |
 +-----+-----+-----+-----+-----+-----+-----+-----+
 
*BUSY : NOT(Status of Busy pin). (note inverted compared to latch machines)
*ACK : Status of *ACK pin
PE : Status of PE Pin
SLCT : Status of SLCT Pin
*ERR : Status of *ERROR pin.
 
"711" Control Register (&30109E8) :
 +--7--+--6--+--5--+--4--+--3--+--2--+--1--+--0--+
 |  -  |  -  | DIR |IRQEN|*STIN|*INIT|*AUTO| *STB|
 +-----+-----+-----+-----+-----+-----+-----+-----+
DIR : Direction of data (0=out)
IRQEN : Do ack's etc generate IRQ's normally set at 1=yes, and disable IRQ
        with the IOC.
*STIN : Status of *SELECTIN output
*INIT : Status if *INIT output
*AUTO : Status of *AUTOFD output
*STB : Status of *STB output.
 
 
Determining which machine is used
---------------------------------
 
There are in fact three different methods of accessing the parallel port. On
older machines, the harware must be accessed directly, no matter which
version of RISC OS is used. On newer machines, the Parallel_Op SWI is
available, but this is unavailable on RISC OS 3.00, so direct hardware access
must be made under RISC OS 3.00, and either direct access or use of
Parallel_Op may be made under later versions.
 
One pseudo-code method of determining which machine is running is shown
below. The routine returns a number 2,3 or 4. An old machine returns the
value 2. An A5000 running RISC OS 3.00 returns 3 (and so direct access to a
"711" device should be used), and a late machine running RISC OS 3.10 or
later returns 4 (so Parallel_Op should be used in preference to direct
access).
 
--------------------------------------------------------------------------
Call OS_Module with R1=0 to find the address of the utility module (returned
in R3)
 
Get offset to title from R3+16.
 
Read the string at R3+[R3+16], until we get to the version number (after the
tabs). If it starts with "2" then we're on RISC OS 2.00; return 2, else....
 
Call OS_ReadSysInfo with R0=2 (determine chip presence). If R1 indicates no
"711" (=0) then we're on an old machine. Exit with return of 2, else....
 
Call OS_ReadSysInfo with R0=3. This call is invalid under RISC OS 3.00, so
if V = set then return with 3, otherwise return with 4.
--------------------------------------------------------------------------
 
Of course there are many ways of determining which machine is being used. For
example, if direct access is being used, then the final step is unneccesary.
 
 
Document Versions
-----------------
 
V0.01 (11/12/94)        Initial release in response to requests for data
                        about direct parallel port access.
       
V0.02 (17/04/95)        Addition of port pinout. Removal of non-distribution
                        notices, general release.
                       
V0.03 (28/04/96)        Change of email address.
 
Any suggestions for amendments/improvements/spelling mistakes etc to
stuart@stdevel.demon.co.uk please.
 
Acknowledgements
----------------
 
Obviously a proportion of this documentation has been "stolen" from
some other sources, eg printer manuals, Programmers Reference Manuals
etc, and it even includes some original text! Many thanks to those
people whose work I've obviously used.
 

================================================================================



<< RisControl
All content on this website is Neil Fazakerley or its originators