HI,currently i am working on project based on stm32f407 chip.my development work has been stopped since two days as i have stuck in hard fault handler. Please guide me how to trace the fault ???i tried every possible way i could.but result in nothing.Pls help me out.thanks in advance
hi ,thanks for prompt reply.by looking at code snippet you sent it gives me status of FSR's and i already have that status. in CFSR IACCVOL bit is set which states somewhat instruction access violation.now my question is my code is written in c how do i troubleshoot which instruction violating access rule when looking into diassembly section.
I believe you would like to "get" the actual PC that made the hardfault and not the current PC.
As the stm32f407 is based on Cortex-M4, I believe, you may find the misbehave PC point by looking at the LR register and decide if the PSP or MSP is
the actual stack that is important.
Then open Memory window and and ump MSP or PSP according to LR.
You will find the PC at address (MSP or PSP) + 6 dwords
All of that can be done from the debugger at the hard-fault interrupt breakpoint.
I know a C code is better, but, writing that code is vital only if you plan to "have" lots of hard-faults ... :-)
If you use uVision, see application note 209 from Keil http://www.keil.com/appnotes/files/apnt209.pdf for debugging fault exceptions.
Chapter 12.5 of Joseph Yiu´s book "The definitive Guide to ARM Cortex-M3 and Cortex-M4 Processors, 3rd Edition" explains how to analyze Fault Exceptions.
Cortex-M processors are designed to be programmed entirely in C, but fault exceptions is one of those shadow areas where assembler instructions knowledge is required, at least for debugging.