Skip to content

H7: support 25 MHz HSE in PLL1 and PLL2 setup (fixes SYNERDUINOH7 build) - #12184

Open
sensei-hacker wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
sensei-hacker:fix-h7-25mhz-hse-pll
Open

sensei-hacker wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
sensei-hacker:fix-h7-25mhz-hse-pll

Conversation

@sensei-hacker

Copy link
Copy Markdown
Member

Summary

SYNERDUINOH7 and SYNERDUINOH7A (HSE_MHZ 25) fail to build on maintenance-10.x: the PLL2 (SDMMC/FDCAN) setup asserts HSE_VALUE % 1600000 == 0.

This adds a 25 MHz HSE case for both PLLs. M=10 gives a 2.5 MHz VCO input, inside the 2-16 MHz input range the wide-range VCO requires (DS12110, Table 50). N is chosen so that each PLL keeps its existing VCO frequency, which leaves every P/Q/R output unchanged:

PLL 8 MHz HSE (unchanged) 25 MHz HSE (this PR)
PLL1 rev Y M=4, N=400, VCO 800 MHz M=10, N=320, VCO 800 MHz
PLL1 rev V M=4, N=480, VCO 960 MHz M=10, N=384, VCO 960 MHz
PLL2 M=5, N=500, VCO 800 MHz M=10, N=320, VCO 800 MHz

Before this change, PLL1 used M = 25/2 = 12 with a 25 MHz HSE. That ran the core at 417 MHz on rev Y. On rev V it ran at 500 MHz with a 1000 MHz VCO, which is outside the VCO's specified range.

The #else branches are unchanged, so 8 and 16 MHz HSE targets compile to the same configuration as before.

Testing

  • SYNERDUINOH7 and SYNERDUINOH7A: failed to build before this change; both build now.
  • MATEKH743 (8 MHz HSE, SDIO + DroneCAN) and KAKUTEH7WING (16 MHz HSE) still build, with no warnings.
  • Not yet flown or bench-tested on Synerduino hardware.

SYNERDUINOH7 and SYNERDUINOH7A (HSE_MHZ 25) fail to build: the PLL2
block asserts HSE_VALUE is a multiple of 1.6 MHz.

For a 25 MHz HSE, use M=10 (VCI 2.5 MHz, inside the 2-16 MHz input
range the wide VCO requires per DS12110 Table 50) and scale N so both
PLLs keep their existing VCO frequencies:
- PLL2: N=320, VCO 800 MHz, VCI range 2-4 MHz
- PLL1: N scaled by 4/5 (320/384), VCO 800/960 MHz as with 8/16 MHz HSE

Previously PLL1 used M=12 for 25 MHz, giving 417 MHz (rev Y) and an
out-of-spec 1000 MHz VCO / 500 MHz core (rev V).

Builds for 8 and 16 MHz HSE targets are unchanged.
@sensei-hacker sensei-hacker added this to the 10.0 milestone Oct 25, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix STM32H7 PLL clocks for 25 MHz HSE boards

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Enable SYNERDUINOH7 and SYNERDUINOH7A builds with a 25 MHz external oscillator.
• Preserve PLL1 core and PLL2 peripheral frequencies using valid 25 MHz divider settings.
• Leave existing 8 and 16 MHz clock configurations unchanged.
Diagram

graph TD
  HSE["HSE input"] --> Check{"25 MHz?"} -->|Yes| New["25 MHz dividers"] --> PLL1["PLL1 clock"] --> Core["Core clock"]
  Check -->|No| Existing["Existing dividers"] --> PLL2["PLL2 clock"] --> Peripheral["SDMMC and FDCAN"]
  New --> PLL2
  Existing --> PLL1
Loading
High-Level Assessment

Keep the targeted 25 MHz branches. They preserve established PLL outputs without changing the 8 and 16 MHz paths; a generalized PLL calculator or configuration table would add complexity for this single new oscillator frequency.

Files changed (1) +19 / -3

Bug fix (1) +19 / -3
system_stm32h7xx.cSelect valid PLL1 and PLL2 settings for a 25 MHz HSE +19/-3

Select valid PLL1 and PLL2 settings for a 25 MHz HSE

• Adds a 25 MHz PLL1 divider and scaled multiplier for both silicon-revision configurations, preserving their VCO and core frequencies. Sets PLL2 to a valid 2.5 MHz input and 800 MHz VCO for SDMMC and FDCAN, while retaining the previous configuration and divisibility assertion for other HSE values.

src/main/target/system_stm32h7xx.c

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@sensei-hacker

Copy link
Copy Markdown
Member Author

@synersignart can you please test?

@github-actions

Copy link
Copy Markdown

RAM / Flash usage vs. base commit bc76329 — commit 9f09c89

Target Flash Δ RAM Δ
MATEKF405 ±0 B (±0.00%) CCM: ±0 B (±0.00%)
RAM: ±0 B (±0.00%)
MATEKF722 ±0 B (±0.00%) ITCM_RAM: ±0 B (±0.00%)
RAM: ±0 B (±0.00%)
TCM: ±0 B (±0.00%)
MATEKF765 ±0 B (±0.00%) DTCM_RAM: ±0 B (±0.00%)
SRAM1: ±0 B (±0.00%)
MATEKH743 ±0 B (±0.00%) D2_RAM: ±0 B (±0.00%)
DTCM_RAM: ±0 B (±0.00%)
ITCM_RAM: ±0 B (±0.00%)
RAM: ±0 B (±0.00%)

See RAM/flash optimization guide for techniques to reduce usage.

@github-actions

Copy link
Copy Markdown

Test firmware build ready — commit 9f09c89

Download firmware for PR #12184

251 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

@synersignart

Copy link
Copy Markdown
Contributor

yas ok we'll check on it, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants