B&B Electronics PPIO manual New

Page 25

For example:

Output_Byte = 01010101b

Line_Number = 3

Status = 1

00000001b

(1 decimal)

 

 

shift-right 3 (Line_Number) =

00001000b

 

 

XOR

11111111b

 

 

 

11110111b (mask 1)

 

AND

01010101b

(Output_Byte)

00000001b

(Status)

01010101b

 

shift-right 3(Line_Number) = OR

00001000b

(mask 2)

 

 

01011101b

(New

 

 

 

Output_Byte)

The function, Toggle(), is used to toggle the status of an output line. If the specified line is ON, it will be turned OFF. If it is OFF, it will be turned ON. The function is defined as:

void Toggle (unsigned char Line_Number)

{

Output_Byte = Output_Byte ^ (1 << Line_Number); outport (Base_Address, Output_Byte);

}

To produce a mask value, 00000001b is shifted right by the desired line number. The mask value is exclusive ORed with Output_Byte to produce the new value of Output_Byte. Then it is written to the parallel port.

For example:

Output_Byte = 01010101b

Line_Number = 3

00000001b (1 decimal)

shift-right 3 (Line_Number) = 00001000b (mask)

XOR 01010101b (Output_Byte) 01011101b (New

Output_Byte)

PPIO2899 Manual

23

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

Image 25
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 Begin Controlling the Ppio Using PascalElse 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 Appendix Hexadecimal NumbersBinary Numbers