2013-09-27 05:10 AM
Hi
I run this very simple code on the STM32F3 Discovery board:int main(void)
{
__WFI();
return 0;
}
It compiles fine and I can flash it onto the STM without any problems (I'm using the ST-Link). However, when I want to flash the program again, I get the 'Internal Command Error'. This error is independent of the IDE and occurs even with the ST-Link Utility. I then have to select 'connect under reset' option in the ST-Link Utility and then erase the whole chip to get it working again.
Any ideas what might cause this problem?
2013-09-27 06:30 AM
Halting the core precludes the SWD/JTAG executing (operating core) commands it needs too. The debugger can't talk to it. DMA and other lower power operation will also preclude debugger access.
Also don't return from main(), bad things will happen.2013-09-27 07:44 AM
Thanks! So this is normal behaviour. Is there a way to use sleep mode and still be able to flash new code by ST-Link? Do I always need to 'connect under reset' in the future?
2013-09-27 07:53 AM
Thanks! So this is normal behaviour. Is there a way to use sleep mode and still be able to flash new code by ST-Link? Do I always need to 'connect under reset' in the future?
Well it's normal that if you turn things off, and clocks/supplies are off, that things cease to function as usual. There are many ways to cause problems, I enumerated some of the most common things. Reseting the core is at least one of the methods that several JTAG/SWD pods use to wrestle control of a system. Or you have code to recognize a GPIO/PIN setting, and enter a download safe mode. Or reset with BOOT0 = High There might be some DBGMCU controls, or such, that maintain the debug interface in some conditions.