Archive for category outb

Programming a "PARALLEL PORT" in C using "inb " and "outb()"

   
                           For programming a parallel port in C,the user program is supposed to get the permission for accesing  the I/O port using the call

iopl(permission value)

which changes the previlege of the calling process.
By default the user program has a permission value of 0.So for accessing the parallel port,the user program  is supposed to have a permission value of 3

iopl(3);

  • outb()

For porting a value onto the parallel – port,the function outb() is used .

outb(value,0x378); 


parallel port the out pins are from 2 to 9 pin.


outb(value,portaddr);

will port a byte to the portaddr address.
the port address is to be selected as follows 

for 
/dev/lp0     ——    0x378 
/dev/lp1     ——–   0x3bc

 
a simple program in C to port a value to the parallel port


inb(portaddr)

parallel port register set


there are three main registers for a parallel port

  • status register
  • controll register
  • status  register

so these registers are used to read  the values of specific pins

the address of the status register
/dev/lp0 — >  0x378
/dev/lp1 — >  0x

4 Comments