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\$
6
  • \$\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\$ Commented Sep 14, 2016 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
    Commented Sep 14, 2016 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\$ Commented Oct 14, 2016 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\$ Commented Oct 14, 2016 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\$
    – jaskij
    Commented Dec 14, 2016 at 12:21

2 Answers 2

1
\$\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\$
3
  • 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\$
    – user39382
    Commented Oct 15, 2016 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\$ Commented Jun 27, 2017 at 13:26
  • \$\begingroup\$ @DmitryGrigoryev True, but semihosting is a separate thing entirely. Enabling/disabling semihosting doesn't affect how applications start up. \$\endgroup\$
    – user39382
    Commented Jun 27, 2017 at 16:30
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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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