Skip to content

Commit 94bf03b

Browse files
committed
drivers: clock_control: fix PLL input frequency
Updated the PLL input frequency calculation to include division by the HSI clock divider. Enable HSI divider using LL_RCC_HSI_EnableDivider(). Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
1 parent df1d51e commit 94bf03b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

drivers/clock_control/clock_stm32_ll_common.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,11 @@ static int stm32_clock_control_get_subsys_rate(const struct device *clock,
456456
#endif
457457
#if defined(STM32_SRC_HSI)
458458
case STM32_SRC_HSI:
459+
#if defined(CONFIG_SOC_SERIES_STM32L0X)
460+
*rate = STM32_HSI_FREQ / STM32_HSI_DIVISOR;
461+
#else
459462
*rate = STM32_HSI_FREQ;
463+
#endif
460464
break;
461465
#endif
462466
#if defined(STM32_SRC_MSI)
@@ -662,7 +666,13 @@ static void set_up_fixed_clock_sources(void)
662666
}
663667
}
664668
#if STM32_HSI_DIV_ENABLED
669+
#if defined(CONFIG_SOC_SERIES_STM32L0X)
670+
if (STM32_HSI_DIVISOR == 4) {
671+
LL_RCC_HSI_EnableDivider();
672+
}
673+
#else
665674
LL_RCC_SetHSIDiv(hsi_divider(STM32_HSI_DIVISOR));
675+
#endif
666676
#endif
667677
}
668678

drivers/clock_control/clock_stm32l0_l1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ __unused
4949
uint32_t get_pllsrc_frequency(void)
5050
{
5151
if (IS_ENABLED(STM32_PLL_SRC_HSI)) {
52+
#if defined(CONFIG_SOC_SERIES_STM32L0X)
53+
return STM32_HSI_FREQ / STM32_HSI_DIVISOR;
54+
#else
5255
return STM32_HSI_FREQ;
56+
#endif
5357
} else if (IS_ENABLED(STM32_PLL_SRC_HSE)) {
5458
return STM32_HSE_FREQ;
5559
}

0 commit comments

Comments
 (0)