Skip to content

Commit

Permalink
Update stm32h7.c (#148)
Browse files Browse the repository at this point in the history
fixes clock configuration error with non-25 MHz crystals
  • Loading branch information
calithameridi authored Feb 9, 2024
1 parent 6eb9a20 commit 288107c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/stm32/stm32h7.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ clock_setup(void)
PWR->CR3 = (PWR->CR3 | PWR_CR3_LDOEN) & ~(PWR_CR3_BYPASS | PWR_CR3_SCUEN);
while (!(PWR->CSR1 & PWR_CSR1_ACTVOSRDY))
;
// (HSE 25mhz) /DIVM1(5) (pll_base 5Mhz) *DIVN1(192) (pll_freq 960Mhz)
// /DIVP1(2) (SYSCLK 480Mhz)
// klipper supports 8, 12, 16, 20, 24, and 25 MHz crystals on HSE
#if CONFIG_CLOCK_REF_FREQ % 5000000 == 0
uint32_t pll_base = 5000000;
#elif CONFIG_CLOCK_REF_FREQ % 4000000 == 0
uint32_t pll_base = 4000000;
#else
#error Unknown pll_base for CLOCK_REF_FREQ
#endif
// Only even dividers (DIVP1) are allowed
uint32_t pll_freq = CONFIG_CLOCK_FREQ * 2;
if (!CONFIG_STM32_CLOCK_REF_INTERNAL) {
Expand Down

0 comments on commit 288107c

Please sign in to comment.