23 uint32_t cfsr = scb->
CFSR;
35 record->
r0 = frame[0];
36 record->
r1 = frame[1];
37 record->
r2 = frame[2];
38 record->
r3 = frame[3];
39 record->
r12 = frame[4];
40 record->
lr = frame[5];
41 record->
pc = frame[6];
42 record->
xpsr = frame[7];
Fault driver: enable the configurable faults and record a fault for the debugger.
void faultEnable(ScbRegisters_t *scb)
Give MemManage, BusFault and UsageFault their own handlers, and trap integer division by zero.
void faultCapture(FaultRecord_t *record, const ScbRegisters_t *scb, const uint32_t *frame, uint32_t exc_return)
Fill record from the fault status registers and the stacked frame.
FaultRecord_t faultRecord
Filled by Fault_Handler; read it from the debugger.
#define SCB_SHCSR_BUSFAULTENA
Enable BusFault (otherwise it escalates to HardFault).
#define SCB_CFSR_MSTKERR
MemManage: fault while stacking on exception entry.
#define SCB_ICSR_VECTACTIVE_Msk
<span class="regaccess">ro</span> Number of the active exception (0 in Thread mode).
#define SCB_SHCSR_USGFAULTENA
Enable UsageFault (otherwise it escalates to HardFault).
#define SCB_CFSR_STKERR
BusFault: fault while stacking on exception entry.
#define SCB_CCR_DIV_0_TRP
Trap divide by zero.
#define SCB_SHCSR_MEMFAULTENA
Enable MemManage (otherwise it escalates to HardFault).
#define SCB_ICSR_VECTACTIVE_Pos
Bits 8:0.
uint32_t bfar
BFAR; the fault address only if CFSR.BFARVALID.
uint32_t exception
ICSR.VECTACTIVE: 3 HardFault, 4 MemManage, 5 BusFault, 6 UsageFault.
uint32_t lr
Stacked LR: the faulting function's return address.
bool frame_valid
The registers below were read from the stacked frame.
uint32_t pc
Stacked PC: the faulting instruction, or the next one for an imprecise fault.
uint32_t mmfar
MMFAR; the fault address only if CFSR.MMARVALID.
uint32_t xpsr
Stacked xPSR.
uint32_t exc_return
LR on entry; bit 2 set means the frame is on PSP.
uint32_t cfsr
CFSR: MMFSR (7:0), BFSR (15:8), UFSR (31:16).
uint32_t hfsr
HFSR: FORCED means a configurable fault escalated.
volatile uint32_t BFAR
0x38: BusFault address
volatile uint32_t CCR
0x14: configuration and control
volatile uint32_t MMFAR
0x34: MemManage fault address
volatile uint32_t HFSR
0x2C: HardFault status
volatile uint32_t CFSR
0x28: configurable fault status (MMFSR, BFSR, UFSR)
volatile uint32_t ICSR
0x04: interrupt control and state
volatile uint32_t SHCSR
0x24: system handler control and state