Showing results for 
Search instead for 
Did you mean: 


Associate II


Hi All,

I made a piece of hardware, where I use STM32G0B1CET6N as a supervisor for another CPU (Qualcomm CPU+LTE) and to manage USB ports/ battery charger.
All went well until I started to add to my code USBPD and USB CDC (virtual COM port).
I was looking for an off-the shelf example, which could be integrated with what I wrote till now. I use PC with WIN10 Pro 10.0.19045 Build 19045.
All of the code was built with STM32CubeIDE, GNU 11.3rel1, _Min_Heap_Size = 0x2000;, _Min_Stack_Size = 0x4000;, FLASH_LATENCY_2.
Tried to do the following:

1. Took STM32CUBEMX V6.9.1 and generated 2 separate projects, which contain the ONLY components:
1.a. USB_DRD_FS+USB_DEVICE Middleware (Configured as CDC) and UCPD1 (Configured as DRP+USBPD Middleware (Full Stack).
Initially STM32CUBEMX provided warning before generating the code because some platform settings (bcd detection related, whatever I tried there, i've got warning, so switched off BCD)
Ran the generated code, got a Hard Fault, like described in [1]. Switched the UCPD1 to SNK, then all ran OK, but no COM port attached.
1.b. USB_DRD_FS+USB_DEVICE Middleware (Configured as CDC) only. All ran OK, but no COM port attached. I was able to catch the HAL_PCD_IRQHandler 3 times and got ESOF, SUSP and ESOF flags set. Then interrupts ended.

What I expect is that the system will recognize the COM port.
Maybe the generated code still lacks part of implementation, which I need to write before this will happen?
please excuse my stupidity, if not this, what else can be wrong?

2. Took an example from STM32CubeG0-master\Projects\STM32G0C1E-EV\Applications\USB_Device\CDC_Standalone, and adapted it to my MCU:
2.a Initially I've got "Unknown USB Device (Device Descriptor Request Failed)" error like in [2] and many others.
This error seems to be related to USB core clock, once I made it 48MHz, I've got reed of it.
2.b Then I've got "This device cannot start(code 10)" error like in [3] and many others.
This error depends whether I'm connected with hub or directly to PC chipset port. The latter eliminates the error.
I suspect some timing issue, and not signal integrity, since I use the very same lines muxed with Qualcom USB port, which works reliably.
2.c Finally got the COM port recognized and was able to connect to it with terminal. Tried to make a loopback without using a huart3 as in example, got one packet back and then all stuck.

What can be a reason for "This device cannot start(code 10)" error?

3. Tried to integrate the result of (2) with my code and then when I initialize the USB (MX_USB_Device_Init(),
specifically - when clock to USB core is enabled) all code execution freezes in very strange way (I can make few folowing steps with debugger, and then it stuck completely).

Can this be related to sleep mode somehow? What may be the other reasons for this?


I would appreciate someone's help please.
Best Regards,

ST Employee

Hello Rise,

May I suggest you to refer to provided USBPD project with USB data support available under this path of STM32G0 cubeFw

you should found a sink MSC application in addition to SRC HID host application