AnsweredAssumed Answered

How to debug code freeze in STM32F401

Question asked by l.d.001 on Mar 5, 2014
Latest reply on Mar 10, 2014 by l.d.001
Hi,
I am running my own code on STM32F401 Discovery board.
Sometimes (pretty rarely) the code freezes.
I added sufficient logging to HardFault_Handler, but it is not executed.
I am not sure, but most likely the code runs some loop with interrupts disabled.
I cannot send any input to it, cannot print stack or examine registers, nothing.

I thought of using NMI, but it appears that STM32F401 has no mean
of invoking NMI externally. The manual says that NMI is invoked
when "HSE clock happens to fail", but how can I make it to happen to fail?

I also searched this forum and saw advise "use JTAG",
which in case of STM32F401 Discovery would translate to "use SWD", but I cannot figure out how to connect to a running board without resetting it.
I am using latest IAR EWARM 6.70. It has Debug option "Attach to running target", but it does not work. It shows message "The debugging session could not be started ..."
But if I disable "Attach to running target", then debugger always resets MCU and stops at main.

So, please, tell me how do you debug freezes on STM32F401 Discovery board or similar?
I would prefer to use NMI rather than debugger if possible.

Thank you



Outcomes