The initial code is familiar to everyone, the most basic interrupt jump
b ResetHandler
b HandlerUndef ;handler for Undefined mode
b HandlerSWI ;handler for SWI interrupt
b HandlerPabort ;handler for PAbort
b HandlerDabort ;handler for DAbort
b . ;reserved
b HandlerIRQ ;handler for IRQ interrupt
b HandlerFIQ ;handler for FIQ interrupt
The jump label is a series of macros
LTORG
HandlerFIQ HANDLER HandleFIQ
HandlerIRQ HANDLER HandleIRQ
HandlerUndef HANDLER HandleUndef
HandlerSWI HANDLER HandleSWI
HandlerDabort HANDLER HandleDabort
HandlerPabort HANDLER HandlePabort
This macro is implemented at the beginning of the file and does some pre-jump processing. As follows:
MACRO
$HandlerLabel HANDLER $HandleLabel
$HandlerLabel
sub sp,sp,#4 ;decrement sp(to store jump address)
stmfd sp!,{r0} ;PUSH the work register to stack(lr does't push because it return to original address)
ldr r0,=$ HandleLabel;load the address of HandleXXX to r0
ldr r0,[r0] ;load the contents(service routine start address) of HandleXXX
str r0,[sp,#4] ;store the contents(ISR) of HandleXXX to stack
ldmfd sp! ,{r0,pc} ;POP the work register and pc(jump to ISR)
MEND
Take HandleIRQ jump as an example to illustrate the secondary jump process of interrupt. The above macro code shows that IRQ jumps to the label HandleIRQ, which is defined as follows: (a series of interrupts and secondary interrupt entry addresses)
AREA RamData, DATA, READWRITE
^ _ISR_STARTADDRESS; (This value is defined by yourself, it is the address of the interrupt vector table)
HandleReset # 4
HandleUndef # 4
HandleSWI # 4 HandlePabort #
4 HandleDabort
# 4
HandleReserved # 4
HandleIRQ # 4
HandleFIQ # 4
;Don't use the label 'IntVectorTable',
;The value of IntVectorTable is different with the address you think it may be.
;IntVectorTable (secondary IRQ interrupt vector table)
HandleEINT0 # 4
HandleEINT1 # 4
HandleEINT2 # 4
HandleEINT3 # 4
HandleEINT4_7 # 4
HandleEINT8_23 # 4
HandleRSV6 # 4
HandleBATFLT # 4
HandleTICK # 4
HandleWDT # 4 HandleTIMER0 # 4 HandleTIMER1
# 4 HandleTIMER2 # 4 HandleTIMER3 # 4 HandleTIMER4 # 4 HandleUART2 # 4 HandleLCD # 4 HandleDMA0 # 4 HandleDMA1 # 4 HandleDMA2 # 4 HandleDMA 3 # 4 HandleMMC # 4 HandleSPI0 # 4 HandleUART1 # 4 HandleRSV24 # 4 HandleUSBD # 4 HandleUSBH # 4 HandleIIC # 4 HandleUART0 # 4 HandleSPI1 # 4 HandleRTC # 4 HandleADC # 4
And HandleIRQ is assigned by the following code, and it can be seen that it jumps to IsrIRQ:
dr r0,=HandleIRQ ;This routine is needed
ldr r1,=IsrIRQ ;if there isn't 'subs pc,lr,#4' at 0x18, 0x1c place interrupt jump
str r1,[r0]
IsrIRQ ;The real IRQ interrupt entry
sub sp,sp,#4 ;reserved for PC to set aside a location to save the interrupt entry address
stmfd sp!,{r8-r9}
ldr r9,=INTOFFSET
ldr r9,[r9] ;Read the interrupt offset code
ldr r8,=HandleEINT0 ;The first address of the secondary jump table
add r8,r8,r9,lsl #2 ;R8=R8+R9X4 to get the corresponding interrupt entry address
ldr r8,[r8]
str r8,[sp,#8] ;The interrupt entry address is sent to SP (the 4-byte space reserved by the first code)
ldmfd sp!,{r8-r9,pc}
So far, the interrupt has been successfully entered into the interrupt vector table, and it has become very simple to write a service program in C language. For example, the ISR of the EINT0 interrupt
void Eint0(void)
{ }
pISR_EINT0=(U32)Eint0; //Use the interrupt entry to point to the function pointer.
Previous article:UART test program based on s3c2410 development board
Next article:s3c2410 Timer
Recommended ReadingLatest update time:2024-11-17 00:46
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Want to make an embedded machine learning wearable system
- Web front-end/back-end matters, non-technical issues!
- A large bounce occurs on the DC power supply
- For four-layer boards, high-power routing issues
- Multi-input six-level energy efficiency standard
- LIS3DH evaluation board STEVAL-MKI105V1 data
- TMS320C6748 DSP Development Kit (LCDK)
- [RVB2601 Creative Application Development] 6. Online Weather Clock Draft Version
- [Silicon Labs BG22-EK4108A Bluetooth Development Review] Part 3: Bluetooth-Soc Blinky Example Development Experience
- Analysis of the effect of resistance between the be electrodes of PNP transistors