Skip to content

Commit d8f5ef7

Browse files
erwangocarlescufi
authored andcommitted
tests/drivers/clock_control: stm32u5: Rework to explicitly test HCLK
Instead of testing SysClockFreq setting, we should instead check HCLK setting which is the real zephyr CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC counterpart (core clock freq) and takes AHB prescaler setting into account. Additionally, update one test configuration to explicitly verify AHB prescaler is correctly taken into account by clock driver. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent efd8ee4 commit d8f5ef7

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

tests/drivers/clock_control/stm32_clock_configuration/stm32u5_core/boards/pll_msis_80.overlay renamed to tests/drivers/clock_control/stm32_clock_configuration/stm32u5_core/boards/pll_msis_ahb_2_80.overlay

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
};
2121

2222
&pll1 {
23-
div-m = <2>;
23+
div-m = <1>;
2424
mul-n = <40>;
25-
div-q = <2>;
25+
div-q = <1>;
2626
div-r = <1>;
2727
clocks = <&clk_msis>;
2828
status = "okay";
2929
};
3030

3131
&rcc {
3232
clocks = <&pll1>;
33+
ahb-prescaler = <2>; /* Use AHB prescaler to reduce HCLK */
3334
clock-frequency = <DT_FREQ_M(80)>;
34-
ahb-prescaler = <1>;
3535
apb1-prescaler = <1>;
3636
apb2-prescaler = <1>;
3737
apb3-prescaler = <1>;

tests/drivers/clock_control/stm32_clock_configuration/stm32u5_core/src/test_stm32_clock_configuration.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
#include <logging/log.h>
1212
LOG_MODULE_REGISTER(test);
1313

14-
static void test_sysclk_freq(void)
14+
static void test_hclk_freq(void)
1515
{
16-
uint32_t soc_sys_clk_freq;
16+
uint32_t soc_hclk_freq;
1717

18-
soc_sys_clk_freq = HAL_RCC_GetSysClockFreq();
18+
soc_hclk_freq = HAL_RCC_GetHCLKFreq();
1919

20-
zassert_equal(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, soc_sys_clk_freq,
21-
"Expected sysclockfreq: %d. Actual sysclockfreq: %d",
22-
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, soc_sys_clk_freq);
20+
zassert_equal(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, soc_hclk_freq,
21+
"Expected hclk_freq: %d. Actual hclk_freq: %d",
22+
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, soc_hclk_freq);
2323
}
2424

2525
static void test_sysclk_src(void)
@@ -80,7 +80,7 @@ static void test_pll_src(void)
8080
void test_main(void)
8181
{
8282
ztest_test_suite(test_stm32_syclck_config,
83-
ztest_unit_test(test_sysclk_freq),
83+
ztest_unit_test(test_hclk_freq),
8484
ztest_unit_test(test_sysclk_src),
8585
ztest_unit_test(test_pll_src)
8686
);

tests/drivers/clock_control/stm32_clock_configuration/stm32u5_core/testcase.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ common:
44
tests:
55
drivers.stm32_clock_configuration.u5.sysclksrc_pll_msis_160:
66
extra_args: DTC_OVERLAY_FILE="boards/clear_clocks.overlay;boards/pll_msis_160.overlay"
7-
drivers.stm32_clock_configuration.u5.sysclksrc_pll_msis_80:
8-
extra_args: DTC_OVERLAY_FILE="boards/clear_clocks.overlay;boards/pll_msis_80.overlay"
7+
drivers.stm32_clock_configuration.u5.pll_msis_hab_2_80:
8+
extra_args: DTC_OVERLAY_FILE="boards/clear_clocks.overlay;boards/pll_msis_ahb_2_80.overlay"
99
drivers.stm32_clock_configuration.u5.sysclksrc_pll_hsi_160:
1010
extra_args: DTC_OVERLAY_FILE="boards/clear_clocks.overlay;boards/pll_hsi_160.overlay"
1111
drivers.stm32_clock_configuration.u5.sysclksrc_pll_hsi_40:

0 commit comments

Comments
 (0)