Searching \ for 'interface to parallel port' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'interface to parallel port'.

Truncated match.
PICList Thread
'interface to parallel port'
1998\06\26@210137 by Brian Clewer

Hey sorry I didn't catch your name, but you wrote:)

>There is a bit in the control register that controls the direction of the
data lines in ECP
>and PS2 modes. If bit 5 of the control register (base address +2) is set
to 1, the data
>lines are set to inputs.......

Thankyou for your code to set the port to inputs.  However I still can't
get the port to work!  I do have a program that monitors the data line on
the port and this seems to work properly.  I have designed a program to
read the base address of the port  plus the next two addresses for the
on a re-boot of my PC and then  again while the 'port program' was running
and again when the port program had ended (it turns the port to an output
again at the end).

Here are the results:)
 On boot up:
Base address ( 0x378)  =  7F04
Base +1         (0x379)   = CC7F
Base +2         (0x37A)   = CCCC

While the LPT program was running:)
Base address ( 0x378)  =  7FFF
Base +1         (0x379)   = E37F
Base +2         (0x37A)   = E3E3

After the LPT program:)
Base address ( 0x378)  =  7F04
Base +1         (0x379)   = DC7F
Base +2         (0x37A)   = DCDC

Now, If I run the LPT program and it exits properly (it has now set all
bits on the port to outputs) I can run my 'C' program and read the port
correctly but, if I just reboot my PC and try to read the port, it does
work.  I have set the three registers to 7FFF for the base address, and
E37F for Base + 1 and E3E3 for  base + 3.  My only guess now is that the
LPT program does more than setting up these three registers.  Can anybody
tell me exactly what is needed (step by step) to initialize the parallel


1998\06\27@180941 by myke predko

Hey Brian,

I'm just looking at what you put earlier as your results:

{Quote hidden}

Brian, these three registers are EIGHT bits long.  You seem to be
reading/writing sixteen bit values to them.  How are you reading/writing to
them?  Is the routine using an input byte or input word instruction?

In "standard" C, you should use the "inp"/"outp" functions only.

In most PCs that I have seen, the actual I/O bus is eight bits wide, when a
sixteen bit read/write instruction is encountered, there are actually two
reads/writes with the processor in "Hold" while this is happening; eight
bits from the address PLUS another operation on the next register address.
The hardware combines these into a sixteen bit value.

This makes a word (16 bit) I/O access the same to the hardware as two eight
bit I/O accesses.

And, if you look at your results, you'll see that this is exactly what is
happening (note that the low byte of the next address is the same as the
high byte of the current address).

NEVER do sixteen bit I/O operations on a PC unless you know *exactly* what
you are doing (even then it's not recommended).

Good luck,


"In this life we all get an equal share of ice.  The rich get it in the
summer, the poor get it in the winter." - Bat Masterson's last words

1998\06\29@121109 by Dennis Merrill

> work.  I have set the three registers to 7FFF for the base address, and
> E37F for Base + 1 and E3E3 for  base + 3.  My only guess now is that the
> LPT program does more than setting up these three registers.  Can anybody
> tell me exactly what is needed (step by step) to initialize the parallel
> port?

OK Brian,

First of all realize that all of the registers your reading are BYTE
registers. I noticed you're saying what WORD you read from it, but only the
lower BYTE is of any importance. First, lets realize what registers there
are and then I'll show you need to do to initialize them to read from the

BaseAddress = Data Register (what's on the data lines)
BaseAddress + 1 = Status Register (what's on the status lines)
BaseAddress + 2 = Control Register
BaseAddress + 400h = ECP Fifo (you probably don't need this)
BaseAddress + 402h = ECR (ECP Control Register)

the top three bits of the ECR control the ECP mode that the port is
currently in.  I bet that you have these bits set to 000 which is ISA
compatible mode.  This would put your port in single-directional mode and
the bit in the control register I mentioned last time would have no effect.
you want the ECR to be set to 001 for PS2 compatible (bi-directional) mode.
Here's how you would do that:

byECR = _inp ( 0x378 + 0x402 );
byECR &= 0x1F;
byECR |= 0x20;
_outp( 0x378 + 0x402, byECR );

After this, set the control lines like I suggested last time and you should
be good to read from the port. If you still can't get it to work, email me
your program (not to the PIClist, to me) and I will give you some more

         Dennis Merrill, BSEE
        Device Driver Engineer
        Embedded Systems Group
     Nicolet Instrument Corp.

1998\06\30@183230 by Sean Breheny

face picon face
I am not the person who sent that code to you, but a while back (maybe 6
months ago) someone posted a URL on the list where you could find info on
how to access the parallel port in EPP and ECP modes. This is not the
straight bidirectional mode you are trying, but it might work better.
Maybe if you use the archive you can find this post. If not, email me and
I will send you the files directly.

Good luck,


On Fri, 26 Jun 1998, Brian Clewer wrote:

{Quote hidden}

'interface to parallel port'
1998\07\01@085106 by Peter L. Peres
picon face
On Tue, 30 Jun 1998, Sean Breheny wrote:

{Quote hidden}

The exact things to be done depend on the chipset. The actions are
performed by the BIOS at boot time.

There is extensive information about parallel port modes on the ieee1284
web site:

hope this helps,


More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...