diff --git a/include/zephyr/sys/time_units.h b/include/zephyr/sys/time_units.h index 4e57120a289..1b08e4c9617 100644 --- a/include/zephyr/sys/time_units.h +++ b/include/zephyr/sys/time_units.h @@ -79,7 +79,7 @@ static inline int z_impl_sys_clock_hw_cycles_per_sec_runtime_get(void) #if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME) #define sys_clock_hw_cycles_per_sec() sys_clock_hw_cycles_per_sec_runtime_get() #else -#define sys_clock_hw_cycles_per_sec() CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC +#define sys_clock_hw_cycles_per_sec() (uint32_t)CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC #endif /** @internal diff --git a/tests/arch/x86/info/src/timer.c b/tests/arch/x86/info/src/timer.c index 85d4a72215c..aa28ba12a7c 100644 --- a/tests/arch/x86/info/src/timer.c +++ b/tests/arch/x86/info/src/timer.c @@ -44,7 +44,7 @@ void timer(void) printk("TIMER: unknown"); #endif - printk(", configured frequency = %dHz\n", + printk(", configured frequency = %uHz\n", sys_clock_hw_cycles_per_sec()); #if defined(CONFIG_COUNTER_CMOS) diff --git a/tests/kernel/timer/timer_behavior/src/jitter_drift.c b/tests/kernel/timer/timer_behavior/src/jitter_drift.c index b958883b6e4..82e178fb602 100644 --- a/tests/kernel/timer/timer_behavior/src/jitter_drift.c +++ b/tests/kernel/timer/timer_behavior/src/jitter_drift.c @@ -240,7 +240,7 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan /* If max stddev is lower than a single clock cycle then round it up. */ uint32_t max_stddev = MAX(k_cyc_to_us_ceil32(1), CONFIG_TIMER_TEST_MAX_STDDEV); - TC_PRINT("timer clock rate %d, kernel tick rate %d\n", + TC_PRINT("timer clock rate %u, kernel tick rate %d\n", sys_clock_hw_cycles_per_sec(), CONFIG_SYS_CLOCK_TICKS_PER_SEC); if ((USEC_PER_SEC / CONFIG_TIMER_TEST_PERIOD) > CONFIG_SYS_CLOCK_TICKS_PER_SEC) { TC_PRINT("test timer period (%u us) is smaller than " @@ -282,8 +282,8 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan ", \"total_drift_us\":%.6f" ", \"expected_period_cycles\":%.0f" ", \"expected_period_drift_us\":%.6f" - ", \"sys_clock_hw_cycles_per_sec\":%d" - ", \"CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC\":%d" + ", \"sys_clock_hw_cycles_per_sec\":%u" + ", \"CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC\":%u" ", \"CONFIG_SYS_CLOCK_TICKS_PER_SEC\":%d" ", \"CONFIG_TIMER_TEST_PERIOD\":%d" ", \"CONFIG_TIMER_TEST_SAMPLES\":%d" @@ -304,7 +304,7 @@ static void do_test_using(void (*sample_collection_fn)(void), const char *mechan expected_period, expected_period_drift, sys_clock_hw_cycles_per_sec(), - CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, + (uint32_t)CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC, CONFIG_SYS_CLOCK_TICKS_PER_SEC, CONFIG_TIMER_TEST_PERIOD, CONFIG_TIMER_TEST_SAMPLES, diff --git a/tests/kernel/timer/timer_monotonic/src/main.c b/tests/kernel/timer/timer_monotonic/src/main.c index baa4c762a6a..a1316ce2b79 100644 --- a/tests/kernel/timer/timer_monotonic/src/main.c +++ b/tests/kernel/timer/timer_monotonic/src/main.c @@ -58,7 +58,7 @@ ZTEST(timer_fn, test_timer) TC_PRINT("k_ticks_to_cyc_floor32(1) = %d\n", k_ticks_to_cyc_floor32(1)); - TC_PRINT("sys_clock_hw_cycles_per_sec() = %d\n", + TC_PRINT("sys_clock_hw_cycles_per_sec() = %u\n", sys_clock_hw_cycles_per_sec()); t_last = k_cycle_get_32();