Skip to main content
Visitor II
May 24, 2020
Question

STM32G431 crystal less usb

  • May 24, 2020
  • 2 replies
  • 1271 views

I want to synchronize the cpu clock frequency with the SOF frequency of USB.

datasheet says, that you may use HSI48 for crystal less operation or use an XTAL.

Question is: Is HSI48 synchron with the SOF frequency?

(than I could use MCO out as reference clock)

second question:

in CubeMX I can configure HSI16 to generate the 48 MHz USB clock. Will that work? CubeMX generated no warning.

    This topic has been closed for replies.

    2 replies

    Super User
    May 24, 2020

    From the datasheet:

    > It requires a precise 48 MHz clock which can be generated from the internal main PLL (the clock source must use a HSE crystal oscillator) or by the internal 48 MHz oscillator in automatic trimming mode.

    So yes, provided you enable the automatic trimming mode as follows:

    __HAL_RCC_CRS_CLK_ENABLE();
    SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
    SET_BIT(CRS->CR, CRS_CR_CEN);

    These commands are for the H7 series. I imagine the G4 series is similar but I didn't check.

    rzong.1Author
    Visitor II
    May 26, 2020

    Hi,

    so after reading the manuals, I found out, that HSI48 with the trimming mechanism is not synchronuos with the SOF frequency. This is because the synchronisation mechanism is not a PLL.

    So my problem is not solved.

    But thanks for Your hint.