cancel
Showing results for 
Search instead for 
Did you mean: 

Set the FAULTMASK bit and then execute a command that triggers a HardFault

cnc_designer
Associate II

I set the Faultmask bit to 1 with the following code snippet and then write 0x5A to an area outside of RAM and read it back.

Since the Faultmask is set to 1, a HardFault does not occur, but the command line I have highlighted is also not being executed.

The processor is not responding at all; I am executing these commands step by step in the debug menu or I want to pause the processor by setting a breakpoint

What could be the cause of the problem? What state might the processor have entered?

 

MOV R0, #1
MSR FAULTMASK, R0

LDR R0, =0x20002800  ;  The address 0x20002800 is outside the RAM area.  
MOV R1, #0x5A
STRB R1, [R0]
LDRB R1, [R0] ; !!! PRODUCE HARD FAULT !!! But FAULTMASK BIT=1

MOV R0, #0
MSR FAULTMASK, R0

3 REPLIES 3
cnc_designer
Associate II

In this line, the processor enters a loop: LDRB R1, [R0]; !!! PRODUCE HARD FAULT !!! But FAULTMASK BIT=1

I want the next command following this instruction to be executed.

Perhaps you can increment the PC in the stacked context and return from the Hard Fault?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I need to know whether the instruction is 16-bit or 32-bit. In this example, I can determine how many bits the instruction has, but I don't like this solution. I need a general solution