Software Archive
Read-only legacy content
17061 Discussions

Use of parallel port

Intel_C_Intel
Employee
556 Views
I try to get control over the parallel port in order to command and control equipment connected to this port.

Using a modern computer running under Windows (both 95 and NT 4) I have significant problems with this. After reading the DVF manuals, I thought if there is a way, I have to use the Windows API, therefore, I tried that. However, maybe since I do not know anything about C programming, I failed.

This leads to my question. Is there anybody there who had already the same problem? Maybe someone could show me by an example how I could handle the parallel port? I need something which is able to send out any code, read any code and check the signal lines (i.e. busy, etc.).

Thanks in advance for any replies.
0 Kudos
1 Reply
alfredodell
Beginner
556 Views
Use the following routines to read/write to a port

function inport(iport)  
external inportb  
pointer(p,inportb)  
integer code(3)  
data code / #0424548B, #c033128B, #0004c2EC /  
p = loc(code)  
inport = inportb(iport)  
return  
end  
subroutine outport(ibyte, iport)  
external outportb  
pointer(p,outportb)  
integer code(4)  
data code / #0424548B, #548B028A, #128B0824, #0008C2EE  /  
p = loc(code)  
call outportb(ibyte, iport)  
return  
end  


Each parallel part has 3 port locations:

port - write/read data 8 bits

port+1 - read status 5 bits

port+3 - write status 4 bits

where port is usually #378 or #278

If the port is bidirectional bit5 (32) of port+3 is set for read, clear for write
Eg

iport=#387  
call outport(0, iport+2) !set data port to write & write 0 to output status  
call outport(24, iport) !write 24 to data port  
call outport(13+32, iport+2) !set data port to read and write 13 to output status  
i = inport(port+1) !read status port  


Parallel port pins are as follows:

2,3,4,5,6,7,8,9 - Bits 0 to 7 of data port

1,14,16,17 - Bits 0 to 3 of output status port .XOR.11

13,13,12,10,11 Bits 3 t0 7 of input status port .XOR.128
0 Kudos
Reply