cancel
Showing results for 
Search instead for 
Did you mean: 

Different USB behaviour with Hard Reset and JTAG reset

srdjan
Associate II
Posted on January 20, 2016 at 16:51

Hello all,

This problem is baffling me for quite some time.

I have a STM32L151VGT6 device, running as a VCP device on USB. If I use the device with a debugger, everything is fine. I can transfer hundreds of megabytes without any issues.

But if I disconnect the J-Link, and power reset the device, the behavior changes. Fairly often I get USB problems, for example I cannot transfer more than 10MB of data. By looking at the USB lines, it looks like the USB loses synchronization and the whole communication fails.

I'm fairly certain that the way the device is reset makes the difference. Somehow power reset makes the whole system behave differently, compared to soft reset using the j-link.

What can cause this kind of problems, and what's the difference between running the firmware while on debugger, and running it standalone? I'm using IAR, with JLink.
2 REPLIES 2
Posted on January 20, 2016 at 19:02

The debugger enables clocks and pins to suit its need, these may be different than the reset condition.

Make sure you enable all the clocks, pins and peripheral you use explicitly. If things still aren't working try dumping the state of internal peripheral registers to a serial port in both cases, and compare/contrast until you spot the difference.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
srdjan
Associate II
Posted on January 21, 2016 at 16:51

The issue was with using __WFI() in the code, which would somehow impact USB. I'm guessing that when a debugger attaches it prevents the CPU from going into sleep states.