PLL Calculator — STM32 clock tree dividers

Solve PLL M/N/P/Q dividers for a target system clock from your crystal, respecting each stage's legal range.

Example: 168 MHz from a 8 MHz crystal: M=4, N=168, P=2, Q=7 — VCO runs at 336 MHz.

Check it against real silicon

Chiprun runs your firmware on an emulated microcontroller and hands back the UART output, so you can confirm these numbers rather than trusting them.

Chiprun docs

Formula

VCO_in = HSE / M    VCO_out = VCO_in × N    SYSCLK = VCO_out / P

Worked example

168 MHz from a 8 MHz crystal: M=4, N=168, P=2, Q=7 — VCO runs at 336 MHz.

  1. VCO_in = HSE / M

    8 MHz / 4

    2 MHz

    Must land between 1 and 2 MHz. This is the constraint people miss.

  2. VCO_out = VCO_in × N

    2 MHz × 168

    336 MHz

    Must land between 100 and 432 MHz.

  3. SYSCLK = VCO_out / P

    336 MHz / 2

    168 MHz

  4. USB = VCO_out / Q

    336 MHz / 7

    48 MHz

Frequently asked questions

How do STM32 PLL dividers work?

Three stages in series. M divides the crystal down to a VCO input between 1 and 2 MHz, N multiplies that up to a VCO output between 100 and 432 MHz, and P divides that down to SYSCLK. Every stage has its own legal range, so a combination giving the right SYSCLK can still be invalid.

Why should the VCO input be 2 MHz?

It minimises PLL jitter. The range allows 1 to 2 MHz, but ST recommends 2 MHz, and jitter matters if you are sampling analogue signals or generating precise timing. With an 8 MHz crystal that means M = 4.

Why is it hard to get both 168 MHz and USB?

USB needs exactly 48 MHz, which requires the VCO output to be an integer multiple of 48 MHz. That constraint plus the SYSCLK requirement plus the VCO range leaves very few valid combinations — it is why 8 MHz crystals and 168 MHz are such a common pairing, since 336 MHz divides by both 2 and 7.

Can I run USB on an approximate 48 MHz?

No. The USB specification allows about 0.25% tolerance, and the peripheral will fail to enumerate outside it. If the PLL cannot produce an exact 48 MHz alongside your SYSCLK, use a separate clock source for USB.

Related tools