EEE 410 - Microprocessors I: - Standard Parallel Port
EEE 410 - Microprocessors I: - Standard Parallel Port
EEE 410 - Microprocessors I: - Standard Parallel Port
¾ The Parallel Port is the most commonly used port for interfacing. This port will allow the
input of up to 9 bits or the output of 12 bits at any one given time, thus requiring
minimal external circuitry to implement many simpler tasks.
¾ It's found commonly on the back of your PC as a D-Type 25 Pin female connector.
Parallel Port’s are standardized under the IEEE 1284 standard first released in 1994.
This standard defines 5 modes of operation which are as follows,
¾
1. Compatibility Mode. (Centronics Mode)
2. Nibble Mode.
3. Byte Mode.
4. EPP Mode (Enhanced Parallel Port).
5. ECP Mode (Extended Capabilities Mode).
¾ Compatibility mode is also known as "Centronics Mode". In this mode you can only
output data.
¾ To receive/input data, you must change the mode to either Nibble or Byte mode.
Nibble mode can input a nibble (4 bits) from device to computer.
¾ Byte mode uses the Parallel's bi-directional feature (found only on some cards) to
input a byte (8 bits) of data.
¾ Extended and Enhanced Parallel Ports use additional hardware to generate and
manage handshaking.
¾ For example, to output a byte to a printer (or anything in that matter) using compatibility
mode, the software must,
¾ This limits the speed at which the port can run at. The EPP & ECP ports get around
this by letting the hardware check to see if the printer is busy and generate a strobe
and /or appropriate handshaking. This means only one I/O instruction need to be
performed, thus increasing the speed. These ports can output at around 1-2
1
megabytes per second. The ECP port also has the advantage of using DMA channels
and FIFO buffers, thus data can be shifted around without using I/O instructions.
• Port Addresses
The Parallel Port has three commonly used base addresses. LPT1 is normally assigned
base address 378h, while LPT2 is assigned 278h. 378h & 278h have always been
commonly used for Parallel Ports.
Notes:
Address
3BCH - 3BFH Used for Parallel Ports which were incorporated
on to Video Cards - Doesn't support ECP
addresses
378H - 37FH Usual Address For LPT 1
278H - 27FH Usual Address For LPT 2
Table 2 Port Addresses
• Hardware Properties
¾ Below is a table of the "Pin Outs" of the D-Type 25 Pin connector and the Centronics
34 Pin connector. The D-Type 25 pin connector is the most common connector found
on the Parallel Port of the computer, while the Centronics Connector is commonly
found on printers.
2
¾ The above table uses "n" in front of the signal name to denote that the signal is active
low. e.g. nError. If the printer has occurred error then this line is low.
¾ The "Hardware Inverted" means the signal is inverted by the Parallel card's hardware.
Such an example is the Busy line. If +5v (Logic 1) was applied to this pin and the status
register read, it would return back a 0 in Bit 7 of the Status Register.
¾ The output of the Parallel Port is normally TTL logic levels. The voltage levels are the
easy part. The current you can sink and source varies from port to port. Most Parallel
Ports can sink and source around 12mA. The best way is to use a buffer, so the least
current is drawn from the Parallel Port.
• Centronics?
¾ Centronics is an early standard for transferring data from a host to the printer. The
majority of printers use this handshake. This handshake is normally implemented using
a Standard Parallel Port under software control.
¾ Note 1 : If the Port is Bi-Directional then Read and Write Operations can be performed
on the Data Register.
¾ The base address, usually called the Data Port or Data Register is simply used for
outputting data on the Parallel Port's data lines (Pins 2-9). This register is normally a
write only port. If you read from the port, you should get the last byte sent. However if
your port is bi-directional, you can receive data on this address.
3
Offset Name Read/Write Bit No. Properties
Base + 1 Status Port/ Read Only Bit 7 Busy
Status Bit 6 Ack
Register Bit 5 Paper Out
Bit 4 Select In
Bit 3 Error
Bit 2 IRQ (Not)
Bit 1 Reserved
Reserved
Bit 0
Table 5 Status Port
¾ The Status Port (base address + 1) is a read only port. Any data written to this port will
be ignored. The Status Port is made up of 5 input lines (Pins 10,11,12,13 & 15), an IRQ
status register and two reserved bits.
¾ The Control Port (base address + 2) was intended as a write only port. When a
printer is attached to the Parallel Port, four "controls" are used. These are Strobe,
Auto Linefeed, Initialize and Select Printer, all of which are inverted except Initialize.
• Bi-directional Ports
¾ Bit 5 of the Control Port enables or disables the bi-directional function of the Parallel
Port. This is only available on true bi-directional ports. When this bit is set to one,
pins 2 to 9 go into high impedance state. Once in this state you can enter data on
these lines and retrieve it from the Data Port (base address). Any data which is
written to the data port will be stored but will not be available at the data pins. To
turn off bi-directional mode, set bit 5 of the Control Port to '0'.
¾ However not all ports behave in the same way. Other ports may require setting bit 6
of the Control Port to enable Bi-directional mode and setting of Bit 5 to dis-enable
Bi-directional mode, Different manufacturers implement their bi-directional ports in
different ways. If you wish to use your Bi-directional port to input data, test it with a
logic probe or multimeter first to make sure it is in bi-directional mode.
4
• Using The Parallel Port to Input 8 Bits.
If your Parallel Port doesn't support bi-directional mode, don't despair. You can
input a maximum of 9 bits at any one given time. To do this you can use the 5 input
lines of the Status Port and the 4 inputs (open collector) lines of the Control Port.
¾ In order to input 8-bit input data we input data both from status port and control port.
The high nibble of status port and low nibble of the control port are combined to
make an 8-bit input data.
¾ The Parallel Port's interrupt request is not used for printing under DOS or Windows.
Early versions of OS-2 used them, but don't anymore. Interrupts are good when
interfacing monitoring devices such as high temp alarms etc, where you don't know
when it is going to be activated. It's more efficient to have an interrupt request rather
than have the software poll the ports regularly to see if something has changed.
This is even more noticeable if you are using your computer for other tasks, such as
with a multitasking operating system.
¾ The Parallel Port's interrupt request is normally IRQ5 or IRQ7 but may be
something else if these are in use. It may also be possible that the interrupts are
totally disabled on the card, if the card was only used for printing.
¾ The Parallel Port interrupt can be disabled and enabled using bit 4 of the control
register, Enable IRQ Via Ack Line. Once enabled, an interrupt will occur upon a low
to high transition (rising edge) of the nACK. However like always, some cards may
trigger the interrupt on the high to low transition.
¾ You must program the programmable interrupt controller (PIC) at address 020H to
respond to the interrupt you are using and then place an Interrupt Service Routine
(ISR) at the appropriate Interrupt Vector.
5
• Programming of the Parallel Port
Ex1: Write required Assembly Language instructions to output 11111111B to the Data
Port of the SPP?
MOV DX,378H ;base address of SPP is 378H
MOV AL,11111111B ;Data Port is placed at [base address + 0]
OUT DX,AL
Ex2: Write required Assembly Language instructions to check if the Paper has run out
at the printer (paper out).
Bit 5 of the Status port indicates the status of paper at the Printer. So after inputting 8-
bit data from this port at [base address+1] we can check if paper is finished or not.
6
channels to move it's data about. It also uses a FIFO buffer for the sending and/or
receiving of data.
¾ Another feature of ECP is a real time data compression. It uses Run Length
Encoding (RLE) to achieve data compression ratio's up to 64:1. This comes is
useful with devices such as Scanners and Printers where a good part of the data is
long strings which are repetitive.
¾ The Extended Capabilities Port supports a method of channel addressing. This is
not intended to be used to daisy chain devices up but rather to address multiple
devices within one device. Such an example is many fax machines on the market
today which may contain a Parallel Port to interface it to your computer. The fax
machine can be split up into separate devices such as the scanner, modem/Fax
and printer, where each part can be addresses separately, even if the other devices
cannot accept data due to full buffers.
REFENENCE:
Read, http://www.beyondlogic.org/spp/parallel.htm ,for further details.
HOMEWORK: Write a subroutine to send a character to a printer using Standard Parallel
Port (SPP) communication. The subroutine will assume that the character is stored in AL.