Sie sind auf Seite 1von 32

PARALLEL PORT

Dr J.Iqbal

Port
A port is a set of signal lines that the p , or CPU, , uses to exchange g data microprocessor, with other components. Typical use of ports are communicating with printers, modems, keyboards and display. Most of the ports are digital, where each signal, or bit, is 0 or 1.

Dr J.Iqbal

Parallel Port Vs Serial Port


A parallel port sends and receives data eight bits at a time over 8 separate wires wires. This allows data to be transferred very quickly; however, the cable required is more bulky because of the number of individual wires it contain. A serial p port sends and receives data one bit at a time over one wire. While it takes eight times as long to transfer each byte of data this way, only a few wires are required.

Dr J.Iqbal

Serial Vs Parallel Data Transfer

Dr J.Iqbal

Comparison
Serial and Parallel
1 bit can be send at a ti time Slow data transfer 1 wires for data and one for ground is required less components, less chances of failure Less cost 8 bits can be send at a ti time Fast data transfer 8 wire for data and one for ground is required More components, more chances of failure More cost

Dr J.Iqbal

MALE TO MALE D25 CABLE

Dr J.Iqbal

Dr J.Iqbal

Parallel port

Dr J.Iqbal

Port
The original IBM-PC's Parallel Printer Port had a total of 12 digital outputs and 5 digital inputs
8 output p p pins accessed via the DATA Port 5 input pins (one inverted) accessed via the STATUS Port 4 output pins (three inverted) accessed via the CONTROL Port The remaining 8 pins are grounded

Dr J.Iqbal

I/O Ports Address


Address From
000 020 030 040 060 061 170 200 278 2E8 2F8 378 3B0 3BC 3E0 3F8 220

Description
DMA Controller (direct memory access) Master Interrupts Slave Interrupts Timer Keyboard S Speaker k First disk drive Game Port Third parallel port LPT3 Serial Port 4 COM4 Serial Port 2 COM2 Second p parallel p port LPT2 Monochromevideo adapter First parallel port LPT1 Serial port 3 COM3 Serial port 1 COM1 Usually used by sound cards

Until
00F 02F 03F 043 060 061 17F 20F 27F 2EF 2FF 37F 3BB 3BF 3EF 3FF 22F

Dr J.Iqbal

Address of parallel port in windows


Control panel System OR right click my computer and then properties Hardware Device manager Port Parallel port (right click, then click properties) R Resources ( (read d address dd of f th the parallel ll l port) t)

Dr J.Iqbal

Dr J.Iqbal

Address of parallel port in DOS


goto dos prompt c:\> debug <press enter> - d 0040:0008 <press enter> _________________________________________

Microsoft Windows 2000 [Version 5.00.2195] (C) Copyright 1985-1999 Microsoft Corp. c:\>debug -d 0040:0008 0040:0000 BC 03 78 03 78 02 C0 9F ..x.x... 0040:0010 23 C8 FE 80 02 92 10 20-00 00 36 00 36 00 64 20 #...... ..6.6.d 0040:0020 20 39 30 0B 30 0B 34 05-30 0B 3A 27 30 0B 30 0B 90.0.4.0.:'0.0. 0040:0030 30 0B 38 09 0D 1C 00 00-00 00 00 00 00 00 00 00 0.8............. 0040:0040 F9 00 C3 00 00 00 00 00-00 03 50 00 E0 1F 00 00 ..........P..... 0040:0050 00 0A 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0040:0060 07 06 00 D4 03 29 30 80-02 00 18 00 B1 62 0D 00 .....)0......b.. 0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01 ................ Dr J.Iqbal 0040:0080 1E 00 3E 00 31 08 00 60

Parallel port
Data Port Status Port Control Port

(Note that the S7, C0, C1 & C3 signals are inverted)

Dr J.Iqbal

Parallel Port Address


Address B Base +0 Base + 1 Base + 2 Port Name D t P Data Port t Status Port Control Port Read/Write W it Write Read Write

378H PORT: In this address the CPU writes the data to be sent to the printer.
It is an OUTPUT port. The eight data bits (D0-D7) are latched to appear in the output connector.

379H PORT: This is an INPUT port. These signals are used by the CPU to
know the state of the printer.

37AH PORT: In this port the computer writes the signals that control the
printer. Therefore, it is an OUTPUT port.

Dr J.Iqbal

Pin Assignment used by Printer


Pin 1 2-9 10 11 12 13 14 15 16 17 18-25 Signal Strobe Data 0-7 Ack Busy Paper Out Select Auto Linefeed Error / Fault Init Select Printer Ground IN/OUT Out Out In In In In Out In Out Out GND Function A low on this line indicates data is ready Data Bus. Interrupt Line. tells computer that data has been received. Used when buffer is full. A high signal asserted by the printer to indicate that it is busy and cannot take data. Communicate paper out High means printer is online/present Advance paper p p Error has occurred Reset - Active Low Active low. low Used to indicate to the printer that it is selected. Ground
Dr J.Iqbal

Output
STROBE/: (C0) Tells the printer when the eight data bits are ready to be read. Turns to a low logic level when the data are ready. AUTO FD/: (C1) Tells the printer to advance paper. INIT/: (C2) Reset the printer. SLCT IN/: (C3) Used to indicate to the printer that it is selected. D0 D7 Data D0-D7: D t bits. bit

Inputs:
ERROR/ (S3) An ERROR/: A error has h occurred. d Th The CPU stop t sending di more d data t SLCT: (S4) Tells the computer that a printer is present. (S5) ) The p printer is out of p paper. p PE: ( ACK/: (S6) Tells the CPU that the data has been correctly received. BUSY: (S7) The printer sets this line when its buffer is full. The computer will stop sending more data. Dr J.Iqbal

Addressing the port

Data Bits Table BIT FUNCTION PIN D0 D1 D2 D3 D4 D5 D6 D7 data 0 data 1 data 2 data 3 data 4 data 5 data 6 data 7 2 3 4 5 6 7 8 9

Status Bits Table BIT FUNCTION PIN D0 D1 D2 D3 D4 D5 D6 D7 not used not used not used ERROR/ SLCT/ PE ACK/ BUSY/ 15 13 12 10 11

Control Bits Table BIT FUNCTION D0 D1 D2 D3 D4 D5 D6 D7 STROBE AUTO FD INIT/ SLCT IN/ Not used not used not used not used PIN 1 14 16 17

(Note that the pins 1, 10, 14, 17 are inverted)


Dr J.Iqbal

Dr J.Iqbal

Functions used for Data Transfer


Data In: inportb (PortAddress) Data Out: outportb (Data ( , PortAddress) )

Dr J.Iqbal

#include <stdio.h> #include <dos.h> #include <conio.h> <conio h> /*This program set the parallel ll l port outputs*/ void main (void) {clrscr(); outportb(0x378 0xff); outportb(0x378,0xff); getch(); }

This program shows how to send a byte to the parallel port output addresses. It's as easy as you can see. The Th outportb(); t tb() function sends a byte to a specified I/O port. The first function parameter is the address of the port to write a byte The second parameter is byte. the value of the byte to send. Both parameters can be defined as variables. variables

Dr J.Iqbal

#include <stdio.h> #include <dos.h> #include <conio.h> /*This program set the parallel port outputs*/ p p / void main (void) {unsigned int BaseAddress=0x378; clrscr(); outportb(BaseAddress+2,0xff); getch(); }

Above program shows Ab h h how t to send dab byte t t to th the C Control t l port t of parallel port. Control port is at Base+2 address. Remember that bit 0,1,3 of control port was inverted by hardware. To get correct result, we need to use exclusive OR with 0xb [1011], which will give us correct result.

Dr J.Iqbal

Problem
Bit 0 0,1,3 1 3 of f control t l port t was i inverted t db by hardware. To get correct result, we need to do some manipulation. i l ti Wh What t are th those ????

Dr J.Iqbal

#include <stdio.h> #include <dos.h> #include <conio.h> /*This program set the parallel port outputs*/ p p / void main (void) {unsigned int BaseAddress=0x378; clrscr(); outportb(BaseAddress+2,0xff^0xb); getch(); }

Above program shows Ab h h how t to send dab byte t t to th the C Control t l port t of parallel port. Control port is at Base+2 address. Remember that bit 0,1,3 of control port was inverted by hardware. To get correct result, we need to use exclusive OR with 0xb [1011], which will give us correct result.

Dr J.Iqbal

#include <stdio.h> #include <dos.h> #include <conio.h> # /*This function read parallel port inputs*/ int Read_Input() {int Byte; Byte=inportb(0x379); return t B Byte; t } (void) ) void main ( {int PP_Input; clrscr(); PP_Input p = Read_Input(); p (); printf("%d",PP_Input); getch(); }

This example shows how to read a byte from the parallel port input address. The main function is only used to show the value of the byte on the screen screen. The inportb(); function read a byte from the specified I/O address of the computer.
Dr J.Iqbal

Dr J.Iqbal

Dr J.Iqbal

The End
Dr J.Iqbal

Pin

SPP Signal

EPP Signal

IN/OUT

Function A low on this line indicates a Write, High indicates a Read Data Bus. Bidirectional Interrupt Line. Used U df for handshaking. A EPP cycle can be started when low, and finished when high. Spare - Not Used in EPP Handshake Dr J.Iqbal

Strobe

Write

Out

2-9

Data 0-7

Data 0-7

In-Out

10

Ack

Interrupt

In

11

Busy

Wait

In

12

Paper Out / End

Spare

In

Pin
13

SPP Signal
Select

EPP Signal
Spare

IN/OUT
In

Function
Spare - Not Used in EPP Handshake When Low, indicates Data transfer Spare - Note used in EPP H d h k Handshake Reset - Active Low When low, indicates Address transfer Ground

14

Auto Linefeed

Data Strobe

Out

15

Error / Fault

Spare

In

16

Initialize

Reset

Out

17

Select Printer

Address Strobe

Out

18-25

Ground

Ground

GND

Dr J.Iqbal

Dr J.Iqbal

Dr J.Iqbal

Das könnte Ihnen auch gefallen