cancel
Showing results for 
Search instead for 
Did you mean: 

USB Communication and Debugger are not working together

DDS
Associate II

Hi,

I have developed a Keyboard using USB communication protocol and i am facing an issue, when i want to debug the code and parallelly i want to see whether the alphabet is printing or not. This is not happening when i want to see both simultaneously.

Screenshot 2024-11-09 145614.png

so i am getting the above dialogue and only its going into debug but it is not communicating for keyboard.

 

Thank you. 

3 REPLIES 3
gbm
Lead III

You didn't include any information on the hardware used. My guess: BluePill.

It this is the case, at the beginning of main set the PA12 line as output (low level is the default), then wait for 50 ms, then start the USB. Set the debugger in such a way that it will not stop execution before the USB configuration process is completed.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
DDS
Associate II

Hi,

Yes, I am using Blue Pill (STM32F103C8T6). Could you please explain the second part of the reply, (i.e Set the debugger in such a way that it will not stop execution before the USB configuration process is completed).

 

Thank you.

After USB connection is recognized, the USB configuration process starts, requiring the processing of few commands from host in your device. There is a time limit for these actions; in theory - milliseconds, in practice - few seconds. If your device is stopped by the debugger during that time, the process will fail.

With BluePill, the process starts when the board is connected and USB peripheral is activated. It restarts when you remove and then restore the pullup on PA12. To remove the pullup - set PA12 as output. To restore it - just enable the USB peripheral (this is done in USB stack when the MX_USB_init is called).

If you use the debugger, the configuration will fail initially, cause the CPU is stopped and the board is detected by the host as connected (but not responding to the requests). Then by fiddling with PA12 it will be detected as disconnected, then as connected again, so that the configuration process will have a chance to restart and complete on time.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice