Recovering from a hard fault cortex M3

Hi,

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

int main(void)
{
    SCB->SHCSR |= 0x00007000; // enable Usage Fault, Bus Fault, and MMU Fault
    SCB->CCR |= 0x18; // enable div-by-0 and unaligned fault

    int i=0;
    static int test;



    test = (*(unsigned int *)0x678000000);
    while(1)
    {
        i++;
    
    }

}


int value;
void HardFault_Handler (void)
{
    int r1,;
    value=r1;
    
    __asm
    {

    }
}

Any ideas?

Parents
  • Hi Mike,

    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.

Reply
  • Hi Mike,

    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.

Children
No Data