cancel
Showing results for 
Search instead for 
Did you mean: 

Investigating HardFaultException

paul
Associate II
Posted on November 26, 2009 at 16:46

Investigating HardFaultException

4 REPLIES 4
paul
Associate II
Posted on May 17, 2011 at 12:29

I am getting HardFaultExceptions somewhere in my code for my printf to USART1. This uses DMA to transfer the string to the UART.

My question is how can I find out where this hard fault is occurring. It is a race condition occurring between something and is very frustrating as when I use JTAG to debug the race condition doesn't occur.

Is there a way to find out the reason for the HardFaultException (is there a status register?) Can I view things like the PC before the hardfault, as the context saving is done by the Cortex hardware.

I have tried reading the datasheet and reference manual for any mention of faults and I haven't found anything. Any tips would be great.

Regards Paul

paul
Associate II
Posted on May 17, 2011 at 12:29

Thank you for the link Paul.

This was the exact document that I have been looking for. It explains the whole exception and NVIC paths, exactly what I need. (and more)

Now just to find this pesky bug....

paulsmitton9
Associate III
Posted on May 17, 2011 at 12:29

Yes - the hard fault status register, but you will probably have to check a few other registers until you get to the cause of your problem, which may take a while.

They are all detailed in the ARM Cortex M3 Technical Reference Manual:

http://infocenter.arm.com/help/topic/com.arm.doc.ddi0337e/DDI0337E_cortex_m3_r1p1_trm.pdf

I had a hard fault problem (see forum) and found that it was a read of a bad memory address, and eventually found a register containing the address of the offending code.

mujahid
Associate II
Posted on May 17, 2011 at 12:29

Paul,

I am having a similar problem with my code, which incurs a HardFault during a printf to USART1. Did you ever find the source of the hardfault or were you able to mitigate it somehow?

Apologies for reviving this year-old-thread.

Here are the details of my issue.

http://www.st.com/mcu/forums-cat-9181-23.html

Thanks!