For example:
Output_Byte = 01010101b
Line_Number = 3
Status = 1
00000001b | (1 decimal) |
|
|
00001000b |
| ||
| XOR | 11111111b |
|
|
| 11110111b (mask 1) | |
| AND | 01010101b | (Output_Byte) |
00000001b | (Status) | 01010101b |
|
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)
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