About interruption
A complete interrupt process is composed of the interrupt request, the interrupt, and the mask, interrupt response, interrupt processing, and interrupts return five parts.
In the 8086/8088 microcomputer system, the priority of the interrupt source is sequentially: divided by zero, INT N, INT O, NMI (non-mask interrupt), INTR, single-step execution interrupt.
8259A chip external characteristics:
(1) Slices Selection Signal (CS)
(2) Write signal (WR)
(3) Read signal (RD)
(4) D0 ~ D7: 8 data bus
(5) GND: ground signal
(6) VCC: 5V power supply
(7) INT: Interrupt request signal
(8) Interrupt response signal
(9) IR0 ~ IR7: 8 interrupt request input signal
(10) A0: address selection signal
(11) SP / EN: Signboard / Allow Buffer Signals
(12) CAS0 ~ CAS2: These three signals are the 8259A level of the master-slave-degree-oriented structure of 8259A.
When the CPU completes the initialization operation of 8259A, the 8259A enters the operational state, and the interrupt application is proposed to the CPU through the INT port. 8259A outputs the interrupt type N6 model n of the current service object from the data bus D7 ~ D0, and the CPU intercends the interrupt vector and responds. Interrupt, complete an interrupt operation.
In the IBM PC and its compatible machine, a 16-level interrupt is provided by the NMI (unshielded interrupt) and two 8259a programmable interrupt controller chips, and the hardware interrupt structure is constituted as shown in Figure 1. The master-slave grade control structure is connected to the CPU, and the next layer is referred to as the sheet, from the sheet interrupt request signal INT to the IRQ2 of the main piece. The interrupt number whose IBM PC is retained will be freely programmed with IRQ10, IRQ11, IRQ12, and IRQ15, which are on the 1259A from the 12259a.
The 16-level interrupts managed by 8259A have a predetermined interrupt vector storage address in the IBM PC. The IRQ0-IRQ7 in the main sheet corresponds to 08H-0FH, respectively from the IRQ8-IRQ 15, respectively, 70H-77H, respectively (such as serial port 1 corresponds to 0CH) (12), save the original interrupt vector with OldVect = GetVect (0x0B)). The interrupt control register ICR and the interrupt shield register IMR of the main film are 20 h and 21h, respectively, from the corresponding register port addresses of the sheets being A0H and A1H, respectively.
When the interrupt initialization programming, when IRQ0-IRQ7 in the main piece, only the corresponding interrupt is opened in the mask register, in the interrupt service, the interrupt control register ICR sends an interrupt command EOI.
Ordinary interrupt procedure
Void Interrupt (* Vect_com) (...); // Set the original interrupt vector save pointer
Void Interrupt Receiver (...)
{
{CH = inportb (0x3f8)}; // receive data statement
OUTPORTB (0x21, 0x20); // Send the interrupt end command EOI (0x21) to the main piece interrupt shield register 0x21;
}
When the serial port 1 interrupts initialization, you must first save the original interrupt vector stored in the address (0x0c) stored in the serial port 1, and then load its own interrupt service program entry address.
Void Seropen (Void)
{
Vect_com = getvect (portf 8); // Interrupt initialization to get the old interrupt vector disable ();
InportB (PortadDR RXD);
Inportb (Portaddr MSR);
InportB (PortadDR LSR);
InportB (PortadDR IIR);
OUTPORTB (PortadDr Ier, Ierv);
OUTPORTB (PortadDr MCR, OUT2 | ERTS | EDTR);
OUTPORTB (iMaskReg, IMASKREG) & (~ (1 << Portf))); // 0x21 is the main piece interrupt shield register entry address / / action: Open
/ * ALSO
Temp = Inport (iMaskReg) & (~ (1 << portf)); // Open the main piece IRQ4;
Outportb (iMaskReg, Temp);
* /
SetVect (Portf 8, Receiver);
ENABLE ();
}
Finally, don't forget to turn off the front and restore the original interrupt vector in the program.
Void Serclose (Void)
{
disable ();
OUTPORTB (Portaddr Ier, 0); // Off Interrupt Reputation Register
Outportb (portaddr mcr, 0); // Offset demodulator control register
OUTPORTB (IMASKREG, IMASKREG) | (1 << portf)); // Offs the main film IRQ4
ENABLE ();
SetVect (portf 8, vect_com);
}