using parallel port for I2C - timing problem?

using parallel port for I2C - timing problem?

Post by Drew Perttul » Thu, 09 Oct 1997 04:00:00



I got the board described at http://www.velleman.be/kits/k8000.htm

It has a few chips that speak I2C and it comes with software that
sends/receives I2C over the online(17), autofeed(14), and select(13)
lines.

IT WORKS IN DOS! The sample programs run great, board lights up great.

I ported the code to Linux by changing outport() and inp() to outb() and
inb(). I got everything working such that the 'data from port' LEDs
on the board blink just as they do in DOS. But the I2C chips don't
react.

I2C appears to be pretty relaxed about timing, and I've tried many
things (though outb_p gives me segfault).

What is the difference between DOS and Linux w.r.t. IO ports?? Does
one or the other alter my data before sending it to the port or
something?

TIA--
  Drew

 
 
 

using parallel port for I2C - timing problem?

Post by Jonathan Luck » Tue, 14 Oct 1997 04:00:00



>I got the board described at http://www.velleman.be/kits/k8000.htm
>It has a few chips that speak I2C and it comes with software that
>sends/receives I2C over the online(17), autofeed(14), and select(13)
>lines.
>IT WORKS IN DOS! The sample programs run great, board lights up great.
>I ported the code to Linux by changing outport() and inp() to outb() and
>inb(). I got everything working such that the 'data from port' LEDs
>on the board blink just as they do in DOS. But the I2C chips don't
>react.

Well, I am assuming you know that normally Linux reserves the in/out
instructions to the kernel, so you have to do things funny at a high
security level to access the raw hardware.  That may explain your
segfault.

But the main difference betrween Linux and DOS is that it is multi-
tasking.  So you need to make sure that some other program is not
affectting yout direct access of the LPT port.  Linux commonly comes
with polling printer driver enabled.  So when you toggle bits to do your
serial bus, linux might come along, poll the port, see something it
thinks it has to handle, and do its own write to the port.  I suggest you
recompile your kernel with no LPT drivers, and make sure you are not
loading LPT drivers as a module.