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

How to skip the instruction causing exception in Cortex M

Hello, Sir,

If an instruction such as LDR or STR causing BusFault or MMFault and if I log the exception and clear the error flags and let the software resumes to run, the instruction causing this exception will be executed again. So again the same exception handler is entered and executed again.

Do you have example code to skip this instruction causing the exception so that the application software can resume running?
I can change the PC stored in the stack and when restore the context, the PC is changed to the instruction after the error instruction.
This looks fine. But the difficulty is I cannot tell whether the error instruction is a 16-bit instruction or a 32-bit instruction.
Do you have any suggestions?
I can find out all the LDR and STR instructions encoding in the ARM reference manual and check the first few bits of these instructions to tell it's 16-bit or 32-bit.
Is there any recommended method?

Thank you.
Jason Yang