Connection Devices are connected to the parallel port (LPT) using a 25 -way D-connector.
Pinout of centronics port
Outputs l l l We use D 0 to D 7 for most outputs D 7 is the most significant bit We output all eight bits at once D D 6 D D 4 D 3 D D D 7 1 l 5 0 0 1 1 2 1 0 0 To get this output send 10011100 (binary), 156 (decimal) or 9 C (hex) to the output port
Address l l The output port is at address 378 H Outputs use the command: OUT address, data Hexadecimal numbers can be written using &h at the start You can send 9 CH to the output port using: OUT &h 378, &h 9 C
Inputs l l l The inputs are at address 379 H The inputs can be read using INP(address) INP(&h 379) behaves like a variable and has a value that depends on the inputs so is used in statements like this: S=INP(&h 379)
Addresses of pins
Inputting l To look at the input from the ERROR pin we need to input from the input port S=INP(&h 379) D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 BUSY ACK PE SLCT ERR OR Not used 1 0 0 1 1 1 S is now equal to 9 FH
Masking • All the bit other than D 3 need to be ignored – this is called masking D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 BUSY ACK PE SLCT ERROR Not used 1 0 0 1 1 1
Making the mask • The function AND is used for masking • Put 0 s where you want the bits to be ignored • If D 3 is 0 the answer is zero • If D 3 is 1 the answer is not zero AND Answer D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 BUSY ACK PE SLCT ERROR Not used 1 0 0 0 0 1 1 0 0 Hex 9 F 08 08
Code for inputting and masking S=INP(&h 379) S=S AND &h 08 IF S=0 THEN … IF S>0 THEN …