2011-07-28 01:56 PM
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.2011-07-28 02:06 PM
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.2011-07-28 02:32 PM
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.