STM32F030 hardfault only during debug mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-15 10:59 AM
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?
- Labels:
-
STM32Cube MCU Packages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-15 11:01 AM
> Why is this happening?
-> You do something wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-15 11:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-15 11:57 AM
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.
Up vote any posts that you find helpful, it shows what's working..
