10-1. The Centronics Printer Interface
The Centronics printer interface allows data to be transmitted to a printer 8 bits at a time. Since the computer can output up to 150 kilobytes/second, the printer needs some way to say "Wait!" it does this by pulling the BUSY line high as described previously. In addition, there is a second two-way handshake in the Centronics standard. When the computer sends a byte of data to the printer, it also sends a pulse down the STROBE line. This tells the printer, "Hey, I've got another byte of data here for you." When the printer has read the data byte and is ready to accept another, it acknowledges that fact by sending back a pulse on the ACKNLG line. This tells the computer, "OK, I've read what you sent. This is a classic example of a two-way handshake. The first device says, "Here's some data," and the second device replies, "I've got it." Figure 10-1 is a timing diagram that shows the relationship of the various handshake signals.
The IBM PC typically uses the BUSY line for handshaking in a polled mode. Polling means that the computer hangs in a little loop, testing the line until the desired condition occurs. Thus a polling loop for the BUSY line would be
mov dx,status hang: in al,dx test al,80H jz hang
The ROM BIOS routine for the parallel printer port on IBM's parallel printer adapter (or the equivalent port on the monochrome adapter) works as follows: When a character is to be sent to the printer, the output routine sends the desired character to the data port (port address 3BCH on the monochrome display and printer adapter), where it's latched and held. The routine then polls the BUSY line (bit 7 of port 3BDH) until it goes low. Because such a loop could hang up forever on a nonexistent printer, the polling loop contains a countdown lasting about 16 seconds, which returns an error value if the BUSY line never goes low. This countdown has the disadvantage that it can time-out when you pause the printer (for example, to adjust the paper), leading to loss of characters. We use our own printer driver routine (see below), which can be interrupted by typing a control C, and therefore we don't need a timeout.
As soon as the BUSY line goes low, the PC's ROM BIOS routine pulses the STROBE line low (bit 0 of port 3BEH), telling the printer that a new byte is ready, and then the routine returns. Here as elsewhere on the I BM version of the printer interface, the high/low value of the BUSY and STROBE lines are inverted in the printer adapter registers. Hence the output routine looks for a 1 bit (bit 7 = 1 of 3BDH) to detect a low BUSY line value, and sets a bit high (bit O of 3BEH) momentarily to pulse the STROBE line low.
The ACKNLG handshake line is ideally suited to an interrupt-driven output routine. If printer interrupts on the 8259A interrupt controller's IR7
line are enabled (bit 4 = 1 on port 3BEH of the printer adapter and bit 7 = O in the 8259A's interrupt mask register), the inverted value of the ACKNLG line is gated onto the l/O channel's IR7 line. Since the 8259A is programmed to produce an interrupt on a rising edge, the ACKNLG line can cause an interrupt. For this approach, characters are typically stored in a FIFO buffer until a printer-acknowledge interrupt indicates that another character can be transmitted. This output buffering technique is one kind of "print spooling." This capability is built into the PRINT command of DOS 2.0, and is also available for DOS 1.1 from a number of the multifunction-board suppliers for the I BM PC (for example, AST Research). The ROM BIOS printer routine (the default INT 17H) can handle up to four parallel printers. The 16-bit port addresses for the corresponding printer adapters are stored in locations 40:840:0F and the number (0,1, 2 or 3) of the desired adapter is passed to INT 17H in the DX register. For printer 0, which is driven by the monochrome display and printer adapter, the port numbers given above are valid, but other adapters use different addresses. The IBM PC BIOS routine is given in the IBM PC Technical Reference manual. A simpler Centronics routine able to handle a single printer adapter goes as follows:
cenout: push dx ;CENtronics OUTput routine mov dx,data ;Point at data output port out dx,al ;Output character to data latch inc dx ;Point dx at status port (data+1 ) waitbs: mov ah,1 ;Keyboard character typed? int 16H jz waitb2 cmp al,3 ;Yes. eC? jz cenret waitb2: in al,dx ;Wait for BUSY line to go low test al,80H jz waitbs ;(BUSY low if bit 7 = 1 in status port) inc dx ;Point at control port (data+2) mov al,Odh ;Pulse STROBE low: Set bit O = 1 out dx,al ; to pull STROBE low mov al,Och out dx,al ;Bring it back high cenret: pop dx ret
To be compatible with the IBM PC conventions, the routine should load the appropriate port address into DX using the input value of DX and the port address locations at 40:8OF, and should return the status byte in AH.
Figure 10-2 summarizes the lines used for the IBM PC 25-pin Centronics interface. The standard Centronics convention uses a 36-pin connector, so IBM's pin numbers are nonstandard. Note that in addition to the BUSY, ACKNLG, DATA, STROBE, and ground lines, there are lines for PAPER END, SELECT, AUTO FEED, ERROR, INITIALIZE PRINTER, and SELECT INPUT. The SELECT IN PUT line must be low in order for the printer to be selected. Thus by using individual SELECT INPUT lines for each of several printers, you could use the same interface to drive a number of printers, all sharing the same handshake and data lines. This idea is carried out in great generality in the IEEE 488 bus interface discussed in Sec. 10-7.
|Driven by||Signal Name||Cent
|1||Host||/Strobe||1||Tells the printer that data is available on Data 0-7. Pulse width must be more than 0.5us. Must be high if Busy or /Acknowledge are also high.|
|2||Host||Data 0||2||Data lines must be valid 0.5us before falling edge of Strobe signal|
|10||Printer||/Acknowledge||10||Pulse width approx 3us. Asserted when Busy goes off or after data is accepted.|
|12||Printer||Out of Paper||12|
Now let's see how the interface is implemented on the IBM PC, and how it might be useful for other l/O purposes. The output byte on the IBM adapters is latched by a 74LS374, which can both source and sink current, and hence should not be driven externally. The output byte can also be read through a 74LS244 input buffer. If the 74LS374's tristate output enable pin had been connected to the extra bit on the adapter's command port (a 6-bit 74LS174 latch), the data port could have been programmed for external input as well as output, making the port substantially more useful. Five bits of the 74LS174 are used for command lines, one being the interrupt enable line and the other four being buffered through open-collector (three inverting) drivers onto the Centronics interface cable. Since these four Iines are readable and as open collectors can be driven externally, they can be used for input as well as output lines. Together with the four standard input lines, this makes a total of eight lines that can be used for input in non-Centronics applications. Alternatively you can have twelve output lines and four input lines.
The port would have been useful for more than a printer interface if a smart port such as an 8255 had been used, and buffered by bidirectional 74LS245 drivers. Then files could be transferred between two computers at high data rates. It seems unfortunate that the Centronics convention is typically so unidirectional in character, since systems often end up with serial interfaces that are not particularly useful for anything but printers with limited handshakes. One exception is the Victor 9000 implementation, which can be used bidirectionally and can be programmed to be an IEEE 488 port as well as a Centronics printer port.
|file: /Techref/io/parallel/pcios10.htm, 11KB, , updated: 2001/12/20 22:48, local time: 2018/11/19 17:09,
|©2018 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://techref.massmind.org/techref/io/parallel/pcios10.htm"> io parallel pcios10</A>
|Did you find what you needed?|
Welcome to massmind.org!
Welcome to techref.massmind.org!