User guide
Chapter 2. Communication
67
Bits 0, 1, 2 and 3 of the AT6nnn status register can be used to identify the interrupt. For
example, if the AT6nnn general-purpose interrupt is enabled, then check bit 2 of the AT6nnn
status register to see if a general-purpose interrupt occurred.
/* test for AT6nnn general purpose interrupt */
if(int_enable & GP_INTERRUPT) && (inp(address+4) & GP_INTERRUPT))
{
process_gpint(); /* process the interrupt */
outp(address+4, 0x44); /* clear the interrupt */
}
Important
Considerations
Keep in mind that when processing interrupts, you should minimize the amount of time spent
in the interrupt service routine. If you do not, your background processing will suffer.
The interrupt must be cleared prior to exiting the ISR. If you do not clear the interrupt, the
PC-AT will be continually interrupted by the same interrupt.
The AT6nnn output-buffer-has-data interrupt is cleared simply by fetching data from the
AT6nnn output data buffer. Likewise, the AT6nnn input-data-buffer-empty interrupt is cleared
by sending data to the AT6nnn input data buffer and a "data ready" command (0x42) to
the AT6nnn status register.
The AT6nnn general-purpose interrupt is cleared by sending a "clear general purpose
interrupt" command (0x44) to the AT6nnn status register.
The AT6nnn status-update interrupt is cleared by requesting another status update via the
"update status request" command (0x48).
Before exiting the ISR, you must send an "end-of-interrupt" command (0x20) to the
8259 command register. If you are using an interrupt on the second 8259, you must send
0x20 to both 8259s in the PC-AT (see below).
/* send EOI to 8259 */ outp(0x20, 0x20);
➄ Disable
Interrupts in
the AT6nnn
You must next disable all interrupt sources from the AT6nnn. This is accomplished by
writing to the AT6nnn interrupt enable register (AT6nnn base port address + 4). Setting the
Master Interrupt Enable bit to Ø will disable all AT6nnn interrupts (as follows).
#define MASTER 0x10 /* Master Interrupt Enable mask */
int_enable = int_enable & ~MASTER;
outp(address+4, int_enable);
➅ Restore
Original
Interrupt
Vector
Before exiting your program, use function 25H of INT 21H to restore the original interrupt
vector that was previously saved at the beginning of your program.
/* Restore original interrupt vector */
inregs.h.ah = 0x25; /* Function 25H */
inregs.h.al = int_num; /* Interrupt number */
segregs.ds = oldseg; /* Get segment */
inregs.x.dx = oldoff; /* Get offset */
intdosx(&inregs, &outregs, &segregs); /* Call INT21H */
➆ Exit
Program
If you have completed steps 1 through 6 above, you may now exit the program.










