Skip to content

Commit f6c665b

Browse files
erwangocarlescufi
authored andcommitted
drivers/clock_control: stm32u5: Fix on flash latency procedure
Instead of computing hclk freq use for flash latency setting after setting the PLLs, do it right at the beginning of the function. Indeed, first step of PLL configuration is to switch back sysclock to HSI source (in case it was initially PLL). In that case, flash latency is theoretically set in consistency with PLL driver hclk. So we should "measure" hclk freq at that step rather than once sysclock is back on HSI. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent d8f5ef7 commit f6c665b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/clock_control/clock_stm32_ll_u5.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ int stm32_clock_control_init(const struct device *dev)
416416

417417
ARG_UNUSED(dev);
418418

419+
/* Current hclk value */
420+
old_hclk_freq = __LL_RCC_CALC_HCLK_FREQ(get_startup_frequency(), LL_RCC_GetAHBPrescaler());
421+
419422
/* Set up indiviual enabled clocks */
420423
set_up_fixed_clock_sources();
421424

@@ -428,9 +431,6 @@ int stm32_clock_control_init(const struct device *dev)
428431
/* Set voltage regulator to comply with targeted system frequency */
429432
set_regu_voltage(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
430433

431-
/* Current hclk value */
432-
old_hclk_freq = __LL_RCC_CALC_HCLK_FREQ(get_startup_frequency(), LL_RCC_GetAHBPrescaler());
433-
434434
/* Set flash latency */
435435
/* If freq increases, set flash latency before any clock setting */
436436
if (old_hclk_freq < CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) {

0 commit comments

Comments
 (0)