Timer accuracy for micro seconds

Hi,

i defined timer 
K_TIMER_DEFINE(my_timer, my_timer_handler, NULL);

then i am starting  the timer with configuration :

k_timer_start(&my_timer, K_USEC(500), K_USEC(500));
The issue that the 
the handler prints log every 581.5 us instead of 500.
What can be the reason?or how to trigger some handler every 500 us
Thanks
Parents Reply
  • I try to put K_MSEC(1) but the work handler called after 1.117 ms.
    .
    i fareget that i changed 

    hfclock to 128 MHz but i think it is not related.



    static int hfclock_config_and_start(void)
    {
    	int ret;
    
    	/* Use this to turn on 128 MHz clock for cpu_app */
    	ret = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);
    
    	ret -= NRFX_ERROR_BASE_NUM;
    	if (ret)
    	{
    		return ret;
    	}
    
    	nrfx_clock_hfclk_start();
    	while (!nrfx_clock_hfclk_is_running())
    	{
    	}
    
    	return 0;
    }

Children
Related