This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#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++;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Any ideas?

0