STM32G0 USB clock config


I noticed something weird in the clock_setup() for stm32g0. At the end, the USB is switched to use PLLQ as the clock source. This makes sense since earlier the PLL is configured to output 48MHz on PLLQ. What doesn’t make sense is the actual line of code. The code sets USBSEL to 2, but according to the datasheet, that results in configuring the USB to use HSE as input, not PLLQ. The comment also says that it works in practice, but I really doubt that it works unless HSE is a 48MHz crystal. Am I understanding this wrong or is this a bug? I unfortunately don’t have a stm32g0bx board at the moment to test if it works or not (and of course it’s unavailable everywhere right now).

According to the header file provided by STMicroelectronics, the corresponding value of PLLQ is 2.
In addition, USB can be used normally when it is 2, and USB cannot recognize when it is 1.

So I guess the manual is wrong? Verifying with STMicroelectronics FAE

1 Like