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.
Formula
VCO_in = HSE / M VCO_out = VCO_in × N SYSCLK = VCO_out / PWorked example
168 MHz from a 8 MHz crystal: M=4, N=168, P=2, Q=7 — VCO runs at 336 MHz.
VCO_in = HSE / M
8 MHz / 4
2 MHz
Must land between 1 and 2 MHz. This is the constraint people miss.
VCO_out = VCO_in × N
2 MHz × 168
336 MHz
Must land between 100 and 432 MHz.
SYSCLK = VCO_out / P
336 MHz / 2
168 MHz
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
Timer & Prescaler Calculator
Every valid prescaler and reload pair for a target frequency on AVR, STM32, PIC and RP2040 — ranked by error, with C you can paste.
Firmware
UART Baud Rate Error Calculator
Register value and percentage error for any MCU clock and baud rate, with a verdict on whether the link will actually be reliable.
Firmware
SPI Clock Divider Calculator
Prescaler settings to hit a target SPI clock without exceeding your peripheral's maximum.
Firmware
CAN Bus Bit Timing Calculator
Every valid TSEG1/TSEG2/SJW combination for your clock and bitrate, ranked by sample-point quality, with the register value.
Firmware
Hex, Binary & Decimal Converter
Convert between hex, binary, decimal, octal and ASCII, with width-aware bit grids and endianness swapping.
Firmware
Bitwise Operation Calculator
AND, OR, XOR, NOT and shifts with a live bit grid so you can see exactly which bits moved.
Firmware