140 likes | 555 Views
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 D 0 to D 7 for most outputs D 7 is the most significant bit We output all eight bits at once
E N D
The centronics port Interfacing to a PC
Connection Devices are connected to the parallel port (LPT) using a 25-way D-connector.
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
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)
Inputting • To look at the input from the ERROR pin we need to input from the input port S=INP(&h379) S is now equal to 9FH
Masking • All the bit other than D3 need to be ignored – this is called masking
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
Code for inputting and masking S=INP(&h379) S=S AND &h08 IF S=0 THEN … IF S>0 THEN …