Page 1 of 1

STM32F072 USB CDC fail descriptor request

Posted: Sun Jun 03, 2018 6:37 pm
by Captain
Hello!
I have a simple custom PCB with the stm32f072c8 chip onboard. The host OS can not enumerate the device:
A request for the USB device descriptor failed.

First I thought it might be the hardware issue, but in dfu mode it allows to read and flash the chip successfully. The schematic is as simple as two 22R hooked up in series with D+ and D- with no external pull-up. I tried building the same project for stm32f103 chip (blue pill board) and it worked. As F0 and F1 share the same driver, I suppose this is not a driver issue. I don't have a scope able to decode usb, but as for what I see on the bus lines it looks OK (D+ is pulled up, D- is low, no "capacitive" slopes).
I've also checked the clock configuration in a debugger (HSI48ON/RDY = 1 and USBSW = 0 as expected). Clocking usb from PLL with external crystal (16MHz / 4 * 12) does not help either.
I am not familiar with usb protocol much, but what I've found interesting during debugging is that after usb initialization done it hits interrupt multiple times with the RESET flag high together with SUSP/ESOF/SOF (may vary).
Now I'm stuck. I feel that it must be something with GPIO or clock configuration but can't find a clue. Here is my project (simple hello world; I use HAL V6.0). Maybe someone have a working project for the f072 discovery kit, utilizing usb and can share, i would appreciate much.
Thanks in advance.

Re: STM32F072 USB CDC fail descriptor request

Posted: Mon Jun 04, 2018 11:03 am
by Captain
Well.. that was in fact obvious. In case someone would hit the same issue, my AHB bus clock was at 48 / 4 = 12Mhz, so my program was unable to meet usb timing specification (at least as I understand). Setting STM32_HPRE=STM32_HPRE_DIV1 solved the issue. I've found no mention about it in STm papers, but it might be reasonable to add a preproc check for the AHB clock, when utilizing USB or ETH (I believe it requires min frequency as well).

Re: STM32F072 USB CDC fail descriptor request

Posted: Mon Jun 04, 2018 12:18 pm
by Giovanni
Hi,

You should look at the demo for STM32F072B-Discovery under /hal/stm32/STM32F0xx/USB-CDC, settings should be fine for your board too.

On STM32 you always need to provide USB with an accurate 48MHz clock, regardless the model.

Giovanni