cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F217 different behavior from different reset source - Hard fault exception

wojciech239955
Associate II
Posted on July 28, 2011 at 22:56

Hello

What could be the reason for different behavior of the microcontroller. Launched by the power reset - each call to sprintf causes HardFault an exception. Launched after the reset of the watchdog everything works fine and sprintf well done. External Reset of the JTAG debugger program also works correctly. Is there any difference in the resetting of the processor depending on the reset source? I guess that HardFault probably the exception is invoked by reference to a nonexistent location, but why differently from resets source?

 Heap is allocated properly.

So I'm looking for a foothold.
2 REPLIES 2
ColdWeather
Senior
Posted on July 28, 2011 at 23:06

1). Watch if BOOT0 and BOOT1 inputs are properly wired: don't let them floating; if pulled up/down (to VCC or GND) via resistors, keep the values low (under 2K2).

2). Maybe some interrupt occures while no ISR defined. Can happen if wrong start up file used.

Posted on July 28, 2011 at 23:32

So I'm looking for a foothold.

Suspect the stack is going sideways on you, or you have some local variable you aren't explicitly setting/initializing and are having some fun with random junk in SRAM, and thus on the stack.

Clearing SRAM in the Reset Handler, or setting it to some other value, would likely aid in the repeatability of the problem regardless of the initial state or reset method.

If you had a half decent Hard Fault handler you could determine the registers and core state, and you could look at the faulting instruction. The cause would then be far more apparent.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..