cancel
Showing results for 
Search instead for 
Did you mean: 

WFI problem: Internal command error

keepcoding
Associate II
Posted on September 27, 2013 at 14:10

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?
3 REPLIES 3
Posted on September 27, 2013 at 15:30

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
keepcoding
Associate II
Posted on September 27, 2013 at 16:44

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?

Posted on September 27, 2013 at 16:53

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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..