problems reading from the parallel port's control register

Hi, I'm trying to build a simple 8-bit input/output interface via the PC parallel port. I've seen lots of sample code and schematics from books and on the web, but I'm having trouble getting it to work for myself.

8-bit output and the 5-bits of input via the status register work fine, but I've been totally unable to read anything via the control register.

This is essentially what I'm doing:

#define BASE 0x378 // printer port base address #define STATUS BASE+1 // status port #define CONTROL BASE+2 // control port

//output 8 bits to data lines 0-7 outb(value,BASE);

//prepare control port for input outb(inb(CONTROL) || 0x0f, CONTROL); input1 = inb(STATUS); //input 5 bits input2 = inb(CONTROL); //input 4 bits

I can see the bits changing on the status line as I switch pins (10-13,15) from high to low, but I don't ever see changes from the control pins (1,14,16,17) no matter what I do.

I've double checked my connections and they seem fine, and I've tried this on two different machines with the exact same results. Both machines are running Linux 2.4.20. I suppose the next step would be testing with a windows box, but I don't really want to risk damaging my wife's machine.

Does anyone know if I need a particular parallel port kernel module or need to set some setting in linux somewhere? Or am I missing something else somewhere?

Thanks, William

Reply to
William Schumacher
Loading thread data ...

You're not gonna be able to read anything from the control register. It is a write register, with four _outputs_. If you need more inputs, and your port is bidirectional, you can configure the data port as input instead of output. But the control port is always output, and the status port is always input.

John Kasunich

Reply to
John Kasunich

--------------- Not true, the SPP control register outputs are open-collector outputs with read-back input paths attached. The exception would be parallel ports that are being unfaithfully emulated by defectively designed multi-I/O chips. First write 40H to the control port, then attach grounding switches to short the control pins 1, 14, 16, 17 to ground, which is pins 18-25, and you will be able to pull them LO from their pre-set HI state and read it on parallel port address base+2.

-Steve

Reply to
R. Steve Walz

------------ Also, you will have to set the system I/O permissions in Linux to permit this!!! Whereas Windows 9x etc allows it, Linux does not do so automagically.

-Steve

Reply to
R. Steve Walz

That's what I seem to be seeing anyway... I have a book here called 'Controlling the World with your PC' by Paul Bergsman that says you can use the 4 control pins on the parallel port for input if you force them high first. Here is a site that says the same thing:

formatting link
"What I did not mention about the Control Port (other than having four outputs) is that they are bi-directional. They can be outputs and inputs! Dont you just love how confusing they can get?"

I can't seem to do anything of the sort though.

Thanks, William

Reply to
William Schumacher

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.