Information Technology Reference
In-Depth Information
which is based at address 21h. The bit for IRQ7 is the most significant bit, and it must be set
to a 0 to enable the interrupt. As with the serial port, the end of interrupt signal must be
acknowledged by setting the EOI signal bit of the interrupt control register (ICR) to a 1. See
Section 8.5.2 for more information on these operations .
The interrupt on the parallel port is caused by the ACK line (pin 10) going from a high to
a low (just as a printer would acknowledge the reception of a character). For this interrupt to
be passed to the PIC then bit 4 of the control port (IRQ Enable) must be set to a 1.
16.5.3 Example program
Program 16.5 is a simple interrupt- drive n parallel port Borland C program. The program in-
terrupts the program each time the ACK line is pulled LOW. When this happens the output
value should change corresponding to a binary count (0000 0000 to 1111 1111, and then
back again). The user can stop the program by pressing any key on the keyboard. Figure 16.7
shows a sample set-up with a push button connected to the ACK line and LEDs connected to
the output data lines.
5 V
5 V
330
330
9
D7
2
D0
5 V
10 K
10
ACK
GND
Figure 16.7
Example set-up for interrupt-driven parallel port
Program 16.5
/* Program to sample data from the parallel port */
/* when the ACK line goes low */
#include <stdio.h>
#include <bios.h>
#include <conio.h>
#include <dos.h>
#define TRUE 1
#define FALSE 0
#define DATA 0x378
#define STATUS DATA+1
#define CONTROL DATA+2
#define IRQ7 0x7F /* LPT1 interrupt */
 
Search WWH ::




Custom Search