2019-05-31 06:36 AM
I am facing hard fault handler isssue.
I was wondering if someone will help me to resolve it.
I am unable to find the cause.
I am using STM32F4 series controller and while free run it is going to hard fault handler.
I checked the corresponding register and I found Precise data access error in bus fault status register.
How to resolve this error I don't know please help.
2019-05-31 06:59 AM
First, check the LR. It should contain "exception return code". It should be mostly 'FF's, like 0xFFFFFFFD.
The last digit tells the return stack and return mode. If the last digit is 1, it pulls the return stack frame from main stack and returns to handler mode.
If the last digit is 9, it pulls the return stack frame from main stack and returns to thread mode, and if D means process stack and thread mode.
Next, find the return address from the return stack: SP + 0x18.
Maybe that helps? It's probably busfault escalated into hard fault because bus faults are not enabled. That happens often, if you access address that is in the "reserved" area. You can check the BFAR register for that.
2019-05-31 07:26 AM
>>How to resolve this error I don't know please help.
Look at the faulting instruction(s) and the processor registers. Determine what memory you're touching that is causing it, and what your code at the failure point is doing.