Information Technology Reference
In-Depth Information
16.4 I/O addressing
16.4.1 Addresses
The printer port has three I/O addresses assigned for the data, status and control ports. These
addresses are normally assigned to:
Printer Data register
Status register
Control register
LPT1 378h
379h
37ah
LPT2 278h
279h
27ah
The DOS debug program can be used to display the base addresses for the serial and parallel
ports by displaying the 32 memory location starting at 0040:0008 . For example:
-d 40:00
0040:0000 F8 03 F8 02 00 00 00 00- 78 03 00 00 00 00 29 02
The first four 16-bit addresses give the serial communications ports. In this case, there are
two COM ports at address 03F8h (COM1) and 02F8h (for COM2). The next four 16-bit ad-
dresses gives the parallel port addressees. In this case there is two parallel ports. One at
0378h (LPT1) and one at 0229h (LPT4).
16.4.2 Output lines
Figure 16.3 shows the bit definitions of the registers. The data port register links to the out-
put lines. Writing a 1 to the bit position in the port sets the output high, while a 0 sets the
corresponding output line to a low. Thus to output the binary value 1010 1010b (AAh) to the
parallel port data then using Visual C++:
_outp(0x378,0xAA); /* in Visual C this is _outp(0x378,0xAA); */
The output data lines are each capable of sourcing 2.6 mA and sinking 24 mA; it is thus es-
sential that the external device does not try to pull these lines to ground.
The c ontrol port also contain s five output lines, of which the lower four bits are
STROBE ,
SELECT , as illustrated in Figure 16.3. These lines
can be used as either control lines or as data outputs. With the data line, a 1 in the register
gives an output high, while the lines in the control port have inverted logic. Thus a 1 to a bit
in the register causes an output low.
, INIT and
AUTO
FEED
INPUT
Program 16 .2 outputs the binary pat tern 0101 0101b (55h) to the data lines and sets
INPUT
AUTO =1, and STROBE =0, the value of the data port will
be 55h and the value written to the control port will be XXXX 1101 (where X repre sents
don't care). The value for the control output lines must be invert, so that the STROBE line
will be set to a 1 so that it will be output as a LOW.
=0, INIT=1,
SELECT
FEED
 
Search WWH ::




Custom Search