Understand ARM interrupt principles and interrupt nesting

Publisher:草木知秋Latest update time:2022-04-06 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

ARM has seven modes, we are here to discuss SVC, IRQ and FIQ modes

usr (user mode), fiq (fast interrupt mode), irq (interrupt mode), svc (supervisory mode), abt (data access termination mode), sys (system mode), und (undefined instruction abort mode)


① We assume that the ARM core has two interrupt pins (actually invisible), one is called irq pin and the other is called fiq pin. In the ARM cpsr, there is an I bit and an F bit, which are used to disable IRQ and FIQ respectively.

Write the picture description here

② Let's not talk about the interrupt controller, just talk about the ARM core. Under normal circumstances, the ARM core just mechanically follows the instructions of the PC to do things. When the I and F bits in the CPSR are 1, IRQ and FIQ are all in a disabled state. No matter what kind of interrupt signal you send on the irq pin and fiq pin, ARM will not pay attention to you, and you can't interrupt it at all, because it is "deaf" and "blind".


③ When the I bit and F bit are 0, when an interrupt signal comes from the irq pin, the current work of the arm will be interrupted, and the IRQ mode will be switched to the corresponding exception vector table (vector) position to execute the code. This process is automatic, but you have to do it yourself to return to the place where the interrupt was interrupted.


④ When you jump to the exception vector table and are in IRQ mode, if an interrupt signal comes from the irq pin again, ARM will ignore you. The irq pin is like a secretary, and the ARM core is like a boss. The boss is working, and then a customer comes. The secretary interrupts and lets the customer in. If another customer comes, either the secretary keeps knocking on the door to ask, or the customer leaves. The boss will ignore you if he has not finished meeting with the first customer.


⑤ But there is an exception. When ARM is in IRQ mode, an interrupt signal comes from fiq pin. What is fiq pin? Fast interrupt, just like the police come to investigate criminal cases. They don’t care whether the boss is meeting with customers or not. They interrupt directly, enter fiq mode, and jump to the corresponding fiq exception vector table to execute code. If the police come again when ARM is processing FIQ mode, there will be no hope. They are all law enforcement officers. You can’t stop me. What if irq pin comes at this time? I will ignore it. I am investigating a case. How dare they interfere with public affairs?


Conclusion: IRQ mode can only be interrupted by FIQ mode, and no one can interrupt FIQ mode.

If the interrupt is not working, it is useless to use irq pin or fiq pin to send interrupt signal.

Except for fiq being able to interrupt irq, there is no so-called interrupt nesting.


But after all, the irq pin and fiq pin together only have 2 pins. How to deal with so many interrupt sources? It is impossible for everyone to knock on the door directly.


Next, let's talk about who sends the signal to the irq pin or fiq pin. As you can see from the above, it may be the boss, the customer, or the police. In ARM, this matter is managed by the interrupt controller.


Ⅰ. Take the simplest 2410/2440 interrupt controller as an example. The interrupt controller plus a sub-interrupt controller and an external interrupt controller manage more than 50 interrupt resources, that is, more than 50 pins. Except for the external interrupt, these pins have specified functions, such as WDT, LCD, DMA, etc. This function cannot be changed because the internal hardware connection of 2410/2440 has been determined.


Ⅱ. When both WDT and DMA interrupts come, they will be sent to the SRCPND register. Both interrupts are in it. Which one should be sent to ARM? At this time, first look at INTMOD, which is the interrupt mode register: which interrupt is set as a fast interrupt, which one will be sent up; what if both are set as fast interrupts? This is impossible, because only one interrupt can be set as a fast interrupt at the same time. Therefore, if there is a fast interrupt, at this time, send an interrupt signal directly to the fiq pin to interrupt ARM.


III. If there is no fast interrupt, then check INTMSK to see if WDT and DMA are blocked. If DMA is blocked in INTMSK, only WDT continues to send upward. If neither is blocked, then they both enter the priority register PRIORITY at the same time. Here, according to the priority setting, a high priority and a low priority will be separated. The one with a high priority is sent to the INTPND register, so INTPND has only one interrupt in it at any time. As long as there is an interrupt in INTPND, the irq pin will not keep sending interrupt signals to ARM. When it is sent for the first time, it interrupts ARM. At this time, ARM enters the corresponding exception vector and is in IRQ mode.


IV. At this time, INTPND still continuously sends interrupt signals to ARM through irq pin, but ARM is already in IRQ mode and will not respond to you. When you have finished processing the interrupt and want to exit IRQ mode, be careful. If you do not clear the interrupt bit in INTPND before exiting IRQ mode, you will be interrupted again just after exiting IRQ mode, because INTPND has been sending interrupt signals. Therefore, be sure to clear the interrupt bit in INTPND before exiting IRQ mode.


Ⅴ. It is not enough to just clear the bits in INTPND, because the WDT and DMA interrupts are in SRCPND. When you just clear INTPND, another interrupt is selected in SRCPND and sent to INTPND. So the correct way to handle it is to clear the corresponding interrupt bit in SRCPND before exiting IRQ mode, and then clear the corresponding bit in INTPND. Please note that there may be multiple bits in SRCPND, so just clear the interrupt you have handled, but there may only be one bit in INTPND, so just clear it directly.


Let's talk about Linux.

1. Linux does not use FIQ, only IRQ. But sometimes an interrupt needs to be processed for a long time. Do we need to occupy IRQ mode for that long? No, Linux simply records what interrupt it is in IRQ mode and immediately switches back to SVC mode. In other words, Linux interrupt processing is all processed in SVC mode.


2. So how does the interrupt number come from? It is fixed on ARM, and there is only one way to get the corresponding interrupt number: query irqs.h. First, register an interrupt handler with an interrupt number. When an interrupt occurs, how does Linux know that it is an interrupt with this interrupt number? When processing an interrupt, first read INTPND, and then read EINTPEND or SUBSRCPND as needed to calculate an interrupt number. The corresponding processing algorithm is in the macro get_irq_nr_base. The interrupt number in irqs.h is calculated according to this algorithm.

Keywords:ARM Reference address:Understand ARM interrupt principles and interrupt nesting

Previous article:[Supplement] Detailed analysis of the s3c2440 startup process
Next article:s3c2440_soc.h

Recommended ReadingLatest update time:2024-11-16 14:32

Lesson 1: The clock system of ARM chips
Note: The following content is learned from the first video tutorial of ARM bare metal by teacher Wei Dongshan 1. Introduction to 2440 clock 1.1 2440 is a SOC (system on chip) system, which not only has many CPUs, but also many peripherals. The system framework diagram in the 2440 chip manual is as follows: In the 2
[Microcontroller]
Lesson 1: The clock system of ARM chips
From PC bus to ARM internal bus
When I was studying Chapter 9 and Hardware Communication in "Linux Device Drivers (3rd Edition)", I was not very clear about the concept of IO bus, so I looked for relevant information. Now I summarize it as follows: References for this article: 1. "Introduction to AMBA, AHB, APB Buses" Author: adamzhao Date: 2006-11
[Microcontroller]
Design of virtual instrument based on CAN bus and MiniGUI using ARM+Linux architecture
Today, fully digital automotive instruments are widely used in developed countries, and most of them are stepper motor automotive instruments, and are ready to develop in a higher direction. Due to cost constraints, domestic automotive instrument displays can only use field display screens, and cannot use dot matrix sc
[Microcontroller]
Design of virtual instrument based on CAN bus and MiniGUI using ARM+Linux architecture
Arm TechCon 2019 highlights
The annual Arm TechCon was held this year, with experts from major technology giants around the world gathering together to discuss future technology trends and policy directions. In the past few years, Arm has been committed to the "fifth wave of computing" - the integration of artificial intelligence, the Internet o
[Embedded]
Arm TechCon 2019 highlights
Implementation of Ad Hoc Network Platform Based on ARM
Functional Overview     Due to the characteristics of Ad Hoc network, such as no center and dynamic topology, it requires each node to have routing and forwarding functions. The Ad Hoc network node developed in this paper realizes the data packet forwarding function by transplanting the routing protocol on the ARM p
[Microcontroller]
Implementation of Ad Hoc Network Platform Based on ARM
Embedded development ARM system code solidification serial port implementation
Early embedded programs adopted the development model of "programming-burning-modification-burning", and a lot of time was consumed in repeatedly burning chips, which increased development costs and R&D cycles. Later, it developed to the emulator stage. Although the development model was simplified, due to factors s
[Microcontroller]
Embedded development ARM system code solidification serial port implementation
[ARM bare metal program][7] ARM instruction classification learning
Arithmetic shift registers and logic instructions MOV transfer MOV{condition}{S} dest , op 1 dest = op_1 MOV loads a value from another register, a shifted register, or an immediate value to the destination register. You can also specify the same register to implement the NOP instruction. For example: MOV R0, R0. M
[Microcontroller]
Learn ARM development(17)
Because all embedded systems use interrupts, how does my S3C44B0 interrupt process? Then I need to understand the whole process. To understand it in depth, the best way is to write a program and then debug it continuously. Before this program, you must first have a deep understanding of ARM's interrupt mode and know
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号