1
\$\begingroup\$

I'm using a STM32L031 with Eclipse for my application. When in debug mode everything works fine. But when I stop debug mode or power off and on again, the STM32L031 stops working.

I had expected that after downloading the code into the chip, it should work whenever I power it on.

And since I'm not using an evaluation board, there is no reset button so I cannot reset it.

How to solve this problem? Or is there a way to reset the chip without requiring the Reset button hardware?

\$\endgroup\$
  • \$\begingroup\$ What is it doing when you 'stop debug mode'? I guess there are some breakpoints still in the code which didn't get cleaned up before you reset. \$\endgroup\$ – Sean Houlihane Sep 14 '16 at 11:58
  • \$\begingroup\$ Have you wired the NRST pin in a way which could prevent normal startup? Do you use some sort of semi-hosting which might prevent normal running (because of hard coded breakpoints)? Is the debugger still connected when you do the power cycle? \$\endgroup\$ – Arsenal Sep 14 '16 at 13:18
  • \$\begingroup\$ If you probably have an SMT resistor on the NRST line, to which you can solder a small wire to pull low for a test reset. Or (at least if your supply is current limited) you can just touch something grounded (or via a low value resistor) to it. \$\endgroup\$ – Chris Stratton Oct 14 '16 at 18:56
  • \$\begingroup\$ You ought to be able to re-attach the debugger to a running target - this will help to investigate where it is stuck. \$\endgroup\$ – Sean Houlihane Oct 14 '16 at 19:43
  • 1
    \$\begingroup\$ Supposing you HAVE a pullup resistor on the NRST line just short NRST to ground. If you don't - add a 10kOhm one. Also, how is your BOOT0 wired? \$\endgroup\$ – Jan Dorniak Dec 14 '16 at 12:21
1
\$\begingroup\$

When using the debugger, the processor is forced to execute from a certain region.
On power-on reset, the bootloader determines where it should start. Some pins or flash location provide the bootloader with instructions.

stm32l031 boot options

\$\endgroup\$
0
\$\begingroup\$

One thing that can stop it from running is if you are using semi-hosting. In your project properties, try to remove the following two symbols:

enter image description here

I have multiple projects, and only some of them require the removal of semi-hosting. I haven't yet figured out why it is necessary for some and not others...

Oh, and if powercycling the board doesn't work, then a reset button wouldn't, either.

\$\endgroup\$
  • 1
    \$\begingroup\$ Semihosting comes into play if you're using functions that use standard I/O, like printf(). If you don't call those functions, your application is no different with and without semihosting. \$\endgroup\$ – duskwuff -inactive- Oct 15 '16 at 5:51
  • \$\begingroup\$ @duskwuff No experience with this controller in particular, but AFAIK "hosted application" in C means your code starts with main, as opposed to "unhosted" applications which start at something like __program_start. Incidentally, if you run unhosted, you have to initialize STDOUT yourself before you can use printf, but it may be not the only difference. \$\endgroup\$ – Dmitry Grigoryev Jun 27 '17 at 13:26
  • \$\begingroup\$ @DmitryGrigoryev True, but semihosting is a separate thing entirely. Enabling/disabling semihosting doesn't affect how applications start up. \$\endgroup\$ – duskwuff -inactive- Jun 27 '17 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.