Using the control lines for additional i/o, Enabling the parallel port interrupt – Ampro Corporation LITTLE BOARD P5X User Manual
Page 46

2–28
;----------------------------------------------------------
; Code to set the parallel port mode to bi-directional
;----------------------------------------------------------
MOV
AH,0CDh
; AMPRO command
MOV
AL,0Ch
; AMPRO function
MOV
BX,01h
; Extended mode (use 00 to set output-only mode)
INT
13h
Within bi-directional mode, the port can be in its input state or output state. The code shown above
leaves the port in its input state. An IN instruction of I/O address 378h reads the current state of
the data lines.
To change the port between input and output states, write a 1 to bit five of the control register to
set the port to its input state; or a 0 to set it to its output state. Here is a code sample for
dynamically changing the port direction (after it is in Extended Mode).
;----------------------------------------------------------
; Code to change the parallel port direction to input
;----------------------------------------------------------
MOV
DX,37A
IN AL,DX
OR AL,20h
;set bit 5 (input)
OUT
DX,AL
;
;----------------------------------------------------------
; Code to change the parallel port direction to output
;----------------------------------------------------------
MOV
DX,37Ah
IN AL,DX
AND
AL,0DFh
;clear bit 5
OUT
DX,AL
Using the Control Lines for Additional I/O
Besides the eight data lines, you can use the four control lines (STB*, AUTOFD*, INIT*, and
SELIN*) as general purpose output lines. Similarly, you can use the five status lines (ERROR*,
SLCT, PE, ACK*, and BUSY) as general purpose input lines.
You can read the four control lines and use them as input lines. These lines have open collector
drivers with 4.7K ohm pull-ups. To use a control line as an input line, you must first write to its
corresponding bit in the control register. If the line is inverting (*), write a 0, otherwise write a 1.
This will cause the line to float (pulled up by the 4.7K ohm resistors). When a line floats, you can
use it as an input.
Enabling the Parallel Port Interrupt
Bit 4 in the Control Register enables the parallel port interrupt. If this bit is high 1, then a rising
edge on the ACK* (IRQ) line will produce an interrupt on the parallel port interrupt, IRQ7.