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

SVC instruction execution inside the hard fault handler

Hello everyone,

Processor : Arm Cortex-m4

For an experiment, I purposely triggering hard fault exception, by making T-bit in Execution Program Status Register to 0. The program execution control reaches hard fault handler.

Inside the hard fault handler I was triggering SVC instruction using "__asm volatile ("SVC #0");". After executing this line, system goes reset. 

May I know the reason.

Parents
  • It is hard to say just from the description above. Do you fix the T-bit (via debugger?) after the Hard Fault?

    Looking at similar cases I found, there were suggestions to set breakpoint on the entry of the SVC handler to see if you ever even reach that point? If your target supports trace, getting an execution log could be invaluable.

    If this happening on a real MCU? It may be that there is additional logic triggering a reset if multiple hard-faults are occurring, as it detects something has gone wrong? (this is just a guess - I'm not aware of any particular device that does this).

Reply
  • It is hard to say just from the description above. Do you fix the T-bit (via debugger?) after the Hard Fault?

    Looking at similar cases I found, there were suggestions to set breakpoint on the entry of the SVC handler to see if you ever even reach that point? If your target supports trace, getting an execution log could be invaluable.

    If this happening on a real MCU? It may be that there is additional logic triggering a reset if multiple hard-faults are occurring, as it detects something has gone wrong? (this is just a guess - I'm not aware of any particular device that does this).

Children