📄 interfacing the standard parallel port.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0043)http://www.beyondlogic.org/spp/parallel.htm -->
<HTML><HEAD><TITLE>Interfacing the Standard Parallel Port</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META
content="Describes interfacing the SPP (Standard Parallel Port) with pin diagrams, sample schematics & source code in C. Also avaliable in PDF."
name=description>
<META
content="Parallel Port, Printer Port, Centronics Port, IEEE 1284, Centronics Mode, Nibble Mode, Byte Mode, EPP Mode, ECP Mode, ECP, SPP, EPP, Extended Capabilities Port, Enhanced Parallel Port"
name=keywords>
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY leftMargin=0
background="Interfacing the Standard Parallel Port.files/bgyellow.gif"
topMargin=0 FACE="ARIAL" BASEFONT marginwidth="0" marginheight="0">
<STYLE type=text/css>#TITLEBLOCK {
COLOR: #ffffff; TEXT-DECORATION: none
}
TD {
FONT-FAMILY: Arial
}
P {
FONT-FAMILY: Arial
}
FONT {
FONT-FAMILY: Arial
}
A {
FONT-FAMILY: Arial
}
LI {
FONT-FAMILY: Arial
}
B {
FONT-FAMILY: Arial
}
PRE {
COLOR: #100080
}
TT {
COLOR: #100080
}
</STYLE>
<BR>
<CENTER>
<TABLE width="95%" BOARDER="0">
<TBODY>
<TR>
<TD width="25%">
<CENTER><A href="http://www.beyondlogic.org/"><IMG alt="Beyond Logic"
src="Interfacing the Standard Parallel Port.files/beyondsmall.gif"
border=0></A></CENTER></TD>
<TD width="50%">
<CENTER>
<SCRIPT type=text/javascript><!--google_ad_client = "pub-7725444460812017";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text_image";google_ad_channel ="";google_color_border = "0033FF";google_color_bg = "FFFFFF";google_color_link = "0000FF";google_color_url = "008000";google_color_text = "000000";//--></SCRIPT>
<SCRIPT src="Interfacing the Standard Parallel Port.files/show_ads.js"
type=text/javascript></SCRIPT>
<NOSCRIPT><FONT color=red>This page is optimised with JavaScript 1.2.
Currently your browser has JavaScript switched off.</NOSCRIPT>
</CENTER></FONT></TD>
<TD vAlign=center align=right><BR><FONT face=ARIAL>
<SCRIPT language=javascript
src="Interfacing the Standard Parallel Port.files/beyondmenu_plain.js"></SCRIPT>
<NOSCRIPT></FONT></TD></TR></TBODY></TABLE></CENTER></NOSCRIPT>
<CENTER>
<TABLE width="95%">
<TBODY>
<TR>
<TD><BR><BR>
<CENTER><FONT color=green size=5>Interfacing the Standard Parallel
Port</FONT></CENTER>
<CENTER><BR><B><I><FONT size=+2>Table of
Contents</FONT></I></B></CENTER><BR>
<CENTER><B><I><FONT size=+2></FONT></I></B></CENTER>
<CENTER><A
href="http://www.beyondlogic.org/spp/parallel.htm#1">Introduction to
Parallel Ports</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#2">Hardware
Properties</A></CENTER>
<CENTER><A
href="http://www.beyondlogic.org/spp/parallel.htm#3">Centronics?</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#4">Port
Addresses</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#5">Software
Registers - Standard Parallel Port (SPP)</A></CENTER>
<CENTER><A
href="http://www.beyondlogic.org/spp/parallel.htm#6">Bi-directional
Ports</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#7">Using the
Parallel Port to Input 8 Bits</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#8">Nibble
Mode</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#9">Using the
Parallel Port's IRQ</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#10">Parallel
Port Modes in BIOS</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#11">Parallel
Port Modes and the ECP's Extended Control Register</A></CENTER>
<CENTER><A href="http://www.beyondlogic.org/spp/parallel.htm#12">PDF
Version</A></CENTER><BR><A name=1><I><FONT size=+2>Introduction to
Parallel Ports</FONT></I>
<HR>
</A>
<UL>
<P>The Parallel Port is the most commonly used port for interfacing home
made projects. 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. The port is composed of 4
control lines, 5 status lines and 8 data lines. It's found commonly on
the back of your PC as a D-Type 25 Pin female connector. There may also
be a D-Type 25 pin male connector. This will be a serial RS-232 port and
thus, is a totally incompatible port. </P>
<CENTER><I>For more information on Serial RS-232 Ports See <A
href="http://www.beyondlogic.org/serial/serial.htm">http://www.beyondlogic.org/serial/serial.htm</A></I></CENTER>
<P>Newer Parallel Port抯 are standardized under the IEEE 1284 standard
first released in 1994. This standard defines 5 modes of operation which
are as follows, </P>
<UL>1. Compatibility Mode. <BR>2. Nibble Mode. (Protocol not Described
in this Document) <BR>3. Byte Mode. (Protocol not Described in this
Document) <BR>4. EPP Mode (Enhanced Parallel Port). <BR>5. ECP Mode
(Extended Capabilities Mode). </UL>
<P>The aim was to design new drivers and devices which were compatible
with each other and also backwards compatible with the Standard Parallel
Port (SPP). Compatibility, Nibble & Byte modes use just the standard
hardware available on the original Parallel Port cards while EPP &
ECP modes require additional hardware which can run at faster speeds,
while still being downwards compatible with the Standard Parallel Port.
</P>
<P>Compatibility mode or "Centronics Mode" as it is commonly known, can
only send data in the forward direction at a typical speed of 50 kbytes
per second but can be as high as 150+ kbytes a second. In order to
receive data, you must change the mode to either Nibble or Byte mode.
Nibble mode can input a nibble (4 bits) in the reverse direction. E.g.
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 in
the reverse direction. </P>Extended and Enhanced Parallel Ports use
additional hardware to generate and manage handshaking. To output a byte
to a printer (or anything in that matter) using compatibility mode, the
software must,
<P></P>
<UL><I>1. Write the byte to the Data Port.</I> <BR><I>2. Check to see
is the printer is busy. If the printer is busy, it will not accept any
data, thus any data which is written will be lost.</I> <BR><I>3. Take
the Strobe (Pin 1) low. This tells the printer that there is the
correct data on the data lines. (Pins 2-9)</I> <BR><I>4. Put the
strobe high again after waiting approximately 5 microseconds after
putting the strobe low. (Step 3)</I> </UL>
<P>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 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. </P></UL><A name=2><I><FONT size=+2>Hardware
Properties</FONT></I>
<HR>
</A>
<UL>
<P>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. The IEEE 1284
standard however specifies 3 different connectors for use with the
Parallel Port. The first one, 1284 Type A is the D-Type 25 connector
found on the back of most computers. The 2nd is the 1284 Type B which is
the 36 pin Centronics Connector found on most printers. </P>
<P>IEEE 1284 Type C however, is a 36 conductor connector like the
Centronics, but smaller. This connector is claimed to have a better clip
latch, better electrical properties and is easier to assemble. It also
contains two more pins for signals which can be used to see whether the
other device connected, has power. 1284 Type C connectors are
recommended for new designs, so we can look forward on seeing these new
connectors in the near future. </P>
<CENTER>
<TABLE width="75%" border=1>
<TBODY>
<TR>
<TD width="20%">
<CENTER><B>Pin No (D-Type 25)</B></CENTER></TD>
<TD width="20%">
<CENTER><B>Pin No (Centronics)</B></CENTER></TD>
<TD width="25%">
<CENTER><B>SPP Signal</B></CENTER></TD>
<TD width="10%">
<CENTER><B>Direction In/out</B></CENTER></TD>
<TD width="10%">
<CENTER><B>Register</B></CENTER></TD>
<TD width="15%">
<CENTER><B>Hardware Inverted</B></CENTER></TD></TR>
<TR>
<TD>
<CENTER>1</CENTER></TD>
<TD>
<CENTER>1</CENTER></TD>
<TD>
<CENTER>nStrobe</CENTER></TD>
<TD>
<CENTER>In/Out</CENTER></TD>
<TD>
<CENTER>Control</CENTER></TD>
<TD>
<CENTER>Yes</CENTER></TD></TR>
<TR>
<TD>
<CENTER>2</CENTER></TD>
<TD>
<CENTER>2</CENTER></TD>
<TD>
<CENTER>Data 0</CENTER></TD>
<TD>
<CENTER>Out</CENTER></TD>
<TD>
<CENTER>Data</CENTER></TD>
<TD>
<CENTER> </CENTER></TD></TR>
<TR>
<TD>
<CENTER>3</CENTER></TD>
<TD>
<CENTER>3</CENTER></TD>
<TD>
<CENTER>Data 1</CENTER></TD>
<TD>
<CENTER>Out</CENTER></TD>
<TD>
<CENTER>Data</CENTER></TD>
<TD>
<CENTER> </CENTER></TD></TR>
<TR>
<TD>
<CENTER>4</CENTER></TD>
<TD>
<CENTER>4</CENTER></TD>
<TD>
<CENTER>Data 2</CENTER></TD>
<TD>
<CENTER>Out</CENTER></TD>
<TD>
<CENTER>Data</CENTER></TD>
<TD>
<CENTER> </CENTER></TD></TR>
<TR>
<TD>
<CENTER>5</CENTER></TD>
<TD>
<CENTER>5</CENTER></TD>
<TD>
<CENTER>Data 3</CENTER></TD>
<TD>
<CENTER>Out</CENTER></TD>
<TD>
<CENTER>Data</CENTER></TD>
<TD>
<CENTER> </CENTER></TD></TR>
<TR>
<TD>
<CENTER>6</CENTER></TD>
<TD>
<CENTER>6</CENTER></TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -