STM32F072 USB CDC fail descriptor request

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Captain
Posts: 12
Joined: Sat Dec 19, 2015 3:21 pm

STM32F072 USB CDC fail descriptor request

Post 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.
Attachments
usb_test.zip
test project
(18.21 KiB) Downloaded 443 times
Captain
Posts: 12
Joined: Sat Dec 19, 2015 3:21 pm

Re: STM32F072 USB CDC fail descriptor request

Post 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).
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F072 USB CDC fail descriptor request

Post 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
Post Reply