Information Technology Reference
In-Depth Information
D7
Busy
Reserved
D6
ACK
Reserved
D5
PE
Direction
D4
SELECT
IRQ ENABLE
D3
ERROR
SELECT INPUT
D2
IRQ
INIT
D1
Reserved
AUTOFEED
D0
Reserved
STROBE
Data
port
Status
port
Control
port
Figure 16.3
Port assignments
Program 16.2
#define DATA 0x378
#define STATUS DATA+1
#define CONTROL DATA+2
int main(void)
{
int out1,out2;
out1 = 0x55; /* 0101 0101 */
_outp(DATA, out1);
out2 = 0x0D; /* 0000 1101 */
_outp(CONTROL, out2); /* STROBE=LOW, AUTOFEED=HIGH, etc */
return(0);
}
The setting of the output value (in this case, out2 ) looks slightly confusing as the output is
the inverse of the logical setting (that is, a 1 sets the output low). An alternative method is to
exclusive-OR (E X-OR) the outp ut v alue with $B which will invert the 1st, 2nd and 4th least
significant bits (
AUTO =1, and STROBE =0), while leaving the 3rd
least significant bit (INIT) untouched. Thus the following will achieve the same as the previ-
ous program:
=0,
SELECT
INPUT
FEED
out2 = 0x06; /* 0000 0110 */
_outp(CONTROL, out2 ^ 0xb); /* STROBE=LOW, AUTOFEED=HIGH, etc */
If the 5th bit on the control register (IRQ enable) is written as 1 then the output on this line
will go from a high to a low which will cause the processor to be interrupted.
The control lines are driven by open collector drivers pulled to +5 Vdc through 4.7 k
resistors. Each can sink approximately 7 mA and maintain 0.8 V down-level.
 
Search WWH ::




Custom Search