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
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.
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....
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.