cancel
Showing results for 
Search instead for 
Did you mean: 

STLink-V2 appears to reset running code when plugged in to Target

I am currently trying to track a bug in my code running on a STM32F091 MCU that causes my outputs to be really "wrong" after a random amount of time. I have 4 targets running the same code and when one "fails" I'd like to be able to plug in the debugger and view the code execution in Keil. I have set up Keil according to their guide ( http://www.keil.com/support/docs/3697.htm ) so it doesn't reset the code when I connect to it with the software and I know that part works. However, when I physically connect the STLink-V2 debugger to the target all my outputs return to normal before I can even try and connect with Keil. This leads me to believe the code is resetting when it is physically attached to the debugger. Is there anything I can do to prevent this from happening? I have tried to leave the debugger attached over night to one of the targets and connected...except it never seems to "fail" when actively debugging.

5 REPLIES 5
S.Ma
Principal

use 4 stlink and run in debug mode all of them. hot plug is not guaranteed to work..

​I thought of this but this would require 4 different computers each running Keil to do that.  Even then I'm not so sure it would work as it's looking like when it's running on a debugger it doesn't fail even when ones not connected do fail.  Is the debugger doing something in the background that is different from running the target without a debugger attached?

TDK
Guru

I am able to plug/unplug a powered-on STLink-V3 without the target board resetting. I don't have a standalone ST-Link/V2 to try with.

Is the ST-Link powered prior to connecting it? If not, NRST is going to be pulled down.

You can use multiple ST-Links on the same computer and switch between them in STM32CubeIDE by explicitly giving their S/N in the debug configuration. Maybe Keil has an equivalent to this.

If you feel a post has answered your question, please click "Accept as Solution".

​I tried it both ways (with the debugger powered and unpowered and I quickly found out about it resetting (and holding it in reset) it simply because it was powered down.  Over the weekend my target happened to fail while it was connected to the debugger so for the moment I am up and running.  At some point I will try to connect multiple debuggers to the same PC and see if Keil has the ability to select between them.  At this point I don't think it does, but to be honest I've never tried.

I am going to have to get me a V3 though...sounds like it's a nicer debugger than the V2.

prain
Senior III

Also make sure that stlink reset pin is not connected to MCU. when stlink is in power up process, the reset pin may affect the MCU. According to my experience, some stlinks force reset MCU when they are powered off.