Complete the code to define a HardFault handler function in ARM Cortex-M.
void HardFault_Handler(void) {
while([1]) {
// Stay here to indicate fault
}
}while(0) which never loops.The HardFault handler typically loops infinitely to halt the system when a hard fault occurs. Using while(1) creates an infinite loop.
Complete the code to enable the MemManage fault handler in the System Control Block (SCB).
SCB->SHCSR |= [1];To enable the MemManage fault handler, set the MEMFAULTENA bit in the SHCSR register.
Fix the error in the UsageFault handler declaration to match ARM Cortex-M conventions.
void [1](void) {
// Handler code
}The correct ARM Cortex-M handler name is UsageFault_Handler with an underscore.
Fill both blanks to check if a BusFault is active and clear its status in the SCB.
if (SCB->CFSR & [1]) { SCB->CFSR |= [2]; }
The BusFault status bits are checked and cleared using SCB_CFSR_BUSFAULTSR_Msk.
Fill all three blanks to create a dictionary that maps fault names to their active status bits.
fault_status = {
"[1]": SCB->CFSR & [2],
"[3]": SCB->CFSR & SCB_CFSR_MEMFAULTSR_Msk
}This dictionary maps the fault names 'BusFault' and 'UsageFault' to their respective status bits in the CFSR register.
