Interrupt processing based on IRQ in ARM

Publisher:CreativeMindLatest update time:2020-09-03 Source: elecfansKeywords:ARM  IRQ Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Startup interrupt vector table

;*******************************************************************************

; ExcepTIon vectors

;*******************************************************************************

LDR PC, Reset_Addr; address is 0x8000 0000

LDR PC, Undefined_Addr

LDR PC, SWI_Addr

LDR PC, Prefetch_Addr

LDR PC, Abort_Addr

NOP ; Reserved vector

LDR PC, IRQ_Addr

LDR PC, FIQ_Addr

; *******************************************************************************

; ExcepTIon handlers address table

;*******************************************************************************

Reset_Addr DCD __program_start ; the address is 0x8000 0020

Undefined_Addr DCD UndefinedHandler

SWI_Addr DCD SWIHandler

Prefetch_Addr DCD PrefetchAbortHandler

Abort_Addr DCD DataAbortHandler

DCD 0 ; Reserved vector

IRQ_Addr DCD IRQHandler

FIQ_Addr DCD FIQHandler

;*******************************************************************************

; Peripherals IRQ handlers address table

;*******************************************************************************

PRCCUCMU_Addr DCD PRCCUCMUIRQHandler; the address is 0x8000 0040

For embedded systems, the code generated above is usually placed in the flash at address 0x8000 0000 (the sector is also remapped to 0x0000 0000). The addresses of __program_start, UndefinedHandler, etc. are placed in the instruction buffer pool. This allows global jumps. According to the ARM instruction length, the physical address of the address of __program_start is 0x8000 0020. According to the ARM pipeline, LDR PC, Reset_Addr generates assembly language instructions such as LDR PC, [PC, #24].


When an IRQ interrupt occurs, the program jumps to the IRQHandler.

IRQHandler

IRQHandler

SUB lr,lr,#4 ; Update the link register

SaveContext r0,r12 ; Save the workspace plus the current

; return address lr_ irq and spsr_irq.

LDR lr, =ReturnAddress; Read the return address.

LDR r0, =EIC_base_addr

LDR r1, =IVR_off_addr

ADD pc,r0,r1 ; Branch to the IRQ handler.

ReturnAddress

; Clear pending bit in EIC (using the proper IPRx)

LDR r0, =EIC_base_addr

LDR r2, [r0, #CICR_off_addr] ; Get the IRQ channel number

CMP r2,#31

subhi r2, r2, #32

MOV r3, #1

MOV r3,r3,LSL r2

STRHI r3,[r0, #IPR1_off_addr] ; Clear the corresponding IPR bit.

STRLS r3,[r0, #IPR0_off_addr] ; Clear the corresponding IPR bit.

RestoreContext r0,r12 ; Restore the context and return to the.。。

; 。。.program execuTIon.


Among them, EIC_base_addr is 0xFFFF FC00, and the address of IVR is 0xFFFF FC18. By executing the instructions in this register, you can enter the corresponding interrupt service program. This register can be set when installing the interrupt vector service program. For example, if the value of the IVR register is 0xE59FF468, it means LDR PC, [PC, #1128]. In fact, it jumps to the TImer2 interrupt service program defined in the instruction buffer.


Interrupt Vector Register and Source Interrupt Registers Settings

extern u32 PRCCUCMU_Addr;

u8 Counter=0;

u32 Offset = (u32) & PRCCUCMU_Addr; //PRCCUCMU_Addr address is 0x8000 0040

u32 Tmp=0;

/* IVR = high half of load PC instruction (LDR PC,) */

EIC-》IVR = 0xE59F0000; //0xE59F0000, according to the instruction format, indicates an unsigned

//The instruction is executed, which transfers the value to the destination register PC.

//F in the instruction means r15, i.e. PC

/* Read the offset of the interrupt vectors table address */

Offset = (Offset + 0x3E0) < < 16; // Why do we need to add 0x3E0 to the offset address?

//0x8000 0040 + 0x3E0 《《 16 = 0x0420 0000,

//After an interrupt occurs, the high 16 bits of SIR will be passed to the low

//16bit is used as the offset address, and the IVR address is 0xFFFF FC18

//0xFFFF FC18 + 0x420 + 0x8 (pipeline impact) =

//0x1 0000 0040, since ARM is 32 bits, it is

//0x40 (this address is also mapped to 0x8000 0040)

/* Initialize SIRn registers with the equivalent low half of load PC instruction */

for(Counter=64; Counter!=0; Counter--)

{

EIC-》SIRn[64-Counter] = Offset|0xF0000000; //Why 0xF000 0000? It is because LDR PC, [PC, #0ffset],

//The source register and the destination register are both PC

Offset += 0x00000004 《《 16;

}


The above program snippet sets IVR and SIRn, etc. In this way, when an IRQ interrupt occurs, the PC first jumps to 0xFFFF FC18, that is, the instruction LDR PC, [PC, #offset] in the IVR register is executed, and the address of the interrupt service routine is taken from the instruction buffer pool to the PC, thereby jumping to the interrupt service routine.

Keywords:ARM  IRQ Reference address:Interrupt processing based on IRQ in ARM

Previous article:Wireless meteorological data communication system based on ARM microprocessor and Linux
Next article:Design and implementation solution of GIS coal mine safety real-time monitoring system

Recommended ReadingLatest update time:2024-11-16 13:30

ARM cortex-M4 DAP access method summary
The implementation of cortex-M debug is coresight cortex-M4 belongs to cortex-M  Cortex-M4/M1 has only one DP (although it can be implemented as multiple, but once implemented, there is only one DP) and one AP (only one can be implemented, which is AHB-AP) Access to JTAG-DP registers 1. Go through the IR chain and s
[Microcontroller]
Arm China clarifies Huawei incident: never out of stock, still cooperating
Note: The article header image and the images within the article were taken by the author himself. Recently, Huxiu conducted an exclusive interview at Arm China's Shanghai office. In this interview, Liang Quan, Arm China spokesperson and head of the marketing department, clarified some details of the previous Huawe
[Semiconductor design/manufacturing]
Arm China clarifies Huawei incident: never out of stock, still cooperating
ARM instruction suffixes and commonly used read instructions
1: Optional suffix for instructions "S" suffix: When the "S" suffix is ​​used in an instruction, the conditional flag of the status register will be refreshed after the instruction is executed; when the "S" suffix is ​​not used, the conditional flag of the status register will not change after the instruction is execu
[Microcontroller]
ARM instruction suffixes and commonly used read instructions
ARM2440 for LCD
Change the original 3.5-inch resolution from 240x320 to 480x272 Timing settings: CLKVAL=4 (VCLK =10) 5 VCLK 12 Each dot scanning cycle         VSPW = 10-1 2 tvp - typ:10 Vertical synchronization signal VBPD=2-1 2 tvb - typ: 2 How long does it work after the vertical sync signal LINEVAL=272-1 tvd :272 272 lines VFPD
[Microcontroller]
The difference between ARM instruction set and Thumb instruction set
1. Now let's distinguish between ARM instruction set and Thumb instruction set        Thumb instructions can be regarded as a subset of the compressed form of ARM instructions. They are proposed to address the problem of code density. They have a 16-bit code density but are not as efficient as ARM instructions. Thumb
[Microcontroller]
Working principle, algorithm and implementation of ARM single-power supply ECG detection module
The design given in this article uses a single power supply, which can solve the above problems and reduce product costs. At the same time, the design also uses a simple and practical algorithm in an embedded system based on the ARM core, which can quickly and accurately locate the QRS complex (that is, calculate the h
[Microcontroller]
Working principle, algorithm and implementation of ARM single-power supply ECG detection module
A simple explanation of ARM address remapping
Address remapping of ARM chip Mapping means one-to-one correspondence. Remapping is to reallocate this one-to-one correspondence. We can regard the memory as a black box with output and input ports. As shown in the figure below, the input is the address, and the output is the data stored at the corresponding address. O
[Microcontroller]
A simple explanation of ARM address remapping
Use jlink+gdbserver+insight to debug ARM program--Configure insight
1. Download insight-6.8a.tar.bz2 and compile: ./configure --target=arm-linux --prefix=/opt/insight_arm --disable-werror (1) --target=arm-linux will affect the name of the executable file generated by the installation. For example, the name of the executable file after installation is: caodan@caodan-Ubunt
[Microcontroller]
Use jlink+gdbserver+insight to debug ARM program--Configure insight
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号