Dear People,
I am interested to use the Nested Interrupt in Software in a simple way shown in Examples, but in current RealView Tools it is not possible to access the Registers SP, LR, PSR via Inline Assembly with Assembler Macros. Macros for GCC and legacy Keil Tools:
// Macros for Interrupt Nesting #define IENABLE __asm { MRS LR, SPSR } __asm { STMFD SP!, {LR} } __asm { MSR CPSR_c, #0x1F } __asm { STMFD SP!, {LR} }
#define IDISABLE __asm { LDMFD SP!, {LR} } __asm { MSR CPSR_c, #0x92 } __asm { LDMFD SP!, {LR} } __asm { MSR SPSR_cxsf, LR }
Instead of the Macros, Mr. Dietmar Wengler developed the following Assembler Functions for Embedded Assembler:
nested_irq_enable: STMFD SP!, {R0} MOV R0, LR MRS LR, SPSR STMFD SP!, {LR} MSR CPSR_c, #0x1F STMFD SP!, {LR} BX R0
nested_irq_disable: MOV R0, LR LDMFD SP!, {LR} MSR CPSR_c, #0x92 LDMFD SP!, {LR} MSR SPSR_cxsf, LR MOV LR, R0 LDMFD SP!, {R0} BX LR
could you tell me how can i the call the nested_irq_enable and the nested_irq_disable in the c-Code. I use the Realview Compiler.
Thanks.
you can put them in a separate function:
void __asm disable(foo) { STMFD SP!, {R0} MOV R0, LR MRS LR, SPSR STMFD SP!, {LR} MSR CPSR_c, #0x1F STMFD SP!, {LR} BX R0
which you can call from C code (maybe it is not a bad idea to make this a SWI function).
Hello Micheal,
i get even so the error: #7: unrecognized token
Thanks
So use a token that is recognised, then!!
Replace the "foo" above with "void". Sorry...
I get 2x unrecognized token. the unrecognized tokens in that case are in place: STMFD SP!, {R0} and MOV R0, LR
Hello Michael, i made the function as SWI function:
void __swi(0) __asm nestedIrqEnable(void);
void __SWI_0 (void){
STMFD SP!, {R0}
MOV R0, LR
MRS LR, SPSR
STMFD SP!, {LR}
MSR CPSR_c, #0x1F
BX R0
} ===================================================== But i get the errors: Intrp.c(21): error: #20: identifier "STMFD" is undefined Intrp.c(21): error: #65: expected a ";" Intrp.c(25): error: #10: "#" not expected here Intrp.c(28): warning: #12-D: parsing restarts here after previous syntax error
try this syntax:
void __asm __swi(0) disable_interrupts(void) ; void __asm __SWI_0 (void)
View all questions in Keil forum