Is "CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC = 32768" correct for nRF52840?


Wang, Steven L
 

Hi:

   Does anyone know if "CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC = 32768" is correct for nRF52840? I call test_kernel_systick() with reel_board and it always fails. I tried to print "start_time" and "stop_time"

and found that "stop_time - start_time" was around "32670". However, it is supposed to be a number bigger than "32768". So, I'm wondering if "32768" is correct setting.


#define WAIT_TIME_US 1000000

void test_kernel_systick(void)
{
        u32_t start_time, stop_time, diff;

        start_time = osKernelSysTick();
        k_busy_wait(WAIT_TIME_US);
        stop_time = osKernelSysTick();

        diff = SYS_CLOCK_HW_CYCLES_TO_NS(stop_time -
                                         start_time) / NSEC_PER_USEC;

        zassert_true(diff >= WAIT_TIME_US, NULL);
}

Thanks,

-Steven


Carles Cufi
 

Hi Steven,

Yes, it's correct but there's an inaccuracy problem that Andy has fixed in this PR:

https://github.com/zephyrproject-rtos/zephyr/pull/16782

Carles

-----Original Message-----
From: devel@... <devel@...> On
Behalf Of Wang, Steven L via Lists.Zephyrproject.Org
Sent: 28 June 2019 10:03
To: devel@...
Cc: devel@...
Subject: [Zephyr-devel] Is "CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC = 32768"
correct for nRF52840?

Hi:

   Does anyone know if "CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC = 32768" is
correct for nRF52840? I call test_kernel_systick() with reel_board and
it always fails. I tried to print "start_time" and "stop_time"

and found that "stop_time - start_time" was around "32670". However, it
is supposed to be a number bigger than "32768". So, I'm wondering if
"32768" is correct setting.


#define WAIT_TIME_US 1000000

void test_kernel_systick(void)
{
        u32_t start_time, stop_time, diff;

        start_time = osKernelSysTick();
        k_busy_wait(WAIT_TIME_US);
        stop_time = osKernelSysTick();

        diff = SYS_CLOCK_HW_CYCLES_TO_NS(stop_time -
                                         start_time) / NSEC_PER_USEC;

        zassert_true(diff >= WAIT_TIME_US, NULL); }

Thanks,

-Steven



Wang, Steven L
 

Hi Carles:

   Thanks for help on it.

-Steven

On 6/28/2019 9:50 PM, Cufi, Carles wrote:
Hi Steven,

Yes, it's correct but there's an inaccuracy problem that Andy has fixed in this PR:

https://github.com/zephyrproject-rtos/zephyr/pull/16782

Carles

-----Original Message-----
From: devel@... <devel@...> On
Behalf Of Wang, Steven L via Lists.Zephyrproject.Org
Sent: 28 June 2019 10:03
To: devel@...
Cc: devel@...
Subject: [Zephyr-devel] Is "CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC = 32768"
correct for nRF52840?

Hi:

   Does anyone know if "CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC = 32768" is
correct for nRF52840? I call test_kernel_systick() with reel_board and
it always fails. I tried to print "start_time" and "stop_time"

and found that "stop_time - start_time" was around "32670". However, it
is supposed to be a number bigger than "32768". So, I'm wondering if
"32768" is correct setting.


#define WAIT_TIME_US 1000000

void test_kernel_systick(void)
{
        u32_t start_time, stop_time, diff;

        start_time = osKernelSysTick();
        k_busy_wait(WAIT_TIME_US);
        stop_time = osKernelSysTick();

        diff = SYS_CLOCK_HW_CYCLES_TO_NS(stop_time -
                                         start_time) / NSEC_PER_USEC;

        zassert_true(diff >= WAIT_TIME_US, NULL); }

Thanks,

-Steven