Meaning
Diagnostic hardware registers in ARM Cortex-M microcontrollers provide detailed information about the cause of processor faults. This 32-bit register is subdivided into three bytes that capture memory management faults, bus faults, and usage faults. During debugging, the configurable fault status register helps locate the instruction or memory access that triggered the exception.
Diagnostic Capability
Developers read this register when the processor enters a hardfault handler due to an unhandled exception. Examining the contents reveals whether a divide-by-zero, unaligned access, or memory violation occurred.
Hardware Mechanism
The register consists of three separate sub-registers grouped together for easier access during a processor exception. Memory management faults are recorded in the lowest byte, which tracks access violations like trying to execute code from a non-executable memory region. Bus faults are captured in the middle byte, tracking errors that occur during data transfers on the system bus.
Usage faults occupy the upper half-word, showing execution errors such as undefined instructions or illegal state transitions. Hardware automatically sets these flags when a fault occurs, and firmware must write a one to the respective bits to clear them.
Firmware Exception
Operating systems and bare-metal applications utilize this data to implement self-recovery or diagnostic logging. Instead of halting execution, the system can extract the value, save it to persistent storage, and restart the microcontroller.