Skip to main content
Visitor II
September 24, 2024
Question

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

  • September 24, 2024
  • 1 reply
  • 1770 views

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

    This topic has been closed for replies.

    1 reply

    Visitor II
    September 25, 2024

    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.

    Graduate II
    September 25, 2024

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

    Visitor II
    September 25, 2024

    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