⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interfacing the standard parallel port.htm

📁 并口的接口规范
💻 HTM
📖 第 1 页 / 共 5 页
字号:
            <TD width="60%"><B>
              <CENTER>Function</CENTER><B></B></B></TD></TR>
          <TR>
            <TD>
              <CENTER>0000:0408</CENTER></TD>
            <TD>LPT1's Base Address</TD></TR>
          <TR>
            <TD>
              <CENTER>0000:040A</CENTER></TD>
            <TD>LPT2's Base Address</TD></TR>
          <TR>
            <TD>
              <CENTER>0000:040C</CENTER></TD>
            <TD>LPT3's Base Address</TD></TR>
          <TR>
            <TD>
              <CENTER>0000:040E</CENTER></TD>
            <TD>LPT4's Base Address (Note 1)</TD></TR></TBODY></TABLE><FONT 
        size=-1>Table 3 - LPT Addresses in the BIOS Data 
        Area;</FONT></CENTER><BR><I>Note 1 : Address 0000:040E in the BIOS Data 
        Area may be used as the Extended Bios Data Area in PS/2 and newer 
        Bioses.</I> 
        <P>The above table, table 3, shows the address at which we can find the 
        Printer Port's addresses in the BIOS Data Area. Each address will take 
        up 2 bytes. The following sample program in C, shows how you can read 
        these locations to obtain the addresses of your printer ports. </P>
        <UL></FONT><PRE>#include &lt;stdio.h&gt;
#include &lt;dos.h&gt;

void main(void)
{
 unsigned int far *ptraddr;  /* Pointer to location of Port Addresses */
 unsigned int address;       /* Address of Port */
 int a;

 ptraddr=(unsigned int far *)0x00000408;

 for (a = 0; a &lt; 3; a++)
   {
    address = *ptraddr;
    if (address == 0)
		printf("No port found for LPT%d \n",a+1);
    else
		printf("Address assigned to LPT%d is %Xh\n",a+1,address);
    *ptraddr++;
   }
}
</PRE><FONT face=ARIAL></UL></UL><A name=5><I><FONT size=+2>Software 
      Registers - Standard Parallel Port (SPP)</FONT>
      <HR>
      </I></A> 
      <UL>
        <CENTER>
        <TABLE width="80%" border=1>
          <TBODY>
          <TR>
            <TD width="15%">
              <CENTER><B>Offset</B></CENTER></TD>
            <TD width="15%">
              <CENTER><B>Name</B></CENTER></TD>
            <TD width="15%">
              <CENTER><B>Read/Write</B></CENTER></TD>
            <TD width="25%">
              <CENTER><B>Bit No.</B></CENTER></TD>
            <TD width="30%">
              <CENTER><B>Properties</B></CENTER></TD></TR>
          <TR>
            <TD vAlign=top rowSpan=8>
              <CENTER>Base + 0</CENTER></TD>
            <TD vAlign=top rowSpan=8>
              <CENTER>Data Port</CENTER></TD>
            <TD vAlign=top rowSpan=8>
              <CENTER>Write (Note-1)</CENTER></TD>
            <TD>
              <CENTER>Bit 7</CENTER></TD>
            <TD>
              <CENTER>Data 7</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 6</CENTER></TD>
            <TD>
              <CENTER>Data 6</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 5</CENTER></TD>
            <TD>
              <CENTER>Data 5</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 4</CENTER></TD>
            <TD>
              <CENTER>Data 4</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 3</CENTER></TD>
            <TD>
              <CENTER>Data 3</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 2</CENTER></TD>
            <TD>
              <CENTER>Data 2</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 1</CENTER></TD>
            <TD>
              <CENTER>Data 1</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 0</CENTER></TD>
            <TD>
              <CENTER>Data 0</CENTER></TD></TR></TBODY></TABLE><FONT size=-1>Table 4 
        Data Port</FONT></CENTER><BR><I>Note 1 : If the Port is Bi-Directional 
        then Read and Write Operations can be performed on the Data 
        Register.</I> <BR>
        <P>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. See Bi-directional 
        Ports for more detail. </P>
        <CENTER>
        <TABLE width="80%" border=1>
          <TBODY>
          <TR>
            <TD width="15%">
              <CENTER><B>Offset</B></CENTER></TD>
            <TD width="15%">
              <CENTER><B>Name</B></CENTER></TD>
            <TD width="15%">
              <CENTER><B>Read/Write</B></CENTER></TD>
            <TD width="25%">
              <CENTER><B>Bit No.</B></CENTER></TD>
            <TD width="30%">
              <CENTER><B>Properties</B></CENTER></TD></TR>
          <TR>
            <TD vAlign=top rowSpan=8>
              <CENTER>Base + 1</CENTER></TD>
            <TD vAlign=top rowSpan=8>
              <CENTER>Status Port</CENTER></TD>
            <TD vAlign=top rowSpan=8>
              <CENTER>Read Only</CENTER></TD>
            <TD>
              <CENTER>Bit 7</CENTER></TD>
            <TD>
              <CENTER>Busy</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 6</CENTER></TD>
            <TD>
              <CENTER>Ack</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 5</CENTER></TD>
            <TD>
              <CENTER>Paper Out</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 4</CENTER></TD>
            <TD>
              <CENTER>Select In</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 3</CENTER></TD>
            <TD>
              <CENTER>Error</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 2</CENTER></TD>
            <TD>
              <CENTER>IRQ (Not)</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 1</CENTER></TD>
            <TD>
              <CENTER>Reserved</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 0</CENTER></TD>
            <TD>
              <CENTER>Reserved</CENTER></TD></TR></TBODY></TABLE><FONT size=-1>Table 5 
        Status Port</FONT></CENTER>
        <P>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 &amp; 15), a IRQ status register and two 
        reserved bits. Please note that Bit 7 (Busy) is a active low input. E.g. 
        If bit 7 happens to show a logic 0, this means that there is +5v at pin 
        11. Likewise with Bit 2. (nIRQ) If this bit shows a '1' then an 
        interrupt has <B>not</B> occurred. </P>
        <CENTER>
        <TABLE width="80%" border=1>
          <TBODY>
          <TR>
            <TD width="15%">
              <CENTER><B>Offset</B></CENTER></TD>
            <TD width="15%">
              <CENTER><B>Name</B></CENTER></TD>
            <TD width="15%">
              <CENTER><B>Read/Write</B></CENTER></TD>
            <TD width="25%">
              <CENTER><B>Bit No.</B></CENTER></TD>
            <TD width="30%">
              <CENTER><B>Properties</B></CENTER></TD></TR>
          <TR>
            <TD vAlign=top rowSpan=8>
              <CENTER>Base + 2</CENTER></TD>
            <TD vAlign=top rowSpan=8>
              <CENTER>Control Port</CENTER></TD>
            <TD vAlign=top rowSpan=8>
              <CENTER>Read/Write</CENTER></TD>
            <TD>
              <CENTER>Bit 7</CENTER></TD>
            <TD>
              <CENTER>Unused</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 6</CENTER></TD>
            <TD>
              <CENTER>Unused</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 5</CENTER></TD>
            <TD>
              <CENTER>Enable Bi-Directional Port</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 4</CENTER></TD>
            <TD>
              <CENTER>Enable IRQ Via Ack Line</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 3</CENTER></TD>
            <TD>
              <CENTER>Select Printer</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 2</CENTER></TD>
            <TD>
              <CENTER>Initialize Printer (Reset)</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 1</CENTER></TD>
            <TD>
              <CENTER>Auto Linefeed</CENTER></TD></TR>
          <TR>
            <TD>
              <CENTER>Bit 0</CENTER></TD>
            <TD>
              <CENTER>Strobe</CENTER></TD></TR></TBODY></TABLE><FONT size=-1>Table 6 
        Control Port</FONT></CENTER>
        <P>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. </P>
        <P>The printer would not send a signal to initialize the computer, nor 
        would it tell the computer to use auto linefeed. However these four 
        outputs can also be used for inputs. If the computer has placed a pin 
        high (e.g. +5v) and your device wanted to take it low, you would 
        effectively short out the port, causing a conflict on that pin. 
        Therefore these lines are "open collector" outputs (or open drain for 
        CMOS devices). This means that it has two states. A low state (0v) and a 
        high impedance state (open circuit). </P>
        <P>Normally the Printer Card will have internal pull-up resistors, but 
        as you would expect, not all will. Some may just have open collector 
        outputs, while others may even have normal totem pole outputs. In order 
        to make your device work correctly on as many Printer Ports as possible, 
        you can use an external resistor as well. Should you already have an 
        internal resistor, then it will act in Parallel with it, or if you have 
        Totem pole outputs, the resistor will act as a load. </P>
        <P>An external 4.7k resistor can be used to pull the pin high. I 
        wouldn't use anything lower, just in case you do have an internal pull 
        up resistor, as the external resistor would act in parallel giving 
        effectively, a lower value pull up resistor. When in high impedance 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -