INTRODUCTION TO PARALLEL PORT INTERFACING This tutorial is taken from the book
MY EXPERIENCE IN PARALLEL PORT INTERFACING.
you can download it free from the files
section(file:-parallelport(3 files) of
yahoo group-booksbybibinhttp://groups.yahoo.com/group/booksbybibin/
comments about this book on
www.booksbybibin.blogspot.comINTRODUCTION
Parallel Port interfacing is thesimplest method of
interfacing. So it is widely used. The main problem with parallel port interfacing is
that it has data transfer speed upto 1Mbytes/sec. USB interfacing are
available having speed near to 12MBytes/sec. Parallel port is basically the 25 pin
Female connector(DB-25) in the back side of the computer(Printer Port). It has 17 input
lines for input port and 12 pins for output port. Out of the 25 pins most pins are
Ground and there is data register(8 bit), control register(4 bit) and status register(5 bit).
We can input port through all the three registers and can output port only through
data and control registers only. Each of these register have their own addresses. By
using that addresses we can program the port. 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.
2. Nibble Mode.
3. Byte Mode.
4. EPP Mode (Enhanced Parallel Port).
5. ECP Mode (Enhanced Capabilities Mode).
Here I am explaining bi-directional mode and simple parallel port. EPP and ECP
modes use handshaking signals.
DATA PORT
BASE ADDRESS- 0X378 or 0x278 (0x378 mostly used)
TOTEM POLE OUTPUT
The Data Out pins were orginally driven by a 74LS374 octal latch, which could source
2.6 mA and sink 24 mA. There were 0.0022uF capacitors between each line and ground
to reduce transients. The manual warns "It is essential that the external device not try
to pull these lines to ground", as this might cause the 74LS374 to source more current
than it could handle without damage. The Feedback input port for the Data Out
register consisted of a 74LS244 *tri-state buffer*; it is uninverted. Note that this port is
only for diagnostics - if at any time the feedback *buffer* for the data port does
not match the data being output, there is an error (eg: a line stuck high or low).
Exception: bidirectional printer ports allow the 74LS374 (or equivalent) driver chip to
be tri*-*stated, which makes the data feedback port into a legitimate unlatched input
port.
Writing Data Port:giving data to the outside circuit
For normal port C5=0(i.e, the fifth bit of control port must be low)
outportb (0x378,0x45);
D7=0 D6=1 D5=0 D4=0 D3=0 D2=1 D1=0 D0=1
reaches the port.It should be noted that dataport is a latch so the last data
send is stored on the port(since it is a latch).
Reading Data Port: Taking data from outside circuit
In order to make data port for inputting the control pin C5=1
outportb(0x37a,0x20);
a=inportb(0x378);
When u execute this program the variable 'a' is stored the value the decimal value of
the data inputted to the port.
Suppose if you input the all the pins to VCC then we get value
a=255
drive load 24mA @ 4.2V (From IBM definition of port)
Note: High Impedance state is considered as HIGH by parallel port. If you read the
data port without connecting any input, we get all high(a=255)(same as that of LS TTL
gates). Suppose if you connect input to D0 and no inputs to the others pins(D1-D7),
then only the value at D0 change, the value at (D1-D7) will remain as same as the
previous value.
CONTROL REGISTER
OPEN COLLECTOR OUTPUTS
The Control Out pins were driven by 7405 inverting open collector buffers, pulled to
+5 volts via 4.7K resistors. All data lines except C2 are inverted before going to output
pins; data line C2 is double inverted before going to pin 16 (ie: is not inverted).
Remember that it is better to use 74LS gates at the output because open collector
inputs are read as LOGIC HIGH by the 74LS series IC's.
Open collector means LOGIC HIGH become high impedance and
LOGIC LOW become LOGIC LOW(<.8V)
writing Control Port:
outportb(0x37a,0x00);
then you get at the ouput C0=1,C1=1,C2=0, C3=1
because the C0,C1,C3 are inverted pins.
Reading Control Port:
We can read Control Port using the command
a=inportb(0x37a);
No other settings are required.
Don't forget to connect buffer at the output of the control port since the voltage level
of the port is not exactly 5V. Remember to use 74LS buffer.
NOTE:
In documentation it has been told that control port has high impedance instead of
HIGH, but practically i am getting some difference. When i send HIGH to the port
and giving the output to an LED, the LED will glow.
STATUS PORT
Status port is used for reading purpose only. It is an input only port.
A=inportb(0x379); will read the status port. But remember that some pins are
inverted.
Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.