cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030 hardfault only during debug mode

davidDev
Associate

Hi, I'm getting a hard fault on MX_TIM1_Init() but only during debug sessions. When I set a breakpoint after initialization, then I can step through and everything works. Why is this happening? 

3 REPLIES 3
AScha.3
Chief II

> Why is this happening? 

-> You do something wrong. 

If you feel a post has answered your question, please click "Accept as Solution".
TDK
Guru

It's difficult to provide a useful response with such limited information.

Stay objective. The first step would be to look at where the hard fault happens. Use a hard fault monitor to understand why it is happening.

Avoid the temptation to think that if an error doesn't occur, then the program is correct. Or to somehow believe that because it sometimes runs, the problem must be with something other than the code. If something isn't working, the most common culprit is the code. The second most common is the hardware (bad power supply, bad schematic design, improper assembly/soldering, etc.). Everything else is much less likely.

If you feel a post has answered your question, please click "Accept as Solution".

Have the Hard Fault Handler output actionable data. Dumping registers and state.

Perhaps the IRQ Handler, or HAL, has expectations that the instance is fully initialized, via MSP, or wherever, prior to the IRQ firing?

CM0(+) also more fussy about memory access alignments.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..