Parallel Port
Parallel Port
INTERFACING
PART#1
By
MUEEN SAJJAD
General Types of Digital Data
Communication
1. Parallel
2. Serial
Parallel
Parallel communication requires as much wires as the no. of
bits in a word for its transmission. Word may be a
combination of 4,8,16,32 or 64 bits etc.
Serial
serial communication usually requires a minimum of 2 wires
for data transmission in one direction. One wire is for data
and other is for ground.
Parallel port identification on
IBM PC
• Usually ports are found on the rear of computer
and are of the following two types;
1) Male ports
having pins coming out of port.
2) Female ports
having holes for pins.
• Parallel port is generally a 25 pin female
connector with which a printer is usually
attached.
Pin configuration of parallel
port.
Grouping Of Parallel Port Pins
i. Data port Address Bit no. Pin Pin
ii. Status port Name Number
Base +0 7 Data 7 Pin 9
iii. Control port (e.g.
0×378) 6 Data 6 Pin 8
Data port: 5 Data 5 Pin 7
• It includes pin 2 to pin 9
with pin names Data-0 to 4 Data 4 Pin 6
Data- 9 3 Data 3 Pin 5
• It is usually for data
output according to old 2 Data 2 Pin 4
“standard parallel port”
1 Data 1 Pin 3
standard.
0 Data 0 Pin 2
ii. Status Port Address Bit Pin Name Pin Number
Status port is an no.
Base +1 7 Busy Pin 11 (hardware
input only port (eg 0×379) inverted)
i.e. Data can’t be 6 Ack Pin 10
output on this
5 Paper Out Pin 12
port but it can
only be read.
4 Select Pin 13
3 Error Pin 15
2 Irq -
1 Reserved -
0 Reserved -
Address Bit Pin Name Pin Number
iii. Control port no.
Base +2 7 Unused -
Control port is a (eg 0×37A
read / write port. or 37AH) 6 Unused -
For printer purposes
5 Enable bi- -
it is write only port. directional
0 strobe Pin 1
(Hardware
Inverted)
How to access parallel port pins in the software.
Parallel port is assigned a unique I/O address which is
generally among the following:
i) 378h (mostly the case)
ii) 278h (normally found when there are more than
one parallel ports)
iii)3BCh (Rare case)
Schematics of circuit
The Software Controlling part
#include<stdio.h>
void main(void)
{
outportb(0x378,0x01); //turn on the bulb
getch(); //wait for any key to be pressed
outportb(0x378,0x00); //turn off the bulb
getch(); // wait for a key to be Pressed
}
C program to control ON/OFF Through keyboard
• You should connect an external resistor with pin to get logic high voltage
ADVANCED TECHNIQUES IN
PARALLEL PORT
INTERFACING
Introduction to Bi-directional Parallel Port
• These days starting from PC’s equipped with Pentium processors, the parallel
ports have Bi-directional read/write facility.
• Bi-directional means that you can read byte (8 bits) from parallel port which
traditionally was an output only port in the old PC’s.
• In order to check whether your port is configured for it, restart your PC and go
into BIOS see the portion related to the parts. You will find port address as
well as its type, usually the options are as follows
All above signaling, was done by software in which PC had to wait for a response
from printer before outputting the next signal. It was a slow process with data rate
of 50KB/sec to 150KB/sec.
Introduction to EPP (Enhanced Parallel Port) handshake
EPP was designed to do, the above described, handshaking by a separate hardware
chip instead of main processor. It is described as follows:
EPP Data Write Cycle:
The only port to be done in software is to write the Byte to be sent at Data port (EPP) whose
address is (base address+4) {eg.0x37C}
Note: this data port is different from the data port of SPP. However you can still use that
data port of SPP by usual way.
All above signals are generated automatically in hardware.
Description of handshake given on Last slide
The software programs writes the byte to be sent at EPP data register
i) I)
(Base +4)
ii) Write is placed low by PC to indicate the printer that some data is to be sent.
iii) After placing the Write low, data is placed on data lines (pin 2 to pin 9)
iv) Wait pin is checked. It is an input from the printer. If it is low then it means
that printer is waiting for receiving data from PC. This being the case, the
PC pulls DATA STROBE low to indicate the printer that it should read data
from data line.
v) The printer reads data from Data lines and brings the WAIT line high fir a
short duration. This indicates to the PC that printer has received data, so it is
Ok to end EPP data write cycle.
vi) DATA STROBE is brought high. WRITE is also brought high.
vii) EPP write cycle Ends here.
EPP Address Read Cycle
Description of Handshake used for EPP Address Read Cycle.
a. The printer informs the PC that it has to send some data to PC by sending
signal on interrupt line (pin 10, ACK in SPP). This Depends upon software.
Any other input line may be used as well for this signaling.
b. Whenever pc is free, it responds to this signal and reads EPP address register
(Base+3).
c. ADDR STROBE is pulled low if Wait is low. This is done automatically
when processor reads the Address Register. This signals informs the printer
that host (PC) is ready to start an EPP read cycle.
d. Host waits for acknowledgement from Printer by waiting for WAIT line going
high.
e. As Wait line goes high, data is read from data liens (pin 2 to 9)
f. Addr Strobe is pulled high. This ends EPP read cycle.
Time-out indication in EPP
There is a possibility that host (PC) starts a write cycle but never receives
acknowledgement from printer when no printer is attatched. As this
operation is done in hardware so the PC will continue waiting & your
computer will halt. In order to avoid this a Watchdog timer scheme is
used it is described as follows.
i) When host writes data to address/Data port of the EPP, a timer is
started at the same time.
ii) Now host waits for an acknowledgement on WAIT line becoming
high. If it does not happen within about 10μsec, (depending on port),
then a time out is indicated by setting Bit0 of status port (base+1).
iii) The host stops waiting and informs the user about the problem.
How to setup port for Programming using EPP features
Before you can start any EPP cycle by reading/writing to EPP data and address
port, the port must be configured correctly.
In idle state, an EPP port should have its Address Strobe, Data strobe, wait and
reset lines high. So it is better to initiate these lines manually by writing
xxxx0100 to control port(base+2).
For details please consult the document “Interfacing The Enhanced Parallel
Port” found in Pdf form on “www.beyondlogic.org”.
Here you will find most of the details about interfacing SPP, EPP and ECP
with software example as well.
A brief introduction to ECP
(Extended Capability Port)
Enhancements in ECP
ECP supports SPP and EPP features. In addition it has following enhancements.
i) It can use DMA (direct memory access) feature in order to transfer a block of data from memory
automatically without the use of CPU.
ii) It can use (first in first out) FIFO buffers to transfer more than one byte automatically before the
attention of CPU is required.
iii) It supports data compression by using RLE (Run Length Encoding) scheme. This scheme helps
to transmit a single byte if a long string of this same byte is required to be transmitted.
iv) It supports a method of channel addressing by which you can communicate with different
modules of the target. For example with Fax, copier and printer in a single machine
containing these 3.
For details about ECP and its programming details please consult the document:
“Interfacing The Enhanced Parallel Port” found in pdf form on ‘www.beyondlogic.org”.
Here you will find most of the details about interfacing SPP, EPP and ECP with software example
as well.