PC MTH Interrupt Programming 8259 Initialization and Interrupt Server Processing 8259A Initialization and Interrupt Serve Program Processing for Higher Irq in IBM PC How to initialize the 8259 programmable interrupt controller and interrupt service program processing, which gives the 8259 initializer and interrupt service program instance written by Turbo C 3.0. Keywords 8259A programmable interrupt controller; IBM PC interrupt programming in IBM PC and its compatible machine, by CPU NMI (non-mask interrupt) and two 8259A programmable interrupt controller chips provide a 16-level interrupt, hardware The interrupt structure is shown in FIG. Connected. 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. For details on 8259A, please refer to the relevant manual. This article only lists the programming data not mentioned in most PC hardware manuals, and then explains the programming initialization process of the 8259A interrupt controller in the PC and how to process the interrupt service. Figure 1 of the 16-level interrupts managed by 8259A in the IBM PC have a predetermined interrupt vector storage address, and IRQ0-IRQ7 in the main sheet corresponds to 08H-0FH, respectively, from the IRQ8-IRQ 15, respectively, 70H-77H, respectively. 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 film, it is only necessary to open the corresponding interrupt in the mask register. In the interrupt service, the interrupt end command EOI; involves IRQ7-IRQ15 When the high number is interrupted, in addition to the corresponding interrupt in the mask register in the sheet, IRQ2 in the movie, and when the interrupt service is interrupted, send two EOI commands, respectively And from the film execution interrupt end command. The initialization of IRQ11 and the interrupt service program are given to the source code programming description of Turbo C. First, an interrupt pointer OldVect is to save the original interrupt vector, and after the interrupt service program ser_program (), the interrupt end signal EOI is transmitted to the main piece and the interrupt control register ICR of the main piece and the sheet. Void Interrupt (* OldVect) (...); file: // Set original interrupt vector save pointer Void Interrupt Ser_Program (...) {{... ...} file: // Interrupt service program code OUTPORTB (0xA0 , 0x20); file: // Send the EOI command OutportB (0x20, 0x20) from the sheet ICR; file: // Send the EOI command} interrupt to the main piece ICR to save the original interrupt vector of the address 73h store corresponding to the IRQ11. Then, then load your own interrupt service program entry address, then open the main piece IRQ2 and from the slice IRQ11, respectively.
Void interrupt_enable (void) {int Temp; {... ...} file: // Other initialization code OldVect = getVect (0x73); file: // Save the original interrupt vector setVect (0x73, ser_program); file: // Load the interrupt service program entry address TEMP = InportB (0x21) & 0xfb; // Open the main piece Irq2Outportb (0x21, temp); Temp = InportB (0xA1) & 0xf7; // Open from the slice IRQ11Outportb (0xA1, TEMP);} Finally, don't forget to turn off the front and restore the original interrupt vector in the program. Void Interrupt_Disable (void) {int Temp; set: // Restore the original interrupt vector TEMP = InportB (0x21) | ~ (0xfb); // Terminal Irq2Outportb (0x21, temp); TEMP = Inportb (0xA1) | ~ (0xf7); // Off-chip IRQ11Outportb (0xA1, TEMP);} Only the necessary source code for initialization and interrupt service processes, if interested, can be connected with the author The TURBO C source program (compiled under Turbo C 3.0) is used in Turbo C 3.0), and I use a multi-gate port when doing PC104. Reference 1 Thom Hojam (US). PC hardware and software technology data Daquan. Tsinghua University Press, 1990. ◆ Gong Jianwei Technology Home ◆ Serial Port Tongxun (Programming Source), serial debugging assistant, port network communication technology, VC / C programming, Mobile robot control related technology, MATLAB simulation and data processing