Loading...
 
Skip to main content

System Workbench for STM32


STM32F103 USB CDC Device stops working in debug state

So,
Looks like powering up the CPU prior to establishing a USB connection is problematic.

If I disconnect the power connection between Stink and the target, power the target via the USB lead it sort of works... intermittently...
a) Flash target over Stink
b) Enter debug perspective and start the debugger
c) Remove USB cable between target and host computer - debugger will report connection lost in the console window
d) Plug in target USB cable - debugger sometimes throws an error about a void pointer in some java file, dismiss dialog box.
e) Place a break point after all the cubemx generated initialisation code and allow the program to run to that point.
f) In windows 10, computer management, device management page - Menu action - scan for hardware changes
g) Open Terminal program - I'm using Realterm - and connect to COM device.
h) Place break point in CDC_Receive_FS in usbd_cdc_if.
i) Type something in Realterm - the code breaks in the reception routine - nice. 😀
j) Step though, hunt down your bugs

Typing into the terminal whilst CPU is halted will stuff things up.
Leaving the target powered via Stink then unplugging USB and reconnect USB will stuff things up.
Recompiling and reflashing code requires you to start at step a.

Some times it all turns to sh!t, nothing responds and seems the only way out is a restart of the computer.