I'm new into mixing C and ASM on Cortex M3 using keil, here is the question,
Suppose that a function tries to access some memory that is not in the system, something like this, the system crashes with the hardfualt exception, so my question is why after executing the hardfault the program reenters the hardfault again, is there a way to simply return to the next instruction
here is my sample code
#include "LPC17xx.h" // Device header
SCB->SHCSR |= 0x00007000; // enable Usage Fault, Bus Fault, and MMU Fault
SCB->CCR |= 0x18; // enable div-by-0 and unaligned fault
static int test;
test = (*(unsigned int *)0x678000000);
void HardFault_Handler (void)
Firstly, this would be considered a MemManage fault. If it triggers a HardFault this is due to the MemManage faults being disabled in the System Handler Control and State Register, SHCSR, so the fault is escalated to a HardFault.
The same instruction is being fetched due to the processor being in lockup state.
This would be unrecoverable as the processor is dealing with a recurring exception with priority less than zero.