B&B Electronics PPIO manual Mask Value

Page 22

The parallel port’s status register stores the upper nibble (four bits) of the input line status. Since the smallest value that can be read from the port is a byte, some work must be done to get only the upper nibble’s value. We read a byte from the status register and bitwise AND it with F0h (240 decimal, 11110000 binary). This sets the lower nibble of the byte to zero.

The parallel port’s control register stores the low nibble of the input line status. A method, similar to the one used to get the high nibble, extracts the low nibble. We read a byte from the control register and bitwise AND it with 0Fh (15 decimal, 00001111 binary). This sets the upper nibble of the byte to zero.

Now, combine both bytes into one value by bitwise ORing them together. This value is stored in the variable Input_Byte. At this point, the upper nibble of Input_Byte is the same as the upper nibble of the status register and the lower nibble of Input_Byte is the same as the lower nibble of the control register.

To return the status of a specific line, a test is done to determine the state of the line’s corresponding bit stored in Input_Byte. To determine the bit’s state, all other bits of Input_Byte are set to zero. This is done by bitwise ANDing Input_Byte with the mask value of the desired line shown in the following table.

Mask Value

Line

Hex

Decimal

Binary

0

01h

1

00000001

1

02h

2

00000010

2

04h

4

00000100

3

08h

8

00001000

4

10h

16

00010000

5

20h

32

00100000

6

40h

64

01000000

7

80h

128

10000000

20

PPIO2899 Manual

B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104

Image 22
Contents Not Recommended for New Installations Table of Contents Introduction Packing List PC Parallel Port Description Page BIT PPIO2899 Manual Ppio Description & Connection PPIO2899 Manual Controlling the Ppio Using Gwbasic Bit Force I/O on Force I/O OFF Low High Page Controlling the Ppio Using Pascal BeginElse Mask Value Function OutputBit BitNumberBYTE Byte Procedure SetOutputBit BitNumber,OutputBYTE XOR Controlling the Ppio Using C Void SetIRQOffvoid Outport ControlAddress Mask Value Page Page New PPIO2899 Manual Page Interfacing to the Ppio PPIO2899 Manual Example USE of the Ppio Page REM IB is the Input Byte and OB is the Output Byte Hexadecimal Numbers AppendixBinary Numbers