I tried my best to get rid of the PXA270 interruptions in ads. Thanks to the embedded development on the internet, I found that the reading ability of English documents is really important and I should develop good work habits, for example, when developing an analyticdb program, you should read the analyticdb development manual. Based on this consideration, I will use my spare time to translate more authoritative documents for my work in the future. It is not so nice to practice English and learn technology!
Take the time to translate the _ IRQ section of the ADS development manual.
5.5.1 simple interrupt handlers in C
You can write simple C interrupt handlers by using the _ IRQ function declaration
Keyword. You can use the _ IRQ keyword both for simple one-level interrupt handlers,
And interrupt handlers that call subroutines. However, you cannot use the _ IRQ keyword
For reentrant interrupt handlers, because it does not cause the spsr to be saved or
Restored. In this context, reentrant means that the handler re-enables interrupts, and may
Itself be interrupted. See reentrant interrupt handlers on page 5-26 for more
Information.
The _ IRQ Keyword:
• Preserves all atpcs before uptible registers
• Preserves all other registers (excluding the floating-point registers) used by
Function
• Exits the function by setting the program counter to (LR-4) and restoring
CPSR to its original value.
If the function calla subroutine, _ IRQ preserves the link register for the interrupt mode
In addition to preserving the other extends uptible registers. See calling subroutines from
Interrupt handlers for more information.
Note
C interrupt handlers cannot be produced in this way using TCC. The _ IRQ keyword is
Faulted by TCC because TCC can only produce thumb code, and the processor is always
Switched to arm State when an interrupt, or any other exception, occurs.
However, the subroutine called by an _ IRQ function can be compiled for thumb,
Interworking enabled. See chapter 3 interworking arm and thumb for more
Information on interworking.
Calling subroutines from interrupt handlers
If you call subroutines from your top-level interrupt handler, the _ IRQ keyword also
Restores the value of lr_irq from the stack so that it can be used by a subs instruction
Return to the correct address after the interrupt has been handled.
Example 5-13 on page 5-25 shows how this works. The top level interrupt handler reads
The value of a memory-mapped interrupt controller base address at 0x80000000. If
Value of the address is 1, the top-level handler branches to a handler written in C.
Handling processor exceptions
Arm DUI 0056d copyright 1999-2001 arm limited. All Rights Reserved. 5-25
Example 5-13
_ IRQ void irqhandler (void)
{
Volatile unsigned int * base = (unsigned int *) 0x80000000;
If (* base = 1) // which interrupt was it?
{
C_int_handler (); // process the interrupt
}
* (Base + 1) = 0; // clear the interrupt
}
Compiled with ARMCC, Example 5-13 produces the following code:
Irqhandler proc
Stmfd SP !, {R0-r4, R12, LR}
MoV R4, #0x80000000
LDR r0, [R4, #0]
Sub sp, SP, #4
CMP r0, #1
Bleq c_int_handler
MoV r0, #0
STR r0, [R4, #4]
Add SP, SP, #4
Ldmfd SP !, {R0-r4, R12, LR}
Subs PC, LR, #4
Endp
Compare this with the result when the _ IRQ keyword is not used:
Irqhandler proc
Stmfd SP !, {R4, LR}
MoV R4, #0x80000000
LDR r0, [R4, #0]
CMP r0, #1
Bleq c_int_handler
MoV r0, #0
STR r0, [R4, #4]
Ldmfd SP !, {R4, PC}
Endp