Standard Parallel port read

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Thanks again Damion,

I have some I/O on the SBC but they all are occupied, the modification
for particular customer needs another 16 Inputs to read.

I am still not sure that one can not use all the Parallel port pins

As Parallel port can be used in SPP , EPP , ECP Modes, you are
absolutely right for EPP and ECP but in SPP story is different.

ON this site he is reading from all the pins I cant read :) :(


Pin No (D-Type 25)    Pin No (Centronics)    SPP Signal    Direction
In/out    Register    Hardware Inverted
1    1    nStrobe    In/Out    Control    Yes
2    2    Data 0    Out    Data    
3    3    Data 1    Out    Data    
4    4    Data 2    Out    Data    
5    5    Data 3    Out    Data    
6    6    Data 4    Out    Data    
7    7    Data 5    Out    Data    
8    8    Data 6    Out    Data    
9    9    Data 7    Out    Data    
10    10    nAck    In    Status    
11    11    Busy    In    Status    Yes
12    12    Paper-Out / Paper-End    In    Status    
13    13    Select    In    Status    
14    14    nAuto-Linefeed    In/Out    Control    Yes
15    32    nError / nFault    In    Status    
16    31    nInitialize    In/Out    Control    
17    36    nSelect-Printer / nSelect-In    In/Out    Control    Yes
18 - 25    19-30    Ground    Gnd         
Table 1. Pin Assignments of the D-Type 25 pin Parallel Port Connector.


    The only different : these 4 pins are Inverted……………………………….

Also if I believe beyond logic than it says in SPP I can never able to
read pins 2-9, which I am already reading…….

I am totally confused……….. Is any one out there wants to share any
experience in this controversial issue ….

Another solution can be to use the multiplexer and read the pins, but
do I really need to use the hardware ……….???????????



Re: Standard Parallel port read
Quoted text here. Click to load it

I was thinking you only had 12 input pins, but it looks like
you can read 17 pins(one extra thrown in as a bonus).

A useful reference is the IBM Technical Reference Personal Computer AT
March 1984  (20 years ago!)

The above includes schematics of the AT serial/parallel board.
I had to fathom the mysteries of the 74LS155 decode logic to get
that 17th input pin for you.  Tried scanning it in, but my
scanner is dying, so no luck.

Keep in mind that a lot of these pins are normally outputs until
switched to "input mode".

See below for some software.

Quoted text here. Click to load it

Heres some code to help explain and test:

Included is this fun little prog:
To compile: gcc -O1 in17.c -o in17

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <ctype.h>


#include <errno.h>

#include <asm/io.h>

#include <sys/perm.h>

#include <unistd.h>


#define InB inb

#define OutB(_p, _d) outb(_d, _p)

#define LPT_BASE 0x378


int main(int argc, char *argv[])


   unsigned char data,stat,ctrl,i;


   printf("in17.c - test all 17 lpt inputs\n");

   if (ioperm(LPT_BASE, 3, 1)) {

     printf("Could not get IO permissions\n");

     exit (1);


   OutB(LPT_CTRL, 0x24);  // set all output's high, so we can read em


   printf("Connect wire from gnd(18-25) to each pin:\n");

   printf("Input Pins: 2-9=data 10=ack 11=busy 12=PE 13=slct
   printf("AND Output Pins: 1=strobe 14=auto_fd 16=init 17=slct_in\n");

     //    Data:01234567 Stat:01234567 Ctrl:01234567

   printf("      8 6 4 2      11                17 \n");

   printf("     9 7 5 3        10                16\n");

   printf("                     12                14\n");

   printf("                      13                1\n");

   printf("                       15\n");

   while (1) {

     data = InB(LPT_DATA);

     stat = InB(LPT_STAT);

     ctrl = InB(LPT_CTRL);


     for (i=0; i<8; i++) {

       printf("%c", data & (0x80 >> i) ? '1' : '0' );


     printf(" Stat:");

     for (i=0; i<8; i++) {

       printf("%c", stat & (0x80 >> i) ? '1' : '0' );


     printf(" Ctrl:");

     for (i=0; i<8; i++) {

       printf("%c", ctrl & (0x80 >> i) ? '1' : '0' );




     usleep(100000L);  // sleep .1 secs


   ioperm(LPT_BASE, 3, 0);  // release

   return 0;



Quoted text here. Click to load it

Site Timeline