Nested Interrupt Question

Hi,

I have very long function that I want to be executed on time, even if other long functions (less important) are running in my main loop.

So my Idea was to write this function in an interrupt, that can be interrupted by my other, short interrupts (communication etc.)

I am trying to use the IENABLE and IDISABLE macros for the interruptable interrupt, but they don't seem to have any effect (or even cause crashes)

I'm using STR91FAM with uvision3 and ARM-ELF-GCC

Any ideas?

Parents
  • As far as I can recall, there macros apply to the Keil ARM compiler, not RealView.
    Maybe something like this will do, or maybe there are intrinsic functions to do it...?

    void __asm enable_nested_interrupts(void)
    {
        MOV     R0, LR
    
        MRS     LR, SPSR                ; Copy SPSR_irq to LR
        PUSH    {LR}                    ; Save SPSR_irq
        MSR     CPSR_c, #0x1F           ; Enable IRQ (Sys Mode)
        PUSH    {LR}                    ; Save LR
    
        MOV     LR, R0
    
        BX LR
    }
    
    void __asm disable_nested_interrupts(void)
    {
        MOV     R0, LR
    
        POP     {LR}                    ; Restore LR
        MSR     CPSR_c, #0x92           ; Disable IRQ (IRQ Mode)
        POP     {LR}                    ; Restore SPSR_irq to LR
        MSR     SPSR_cxsf, LR           ; Copy LR to SPSR_irq
    
        MOV     LR, R0
    
        BX LR
    }
    

    Note that I just scribbled this, and that you may be able to find a better solution rather than nested interrupts.

Reply
  • As far as I can recall, there macros apply to the Keil ARM compiler, not RealView.
    Maybe something like this will do, or maybe there are intrinsic functions to do it...?

    void __asm enable_nested_interrupts(void)
    {
        MOV     R0, LR
    
        MRS     LR, SPSR                ; Copy SPSR_irq to LR
        PUSH    {LR}                    ; Save SPSR_irq
        MSR     CPSR_c, #0x1F           ; Enable IRQ (Sys Mode)
        PUSH    {LR}                    ; Save LR
    
        MOV     LR, R0
    
        BX LR
    }
    
    void __asm disable_nested_interrupts(void)
    {
        MOV     R0, LR
    
        POP     {LR}                    ; Restore LR
        MSR     CPSR_c, #0x92           ; Disable IRQ (IRQ Mode)
        POP     {LR}                    ; Restore SPSR_irq to LR
        MSR     SPSR_cxsf, LR           ; Copy LR to SPSR_irq
    
        MOV     LR, R0
    
        BX LR
    }
    

    Note that I just scribbled this, and that you may be able to find a better solution rather than nested interrupts.

Children
More questions in this forum