Chapter 13 Parallel Communication

Table of Contents
13.1 Printer Adapter Hardware
13.2 BIOS and DOS Function Calls
13.3 Machine Language Control of Printer Adapter
13.4 Use of the Printer Adapter for Data Input

13.1 Printer Adapter Hardware

The parallel interface provides the signals and hardware to transfer data one character at a time (8 bits in parallel) between the CPU and a device, usually a printer. The signals consist of 8 data lines and 9 handshaking (status and control) lines. The hardware (latches and buffers for the data, status and control signals, and logic to connect them to the internal data bus and to address them as I/O ports via the address bus) is located on a printer adapter card that plugs into an I/O slot. The signals to and from the printer, shown in Table 13-1, are available on a 25-pin female D-shell connector on the printer adapter. Up to 3 printer adapters may be installed; the addresses available for the data, status, and control ports of an adapter are shown in Table 13-2. BIOS determines (during the restart initialization) which addresses have printer adapters installed; DX = 0 to 2 is then used within BIOS to refer to the printer adapters that were found to be present.

Table 13-1. Signals on 25-pin Printer Connector (pin numbers)

Data Signals [to device] Status Signals [from device] Control Signals [to device]
Data 0-7 (2-9) ~Acknowledge (10) ~Strobe (1)
Ground (18-25) Busy (11) ~Auto Feed (14)
  Out of Paper (12) ~Initialize (16)
  Selected (13) ~Select (17)
  ~Error (15)  

Table 13-2. I/O Port Addresses (in hexadecimal) for Printer Adapter Buffer Registers

  Data Port Status Port Control Port
Monochrome Display / Printer Adapter 03BC 03BD 03BE
Primary Adapter 0378 0379 037A
Secondary Adapter 0278 0279 027A

The printer is assumed to use the "Centronics" protocol, shown in Figure 13-1. The printer sets BUSY high while it is processing a character; BUSY may also be high because the printer is disconnected, off-line, or in an error state.

Figure 13-1. Timing Diagram for the Centronics Protocol

In the polled mode of printing, the character bits are put on the DATA lines, BUSY is tested repeatedly until it is found to be low, then the ~STROBE pulse is sent. The printer sets BUSY high when the character data have been latched and sets it low again when the character has been processed. (The Centronics protocol specifies that the DATA lines be stable from at least 500 ns before to at least 500 ns after the ~STROBE pulse, and the ~STROBE pulse be at least 500 ns long. These times may of course be shortened for a specific printer, at the risk of loss of generality.) Programs using the polled mode should include a "timeout" counter to guard against a permanent BUSY condition. BIOS calls and DOS functions use this mode for printing.

In the interrupt-driven mode of printing, the positive-going edge of the ~ACKNOWLEDGE signal is used to cause an interrupt 0Fh via the IRQ7 line to the Interrupt Controller; the Interrupt Handler can send a new character to the printer whenever it is invoked, since ACKNOWLEDGE indicates that the previous character has been processed. The DOS command PRINT uses this mode to spool and print files.