This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

exeption return

Can anyone halp me? I writting by assembler for stm32f051.So I can't return from exception handling (in my case this is timer update event). I have read exception entry and return from fucking programing manual:
"
Exception return occurs when the processor is in Handler mode and executes one of the following instructions to load the EXC_RETURN value into the PC:
â— a POP instruction that loads the PC
â— a BX instruction using any register.
"
The processor performs a vector fetch that reads the exception handler start address from
the vector table. When stacking is complete, the processor starts executing the exception
handler. At the same time, the processor writes an EXC_RETURN value to the LR.
"
I do this way and nothing happening:

TIM2_IRQHandler
    ...
    HANDLING!!!
    ...
    push {lr}
    pop {pc}


next way:

TIM2_IRQHandler
    ...
    HANDLING!!!
    ...
    bx lr


lr during the exception has value 0xFFFFFFF9. I have no idea what happens after the interrupt handling, but program don't execute after exception entry.
I aprciate any help.

Parents
  • You want the subroutine to return, you'd use blx, also you must push lr if you call another routine as it will destroy lr otherwise. Returning to 0xFFFFFFF9 is how it unstacks interrupt context, and from which stack.

    Correct form

    TIM2_IRQHandler
        push {lr}
        ...
        HANDLING!!!
        ...
        pop {pc}
    
    TIM2_IRQHandler
      IMPORT subroutine
       push {lr}
       ...
       handling
       ...
       ldr          r1, =TIM2
       ldr          r3, =~UIF   ;(UIF - rc_w0)
       str          r3, [r1, #TIM_SR]
    ;   bl           subroutine
       ldr          r0, =subroutine
       blx          r0 ; expect to come back
       ...
       pop {pc}
    

Reply
  • You want the subroutine to return, you'd use blx, also you must push lr if you call another routine as it will destroy lr otherwise. Returning to 0xFFFFFFF9 is how it unstacks interrupt context, and from which stack.

    Correct form

    TIM2_IRQHandler
        push {lr}
        ...
        HANDLING!!!
        ...
        pop {pc}
    
    TIM2_IRQHandler
      IMPORT subroutine
       push {lr}
       ...
       handling
       ...
       ldr          r1, =TIM2
       ldr          r3, =~UIF   ;(UIF - rc_w0)
       str          r3, [r1, #TIM_SR]
    ;   bl           subroutine
       ldr          r0, =subroutine
       blx          r0 ; expect to come back
       ...
       pop {pc}
    

Children