This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf_delay is inaccurate

Hi,

i have a problem in my Code, when ic look nrf_delay_us (1000) on the oscilloscope i can se a puls withe 1,3 us thats not accurate enough. What could be a reason for that? What could i had change, that the nrf_delay doesn't work accurate?

And its not because environmental-influence beacause whith an other example it works well.

Best regards Nils

Parents
  • If interrupts are running while you are in a delay loop, this will most definitely throw off the timing, and there isn't much you can do about it.

    There is a more accurate delay implementation using one of the 16 MHz timers in the timer_example in the SDK.

    In general, you should make sure that your application is not dependent on delay loops at all, as those are extremely power inefficient. If you need some action to happen after a certain time period, you should use an (RTC) timer to do it, and put the CPU to sleep in the mean time. This can most often easily be done with the app_timer module.

Reply
  • If interrupts are running while you are in a delay loop, this will most definitely throw off the timing, and there isn't much you can do about it.

    There is a more accurate delay implementation using one of the 16 MHz timers in the timer_example in the SDK.

    In general, you should make sure that your application is not dependent on delay loops at all, as those are extremely power inefficient. If you need some action to happen after a certain time period, you should use an (RTC) timer to do it, and put the CPU to sleep in the mean time. This can most often easily be done with the app_timer module.

Children
Related