Information Technology Reference
In-Depth Information
status register, inverts the BUSY bit and then shifts the bits three places to the right so that
the five inputs bit are in the five least significant bits.
Program 16.3
#include <stdio.h>
#define DATA 0x378
#define STATUS DATA+1
int main(void)
{
unsigned int in1;
in1 = _inp(STATUS); /* read from status register */
in1 = in1 ^ 0x80 /* invert BUSY bit */
in1 = in1 >> 3; /* move bits so that the inputs are the least
significant bits */
printf( Status bits are %d\n ,in1);
return(0);
}
16.4.4 Electrical interfacing
The output lines can be used to drive LEDs. Figure 16.6 shows an example circuit where a
LOW output will cause the LED to be ON while a HIGH causes the output to be OFF. For an
input an open push button causes a HIGH on the input.
5 V
330
D0-D7
5 V
10 K
Control
lines
GND
Figure 16.6
Interfacing to inputs and outputs
16.4.5 Simple example
Program 16.4 uses a push button connected to pin 11 (BUSY). When the button is open then
the input to BUSY will be a HIGH and the most significant bit in the status register will thus
be a 0 (as the BUSY signal is inverted). When the button is closed then this bit will be a 1.
 
Search WWH ::




Custom Search