1 / 18

Interrupt Handling Advanced Interrupt Controller (AIC)

Interrupt Handling Advanced Interrupt Controller (AIC). ARM Core Interrupt Sources. The ARM processor has only 2 Interrupt lines IRQ (Normal Interrupt) Standard interrupt request FIQ (Fast Interrupt) Used for fast interrupt handling Private registers Initialization in C-startup

fahim
Download Presentation

Interrupt Handling Advanced Interrupt Controller (AIC)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interrupt HandlingAdvanced Interrupt Controller (AIC)

  2. ARM Core Interrupt Sources • The ARM processor has only 2 Interrupt lines • IRQ (Normal Interrupt) • Standard interrupt request • FIQ (Fast Interrupt) • Used for fast interrupt handling • Private registers • Initialization in C-startup • Last vector: directly accessible • Save the jump to the handler ARM Core IRQ FIQ

  3. ARM Interrupt Vectors • The interrupt vector is the first instruction executed by the ARM core when getting the interrupt • Stored at location 0x18 (IRQ) or 0x1C (FIQ) • Normally, jump is performed, either with instruction • B Interrupt_Service_Routine • Up to 32Mbytes accessible, much more than expected on SAM7 products • LDR pc, [pc, #Interrupt_Service_Routine] • PC relative, requires an additional 32-bit word • Full 4GBytes address space accessible • Interrupt_Service_Routine • The FIQ handler can be directly written

  4. Advanced Interrupt Controller (AIC) • The AIC is an ATMEL additional layer allowing the handling of up to 32 interrupt sources, coming either from the internal peripherals or from the interrupt input pins

  5. AIC Interrupt Sources External Interrupts • AT91SAM7S Example: • 16 sources • 1 System interrupt • 12 internal peripherals • 3 external sources: FIQ, IRQ0, IRQ1 • Two kinds of interrupt sources: • External (IRQx and FIQ pins): • High or Low Level Sensitive • Rising or Falling Edge Triggered • Internal (internal peripherals): • High Level Sensitive (recommended) • Rising Edge Triggered FIQ System Interrupt IRQ0 IRQ1

  6. What’s the System Interrupt ? • The wired-OR of all the sources coming from the System Controller’s peripherals, including: • Memory Controller • PIT • RTT • WDT • DBGU • PMC • RSTC • …

  7. How to manage the System Interrupt ? • By reading the Status Registers of all the system peripherals and check which interrupt(s) is/are pending: Void ISR_SystemInterrupt (void){ // PIT Timer Interrupt Processing status = PIT_SR & PIT_IMR; if (status != 0x0){ … } // DBGU Interrupt Processing status = DBGU_SR & DBGU_IMR; if (status != 0x0){ if ((status & TXRDY) != 0) {…} if ((status & RXRDY) != 0) {…} } }

  8. Interrupt Source 5 Common IRQ Handler LUT @ Fixed Address AIC_IVR Vector Address ARM Exception Vector Table Common IRQHandler ISR Source 1 Look-Up Table 0x18 ISR Source 5 ISR Source 32 Non-Vectored Interrupts Load PC withFixed Address

  9. Interrupt Source 5 AIC_SVR1 Vector 1 Address AIC_SVR5 Vector 5 Address AIC_SVR32 Vector 32 Address AIC_IVR Vector Address Vectored Interrupts Benefit ARM Exception Vector Table ISR Source 5 Load PC withVector Address 0x18

  10. AIC_ISR ARM Exception vectors AIC Interrupt vectors AIC Source vectors AIC_SVR31 0xFFFFF0FC AIC_SVR30 0x0000001C AIC_FVR FIQ 0xFFFFF104 0x00000018 AIC_IVR IRQ 0xFFFFF100 Index = ABORT (Data) Interrupt Id. ABORT (Fetch) SWI UNDEF RESET AIC_SVR1 AIC_SVR0 0xFFFFF080 AIC Automatic Vectoring Benefit • All sources are individually and dynamically vectored • Management for FIQ and IRQ are independent: • AIC_IVR returns the handler address of the current IRQ • AIC_FVR returns the handler address of the current FIQ • Handler addresses are saved in their corresponding Source Vector Register (AIC_SVRx)

  11. AIC IRQ Priority Management • The ARM Core IRQ line is controlled by an 8-level priority encoder • Each source has a programmable priority level of 7 to 0 (AIC_SMR). • Level 7 is the highest priority. • The AIC manages the IRQ prioritization by using an hardware internal stack on which the current interrupt level is: • Automatically pushed when AIC_IVR is read • Automatically popped when AIC_EOICR is written • No internal stack needed for FIQ (no prioritization)

  12. AIC Interrupt Handling • When an interrupt source is detected, the AIC asserts the ARM Core IRQ line: • The ARM Core is interrupted (automatic branch on ARM Vector 0x18) • The ARM Core enters its IRQ mode (IRQ are automatically disabled at core level) • The application must read the Interrupt Vector register (AIC_IVR) • By reading the AIC_IVR register, the AIC: • De-asserts the ARM Core IRQ line • Determines the highest level pending and enabled interrupt source • Pushes the level of the current interrupt in the AIC hardware stack • Clears the interrupt if it’s configured as edge triggered • Returns the vector corresponding to the current interrupt • The ISR can re-enable as soon as possible the interrupt at core level (nested interrupts) • A higher level interrupt can occur and restarts this sequence • The ISR Exit code must disable the interrupt at core level • Finally, the application must write the End Of Interrupt Command Register (EOICR) in the ISR Exit code • AIC pops from its hardware stack the current level

  13. AIC Interrupt Handling Example • IRQ P is interrupted by IRQ P+ which is interrupted by FIQ (nested interrupts)

  14. AIC Fast Forcing • Any interrupt sources can generate a Fast Interrupt • Keep in mind there is no priority management for FIQ • If several interrupts are forced Fast, each pending interrupt bit in AIC_IPR must be tested => less interesting than 1 single FIQ!!!

  15. The True Interrupt latency • Interrupt latency in a system might be affected by: • AIC External/Internal Interrupt latency (less than 5 cycles) • Return from Core Idle mode (max. 2 cycles) • PDC using the bus (<10 cycles in worst cases) • Interrupt Disabling • several hundreds/thousands of cycles depending on the tasks required for the interrupt to be masked That’s why it is so important to get Atomic Interrupt • Other interrupts handling • might be up to 100 cycles depending on the interrupt management policy Priority and Interrupt Nesting can improve a lot

  16. Interrupt Enable Register (IER) 0 1 Set Reset Q 1 Interrupt Mask Register (IMR) Set Reset 0 Q 0 1 Interrupt Disable Register (IDR) AT91 Single-cycle Bit Manipulation • ARM7TDMI processors do not provide any bit manipulation • Requires read-modify-write sequence of operations • AT91SAM series feature atomic bit set/reset facility for all peripheral control registers • Enabling or Disabling an interrupt is performed with only one instruction (store STR), thus is un-interruptible.

  17. AIC Debug Features • Spurious Interrupt Handling: • a Spurious Interrupt occurs when the ARM Core is interrupted and the source of interrupt has disappeared when IVR is read • This may occur: • By applying a pulse on an external interrupt signal programmed as level sensitive • By disabling an interrupt just at the time it happens • By double management (PDC and IRQ) • AIC_SPU register: returned when AIC detects a spurious interrupt ( when AIC_IVR is read)

  18. AIC Debug Features (cont.) • Protect Mode • Why? • If the AIC_IVR register is read by the debugger on a memory display window, it will corrupt interrupts handling processes. • As the debugger never writes AIC_EOICR, AIC may stay in an undefined state. • Activated by setting the PROT bit in the AIC Debug Control Register • The automatic operations performed by the AIC are now executed only when IVR is written: • AIC de-asserts the nIRQ line • AIC clears the interrupt if it’s edge triggered

More Related