Skip to main content
paul
Associate
November 26, 2009
Question

Investigating HardFaultException

  • November 26, 2009
  • 4 replies
  • 985 views
Posted on November 26, 2009 at 16:46

Investigating HardFaultException

    This topic has been closed for replies.

    4 replies

    paul
    paulAuthor
    Associate
    May 17, 2011
    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

    paulsmitton9
    Associate III
    May 17, 2011
    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.

    paul
    paulAuthor
    Associate
    May 17, 2011
    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....

    mujahid
    Associate
    May 17, 2011
    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!