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
  • MaximSh said:
    I try to put K_MSEC(1) but the work handler called after 1.117 ms.

    Are you calling K_MSEC(1) inside the worker handler or are you queuing the worker handler after K_MSEC(1)? After queuing the work handler, it will not necessary be called immediately if there are higher priority interrupts/threads/worker handlers that are pending to run.

    If you want higher resolution timer I recommend you to use the API in modules\hal\nordic\nrfx\drivers\include\nrfx_timer.h

Children
Related