Thiết kế và lập trình hệ thống - Chương14

25 356 0
Tài liệu đã được kiểm tra trùng lặp
Thiết kế và lập trình hệ thống - Chương14

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Thiết kế và lập trình hệ thống - Chương

Systems Design & Programming Interrupts I CMPE 3101 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6InterruptsInterrupt processing is an alternative to polling.The Intel microprocessors support hardware interrupts through:• Two pins that allow interrupt requests, INTR and NMI• One pin that acknowledges,INTA, the interrupt requested on INTR.And software interrupts through instructions:• INT, INTO, INT 3, BOUNDControl is provided through• IF and TF flag bits• IRET and IRETDTimeExecuting task on the MicroprocessorMain programKeyboard ISRPrinter ISR Systems Design & Programming Interrupts I CMPE 3102 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6Interrupt Vector TableINT and INT3 behave in a similar way.INT n:Calls ISR located at vector n (n*4).The INT instruction requires two bytes of memory, opcode plus n.BOUND and INTO are both conditional.BOUND:AX is compared with DATA and DATA+1, if less than an interruptoccurs.AX is compared with DATA+2 and DATA+3, if greater than an inter-rupt occurs.INTO:Checks the overflow flag (OF). If OF=1, the ISR is called.IRET removes 6 bytes from the stack, 2 for IP, 2 for CS and 2 for FLAGS.BOUND AX, DATA ;Compares AX with DATA Systems Design & Programming Interrupts I CMPE 3103 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6Interrupt Vector TableDivide errorSingle-stepNMI pin1-byte breakpointOverflow (INTO)BoundUndefined OpcodeCoprocessor not availDouble faultCoproc seg overrunInvalid task state segSegment not presentStack seg overrunGeneral protectionPage faultUnassignedCoprocessor error000H004H008H00CH010H014H018H01CH020H024H028H02CH030H034H038H03CH040H14-31 Reserved32-255 User defined080HSeg high Seg lowOffset highOffset lowByte 3 Byte 2 Byte 1 Byte 0The interrupt vector table is located inthe first 1024 bytes of memory ataddresses 000000H through 0003FFH.There are 256 4-byte entries (segmentand offset in real mode).012345678910111213141516 Systems Design & Programming Interrupts I CMPE 3104 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6Real Mode InterruptsAfter the execution of each instruction, the microprocessor determineswhether an interrupt is active by checking, in order: Other instruction executions Single-step NMI Coprocessor segment overrun INTR INTIf one or more of these conditions are present, then: FLAGS is pushed onto the stack Both the interrupt (IF) and trap (TF) flags ar e cleared, which disables theINTR pin and the trap or single-step feature. The CS and IP are pushed onto the stack. The interrupt vector contents are fetched and loaded into CS and IP andexecution resumes in the ISR. On IRET, CS, IP and FLAGS are popped.IF and TF are set to the state prior to the interrupt. Systems Design & Programming Interrupts I CMPE 3105 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6Real and Protected Mode InterruptsThe return address (CS/IP) is pushed onto the stack during the interrupt.The return address can point to: The next instruction. The offending (current) instruction.The latter case occurs for interrupts 0, 5, 6, 7, 8, 10, 11, 12 and 13.This makes it possible to try the instruction again.Protected Mode:The same interrupt assignments are made and the same sequence of opera-tions occurs in protected mode but the interrupt table is different.Instead, 256 interrupt descriptors are used in the interrupt descriptor table(IDT).Offset (A31-A16)PDPL0111000H01234567Segment SelectorOffset (A15-A0)Present Systems Design & Programming Interrupts I CMPE 3106 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6Hardware InterruptsThe INTR pin must be externally decoded to select a vector.Any vector is possible, but the interrupt vectors between 20H and FFHare usually used (Intel reserves vectors between 00H and 1FH).INTA is an output of the microprocessor to signal the external decoder toplace the interrupt number on data bus connections D7-D0.The INTR pin is set by an external device (8259A) and cleared in the ISR.The input is automatically disabled by the microprocessor once it is rec-ognized and re-enabled by IRET or IRETD instruction.Timing diagram of the handshake.INTRLOCKINTAD7-D0Vector number Systems Design & Programming Interrupts I CMPE 3107 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6Hardware InterruptsSimpliest method of generating an interrupt vector:D0D1D6D5D4D3D2D7VCCINTAno connectionLow databus27KAlways generates interruptvector FFH in responseto INTR. Systems Design & Programming Interrupts I CMPE 3108 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6Tri-state Buffer for Generating the Interrupt VectorD0D1D6D5D4D3D2D7INTALow databusVCC74ALS244Y1 .A1 .GGApplies interruptvector 80H inresponse toINTA. Systems Design & Programming Interrupts I CMPE 3109 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6An Example 82C55 Interrupt ConfigurationSTBD0D7KeyboardDAVASCII82C55D0D7A0A7B7B0C7C0CSD7-- D08IORCWait2RDWRA0A1ResetA0A1Reset16L8A3A4A5A7A8A6A9A10I1I10O1O8A0IOWCA11A13A14A12A15Y1 .A1 .GGINTRINTA Systems Design & Programming Interrupts I CMPE 31010 (April 24, 2002)UMBCU M B CUNIVERSITY OF MARYLAND BALTIMORE COUNTY1 9 6 6Handling more than 1 IRQIf any of IRQx goes low, the NAND goes low requesting an interrupt.Note that if more than one IRQ goes low, a unique interrupt vector is gener-ated and an interrupt priority needs to be defined.The Interrupt Vector table must be expanded to accommodate this.D0D1D6D5D4D3D2D7INTAVCC74ALS244Y1 .A1 .GGINTRIRQ0IRQ66 5 4 3 2 1 0 VectIRQs1 1 1 1 1 1 0 FEH1 1 1 1 1 0 1 FDH1 1 1 1 0 1 1 FBH1 1 1 0 1 1 1 F7H1 1 0 1 1 1 1 EFH1 0 1 1 1 1 1 DFH0 1 1 1 1 1 1 BFH [...]... being processed Set priority: allows the setting of the lowest priority interrupt (L2-L0) Non-specific EOI: Here, the ISR sets this bit to indicate EOI The 8259A automatically determines which interrupt was active and re-enables it and lower priority interrupts Specific EOI: ISR resets a specific interrupt request given by L2-L0 0 0 1 1 0 1 1 0 Programming the 8259A OCW2: A0 D7 D6 D5 D4 D3 D2 D1 D0 0 R SL... F Interrupts I M YLAND BA L 1966 U M B C AR 0 1 0 0 0 1 1 1 1 1 1 0 0 1 0 0 } Non-Specific EOI Command End of } Interrupt *Specific EOI Command Rotate on Non-Specific EOI Command Automatic Rotate on Automatic EOI Mode (Set) Rotation Rotate on Automatic EOI Mode (Clear) *Rotate on Specific EOI Command Specific }Rotation *L0-L2 are used *Set Priority Command No Operation CMPE 310 UMBC 20 (April 24, 2002)... Needed 0 = No ICW4 Needed SNGL IC4 D1 1 = Single 0 = Cascade Mode LTIM D3 UMBC 16 (April 24, 2002) LTIM indicates if IRQ lines are positive edge-triggered or level-triggered 1 = Level Triggered Mode 0 = Edge Triggered Mode X A0 ICW1: There are 4 ICWs At power-up, ICW1, ICW2 and ICW4 must be sent If ICW1 indicates cascade mode, then ICW3 must also be sent Programming the 8259A Programmed by Initialization... C AR 16L8 VCC D0 8259A IR0 A0 A1 A2 16550 CS0 D7 CS1 SIN CS2 SOUT MR BAUDOUT RD RCLK RD RTS WR CTS WR DTR ADS DSR XIN DCD RI XOUT OUT1 INTR OUT2 24 IR7 D7 A0 48H-49H CS RD CAS0 10K WR CAS1 SP/EN CAS2 INT INTA 40H-47H Serial Data Data Bus (D0-D7) UMBC INTR INTA RD WR A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 IO/M A11 A12 A13 A14 A15 IVERSITY O F D0 Interrupts I Interfacing 16550 UART using 8259A Systems Design... indicating the IRQ channels connected to master/slave 8259As These bits determine the vector numbers used with the IRQ inputs For example, if programmed to generate vectors 08H-0FH, 08H is placed into these bit positions ICW3: T7-T3 of Interrupt Vector Address (8086/8088 Mode) Low order bits are 0 since there are 8 interrupts Interrupts I A0 D7 D6 D5 D4 D3 D2 D1 D0 1 T7 T6 T5 T4 T3 X X X Programming... BUF D4 D1 1 D0 CMPE 310 1 = AUTO EOI 0 = NORMAL EOI 0 X Non-Buffered Mode 1 0 Buffered Mode:Slave 1 1 Buffered Mode:Master M/S AEOI D2 Interrupts I UMBC 18 (April 24, 2002) AEOI, if 1, indicates that an interrupt automatically resets the interrupt request bit, otherwise OCW2 is consulted for EOI processing Fully nested mode allows the highest-priority interrupt request from a slave to be recognized... INTA Connects to the INTA pin on the microprocessor A0 Selects different command words in the 8259A CS Chip select - enables the 8259A for programming and control SP/EN Slave Program (1 for master, 0 for slave)/Enable Buffer (controls the data bus transievers when in buffered mode) CAS2-CAS0 Used as outputs from the master to the slaves in cascaded systems Systems Design & Programming MO UN TI RE COUNT... 0400H and 0402H D7-D0 O1 O2 I16 I15 I14 I13 I12 I11 UMBC M/IO A0 A2 A3 A4 A5 A6 A7 A8 A9 A1 WAIT2 16L8 8259A Programmable Interrupt Controller A single 8259A connected in the 8086 Systems Design & Programming MO UN TI RE COUNT Y M YLAND BA L 1966 U M B C AR I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 O1 O2 I16 I15 I14 I13 I12 O3 16L8 A15 A14 A11 A10 UMBC M/IO A0 A2 A3 A4 A5 A6 A7 A8 A9 INTR INTA D7-D0 G Dir G Dir... Only one interrupt vector required 74ALS32 Daisy-Chained Mechanism for Multiple IRQs Systems Design & Programming MO UN TI RE COUNT Y Interrupts I CMPE 310 M YLAND BA L 1966 U M B C AR Connect either to devices or to upstream slave 8259As UMBC 12 (April 24, 2002) CS and WR must be decoded Other connections are direct to micro Bidirectional Connect to any 8-bit bank IVERSITY O F D0 IR0 D1 IR1 8259A IR2... 0 = No Poll Command P D3 Interrupts I Indicates which status register, IRR or ISR, is to be read CMPE 310 UMBC 21 (April 24, 2002) There are three status registers, Interrupt Request Register (IRR), In-Service Register (ISR) and Interrupt Mask Register (IMR) IRR: Indicates which interrupt request lines are active ISR: Level of the interrupt being serviced IMR: A mask that indicates which interrupts . priority interrupt (L2-L0).D1D0D3D2D5D4D7D6A00 R EOISL 0 0 L2L1L00 0 10 1 11 011 0 00 0 01 1 11 100 1 0Non-Specific EOI CommandRotate on Non-Specific EOI Command*Specific. error000H004H008H00CH010H014H018H01CH020H024H028H02CH030H034H038H03CH040H1 4-3 1 Reserved3 2-2 55 User defined080HSeg high Seg lowOffset highOffset lowByte 3 Byte

Ngày đăng: 15/11/2012, 11:07

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan