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