Skip to content
Permalink
Browse files

tests: benchmarks: Do not use CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC

On some SoCs the frequency of the system clock is obtained at run time
as the exact configuration of the hardware is not known at compile time.
On such platforms using CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC define
directly introduces timing errors.

This commit replaces CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC by the call
to inline function sys_clock_hw_cycles_per_sec() which always returns
correct frequency of the system clock.

Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
  • Loading branch information...
pizi-nordic authored and carlescufi committed Apr 23, 2019
1 parent ec857d0 commit 5f6cae38db1e73d94e1faaf88c4b78cbeaf7e0c9
Showing with 2 additions and 2 deletions.
  1. +1 −1 tests/benchmarks/boot_time/src/main.c
  2. +1 −1 tests/benchmarks/timing_info/src/timing_info.h
@@ -43,7 +43,7 @@ void main(void)
*/
k_sleep(1);

int freq = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 1000000;
int freq = sys_clock_hw_cycles_per_sec() / 1000000;

_start_us = __start_time_stamp / freq;
s_main_time_stamp = __main_time_stamp - __start_time_stamp;
@@ -138,7 +138,7 @@ static inline void benchmark_timer_start(void) { }
/* Get Core Frequency in MHz */
static inline u32_t get_core_freq_MHz(void)
{
return (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC/1000000);
return (sys_clock_hw_cycles_per_sec() / 1000000);
}

#define PRINT_STATS(x, y, z) PRINT_F(x, y, z)

0 comments on commit 5f6cae3

Please sign in to comment.
You can’t perform that action at this time.