<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Timer accuracy on NRF5340</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111063/timer-accuracy-on-nrf5340</link><description>Hi, 
 I&amp;#39;m trying to sample few sensors at 2 kHz with a timer. Even though nrf5340 application core can run at 128 MHz, I couldn&amp;#39;t achieve exact 500 us delay with timer. 
 Firstly, I initialized a message queue and put timestamps into queue to not block</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 May 2024 20:02:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111063/timer-accuracy-on-nrf5340" /><item><title>RE: Timer accuracy on NRF5340</title><link>https://devzone.nordicsemi.com/thread/483128?ContentTypeID=1</link><pubDate>Mon, 13 May 2024 20:02:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0227be9-1e2c-4939-ab86-8a312867ebf0</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
[quote userid="133615" url="~/f/nordic-q-a/111063/timer-accuracy-on-nrf5340"]I&amp;#39;m trying to sample few sensors at 2 kHz with a timer. Even though nrf5340 application core can run at 128 MHz, I couldn&amp;#39;t achieve exact 500 us delay with timer.[/quote]
&lt;p&gt;On the nRF53, you have 2 different timing peripherals.&amp;nbsp;&lt;span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/timer.html?cp=4_0_0_6_34"&gt;TIMER&lt;/a&gt; and &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/rtc.html?cp=4_0_0_6_27"&gt;RTC&lt;/a&gt;. TIMER uses the high-frequency clock source (HFCLK, 16 MHz), which means better resolution (62.5 ns).&amp;nbsp;RTC uses the low-frequency clock source (LFCLK, 32 KHz), which means less resolution (~30 us).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The zephyr kernel timer, that is used when you are using e.g the function&amp;nbsp;k_cycle_get_32, is using the RTC.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So in your code, you are using the TIMER, to generate a interrupt every 500us. But you are using the RTC to measure the&amp;nbsp;accuracy of the TIMER. So you are in fact getting a accurate interrupt every 500us, but&amp;nbsp;the method you are using to measure the accuracy is what&amp;#39;s adding the&amp;nbsp;inaccuracy in your measurements.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer accuracy on NRF5340</title><link>https://devzone.nordicsemi.com/thread/482807?ContentTypeID=1</link><pubDate>Fri, 10 May 2024 12:50:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d059d812-f025-4583-8b21-3ad3cc5ba39b</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;most of the staff is away for vacation, so there will be some delays in response time. Thank you for your patience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer accuracy on NRF5340</title><link>https://devzone.nordicsemi.com/thread/482687?ContentTypeID=1</link><pubDate>Thu, 09 May 2024 19:30:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b72b6960-5e11-4622-a920-52e3a3504271</guid><dc:creator>sero</dc:creator><description>&lt;p&gt;By the way, I&amp;#39;m using NRF Connect SDK v2.6.1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>