home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
printer
< prev
next >
Wrap
Text File
|
1990-01-05
|
6KB
|
130 lines
Chapter 9
Printer I/O Services
--------------------
1. Parallel Printer Interface
The Personal Computer may be connected to a printer with a standard
parallel interface. The signals of the parallel printer interface are
shown in Table 1-1.
Table 1-1. Parallel Printer Interface
┌────────────────────────┬───────────────┬────────────────────────────┐
│ Signal Name │ Direction │ Adapter Connector Pin No. │
├────────────────────────┼───────────────┼────────────────────────────┤
│ Data Bit 0 - 7 │ To Printer │ 2 - 9 │
│ Strobe # │ To Printer │ 1 │
│ Select Input # │ To Printer │ 13 │
│ Auto Feed # │ To Printer │ 14 │
│ Initialize Printer # │ To Printer │ 16 │
│ Acknowledge # │ To Computer │ 10 │
│ Busy │ To Computer │ 11 │
│ Out of Paper │ To Computer │ 12 │
│ Select │ To Computer │ 13 │
│ Error # │ To Computer │ 15 │
└────────────────────────┴───────────────┴────────────────────────────┘
The operation of the parallel interface is quit simple. The printer
will not accept any input unless the Select Input # line is in the
proper state.
The Initialize Printer # line is used to initialize the printer. The
correct signal must be on the line for at least 50 us.
The data to be printed is placed on the eight Data-Bit lines. Then the
Strobe # line is pulsed for 1 us to 5 us. The printer processes the
data and then sends a pulse back on the Acknowledge # line. When the
acknowledge pulse is received by the computer, another character may be
sent to the printer. Instead of waiting for the acknowledge pulse, the
computer may check the Busy line. The computer may send characters to
the printer as long as the printer is not busy.
The Out of Paper line tells the computer that the printer is out of
paper. The Select line tells the computer that the printer is on line.
The Error # line tells the computer that the printer is off line, out
of paper, or in another error state. The busy status also reflects
these error conditions.
2. Printer I/O Ports
control signals on base I/O address +2
status signals on base I/O address +1
data signals at base I/O address
port 278h-27fh -- parallel printer port 2
port 378h-37fh -- parallel printer port 1
port 3bch-3bfh -- parallel printer port 0
controll:
bit 7 -- not used
bit 6 -- not used
bit 5 -- not used
bit 4 -- +IRQ enable (interrupt on -ACK true to false)
bit 3 -- +SLCT IN (true for printer select)
bit 2 -- -INIT (minimum 50 microsecond true to false pulse)
bit 1 -- +AUTO FEED(true makes printer line feed after carriage return)
bit 0 -- +SRTOBE (1/2 microsecond minimum false to true pulse)
status:
bit 7 -- -BUSY (true indicates printer may not accept data)
bit 6 -- -ACK (false indicates printer ready to accept another byte)
bit 5 -- +PE (true indicateds paper out conditions)
bit 4 -- +SLCT (true means printer selected)
bit 3 -- -ERROR (false means error condition detected)
bit 2 -- INT_STA (if intterrupt enable,'acknowledge' will set this bit)
bit 1 -- not used
bit 0 -- not used
note:
ACK - acknowledge
INIT - initialize
PE - paper end
SLCT - select
INT_STA - interrupt status
3. BIOS Printer I/O Services
The BIOS Printer I/O services send characters to the printers,
initialize them, and return the status of the printer ports.
All functions require a printer number in DX (0 through 3). This
printer number indexes a table in BIOS data area which contains the
port base addresses for each of the four corresponding printers.
The power-on self test routine determines whether a printer adapter is
active at ports 3BCh, 378h, and 278h, and if it detects an installed
adapter it stores its port address in the table.
All three printer I/O functions return a status byte in AH. The least
significant bit is supplied by the Print Character function to signal a
timeout error: the printer will not be ready after the character was
outputted, and the timeout count expired. All three functions are
listed as follows:
function:
ah = 0h Printer character
ah = 1h Initialize printer port
ah = 2h Read the printer status into ah
ah = 3h - 0ffh reserved
input:
ah - function number
dx - device number (0 - 2)
output:
ah - status
bit 0 = 1 -- timeout
bit 1 -- not used
bit 2 -- not used
bit 3 = 1 -- I/O error
bit 4 = 1 -- printer selected
bit 5 = 1 -- out of paper
bit 6 = 1 -- acknowledge
bit 7 = 1 -- not busy