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 that it has 7 working modes. Let's first look at how the initialization code initializes the stack in different modes.
/* IRQMODE。 */
orr r1,r0,#0x12|0xc0
msr cpsr,r1
ldr sp,=IRQ_MODE_SP_START
This code initializes the stack for IRQ mode so that the stack can be used when an IRQ interrupt occurs.
The interrupt process of S3C44B0 is as follows:
when an interrupt occurs, it will jump to the address 0x18 in FLASH to fetch an instruction and execute it. Because only one instruction is allowed there, only a jump instruction can be placed. For example: ldr pc,=0x0c000018, this instruction jumps to SDRAM to run, which means fetching an instruction from 0x0c000018 to run. In fact, I always put a jump instruction at that address, so that it goes to the corresponding interrupt handler. For example, there is a:
b irq, this instruction jumps to the IRQ interrupt handler, and its function is to further search for different interrupt handlers according to different interrupt sources. Its code is as follows:
/*
Use IRQ interrupt to find the entry function address of each interrupt and jump to the corresponding entry function to run.
*/
irq:sub sp,sp,#4 /* reserve a stack for PC */
stmfd sp!,{r8-r9}
ldr r9,=I_ISPR /* read interrupt source register */
ldr r9,[r9]
cmp r9, #0x0 /* If no interrupt source occurs, exit. */
beq IDLE_IRQ
mov r8,#0x0 /* Calculate the interrupt program location corresponding to the interrupt source */
LOOP_IRQ:
movs r9,r9,lsr #1
bcs HAVE_IRQ
add r8,r8,#4 /* Each interrupt entry occupies 4 bytes*/
b LOOP_IRQ
HAVE_IRQ:
ldr r9,=CONFIG_SDRAM_START+4*8 /* From HandleADC interrupt entry */
add r9,r9,r8
ldr r9,[r9]
str r9,[sp,#8] /* Save to the previously reserved SP location*/
ldmfd sp!,{r8-r9,pc} /* Jump to interrupt program execution. */
IDLE_IRQ: /* No interrupt processing. */
ldmfd sp!,{r8-r9}
add sp,sp,#4
subs pc,lr,#4
The function of this code is to first take out the interrupt source flag from the interrupt source storage register I_ISPR of S3C44B0, and then continuously shift to determine whether there is an interrupt at this bit, and if there is an interrupt, handle it. According to the shift, the interrupt entry address is calculated, and in this way, the interrupt entry function can be changed dynamically. CONFIG_SDRAM_START+4*8, this is the interrupt entry function base address, if there is an interrupt at the first bit, it is an ADC interrupt.
Then just jump to this address and run it.
For example, if I use the TICK interrupt of S3C44B0, which is the time slice
interrupt, I will set the entry function at the corresponding address and use the following code:
///
...
//Input parameters:
//Output parameters:
//
Return value:
//
Developer: Cai Junsheng
//
Time: 2006/02/13
//Modification notes
:
//
///
...
The above statement sets an interrupt entry function as a time slice function. When there is a TICK interrupt, it will run in the time slice function.
In summary, writing an interrupt handler for S3C44B0 requires the following work:
1. Place a jump instruction at 0x18 in FLASH to jump to SDRAM.
2. Place a jump instruction at 0x0c000018 in SDRAM to jump to the IRQ subroutine.
3. Write an IRQ handler.
4. Write a function to handle the actual interrupt source.
5. Set the interrupt register and clear the interrupt source mask bit.
Previous article:Learn ARM development(18)
Next article:Learn ARM development(16)
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- MSP430 MCU Development Record (6)
- Is there a suitable chip/solution for converting 24V to positive and negative 15V?
- Hikvision responds to US ban: All components used have alternatives
- How to implement BLUENRG1/2 Bluetooth MESH and BLE REMOTE at the same time?
- Using ESP's rtc memory in mpy
- Does the PIC32MZ DA series have an FPU?
- Comprehensive electrical skills from entry level to mastery
- Linux serial communication 1——96-N-8-1 format
- [STM32WB55 Review] Summary
- 1000 posts, commemorating