<?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>Accurate Time Capture</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28600/accurate-time-capture</link><description>Hi guys, I&amp;#39;m using a HFCLK TIMER to time ADC sample capturing via PPI. This eliminates CPU+BLE usage from affecting my time keeping. I assume that each ADC sample arrives in my callback within usec variance from my timing. 
 I&amp;#39;m trying to get 10msec</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Sep 2019 20:14:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28600/accurate-time-capture" /><item><title>RE: Accurate Time Capture</title><link>https://devzone.nordicsemi.com/thread/209939?ContentTypeID=1</link><pubDate>Mon, 16 Sep 2019 20:14:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11b034ad-1088-4e78-b25a-d0d94a68fcb3</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Requesting the HFCLK before running sampling eliminated the jitter causes by the Crystal ramp-up time and thus more accurate data.&amp;nbsp; &amp;nbsp;ISRs still execute with some jitter due to BLE events.&amp;nbsp; However the time the data was captured at was accurate&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accurate Time Capture</title><link>https://devzone.nordicsemi.com/thread/208025?ContentTypeID=1</link><pubDate>Wed, 04 Sep 2019 16:28:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:417fa83d-d933-4430-a204-495f7e00c987</guid><dc:creator>Cy</dc:creator><description>&lt;p&gt;Hey Dave, How did Torbjorn&amp;#39;s suggestion work out for you?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accurate Time Capture</title><link>https://devzone.nordicsemi.com/thread/113351?ContentTypeID=1</link><pubDate>Mon, 18 Dec 2017 11:59:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0a29550-40d6-4893-9bab-ded50dcc87d1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Dave&lt;/p&gt;
&lt;p&gt;Most likely the issue is that you need to request the external high frequency clock to have it run all the time. You are correct that modules that need it will enable it implicitly, but they will only enable it just before they need it, and disable it again when the operation is complete (be it an ADC sample operation or a some radio activity).&lt;/p&gt;
&lt;p&gt;Try calling &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/group__nrf__drv__clock.html?cp=4_0_0_6_9_0_0_8#ga425c8dc0508bb9c0777da123b7c66f3d"&gt;nrf_drv_clock_hfclk_request(..)&lt;/a&gt; and see if it improves the situation.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;
Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accurate Time Capture</title><link>https://devzone.nordicsemi.com/thread/113348?ContentTypeID=1</link><pubDate>Sun, 17 Dec 2017 19:54:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:161bbd4b-558f-4981-a46f-f192d05c134b</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I suppose I could try and play around with enabling Constant Latency Mode.  I just haven&amp;#39;t it mentioned on here, and I&amp;#39;ve seen posts with people requiring far faster data acquisition that 100-150Hz on the ADC.  So I figure I must be missing something thats causing this time drift.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accurate Time Capture</title><link>https://devzone.nordicsemi.com/thread/113347?ContentTypeID=1</link><pubDate>Sun, 17 Dec 2017 19:09:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:edb00fdd-54ed-41ae-9887-3844dcade95c</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Thanks for the reply.  Burst mode is disabled so I believe that means Single-Shot.  I also disabled OVERSAMPLING in my config setup.   I should note that I have 3 channels configured in my ADC setup.&lt;/p&gt;
&lt;p&gt;I wasn&amp;#39;t aware of the requirement for turning on the HF_CLK.  Using the nrf_drv_saadc driver should take care of this.  However if the SD is shutting it off, then there will be start-up delay to turn on TIMER0 again to obtain the SAADC sample.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accurate Time Capture</title><link>https://devzone.nordicsemi.com/thread/113346?ContentTypeID=1</link><pubDate>Sun, 17 Dec 2017 18:30:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:604faac0-8edf-4393-ab52-5f9f8a29d223</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;Higher accuracy isn&amp;#39;t necessarily true, depends on your xtal choices.  Many of the specified 32MHz xtals are 10-20ppm same as the RTC. Plus higher accuracy RTC crystals are normally cheaper compared to 32MHz xtals. But if you don&amp;#39;t care about the power consumption of the HF CLK then by all means do it that way.&lt;/p&gt;
&lt;p&gt;Yes the sample sitting in the SAADC buffer assuming it is running single shot mode is the last sample you wanted.&lt;/p&gt;
&lt;p&gt;You should double check that it is running single shot, single sample in buffer (not averaging) and that you actually turned on HF_CLK.  The SD will always turn off HF_CLK during power manage and when it returns from power mange it is actually on HF_RC. Just search in the devzone on how to make sure it is on continuously.  As I recall the trick is to start it before starting the SD and the SD will leave it on.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accurate Time Capture</title><link>https://devzone.nordicsemi.com/thread/113350?ContentTypeID=1</link><pubDate>Sun, 17 Dec 2017 17:57:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e27ef7de-433a-4b4a-8d8d-ae18e89e56ee</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Thanks for the comment.  I have an RTC version as well, but I went with HFCLK due to the higher accuracy.  Power Consumption is less important then accuracy for me.&lt;/p&gt;
&lt;p&gt;I guess a question for Nordic would be, I know the SAADC ISR callback could be delayed due to BLE activity, but the value it contains (triggered from PPI/GPIOTE) should be from the correct time period right?  Meaning for example, since PPI/GPIOTE triggers every 10msec, even if BLE activity delays a given sample by 4msec, the value contain should still be the ADC value taken at the correct time (4msec ago).   Is this assumption valid?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Accurate Time Capture</title><link>https://devzone.nordicsemi.com/thread/113349?ContentTypeID=1</link><pubDate>Sun, 17 Dec 2017 17:01:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:850697a6-7aea-47d8-9be6-daf081446bbc</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;Everything you said is correct.  If you want accurate samples independent of the BLE stack the best way is PPI/GPIOTE.  You could use RTC1 to count out intervals and fire the SAADC event in single shot mode.  Then the sample shows up in the handler and can be processed at your leisure within your sample period. The ISR for the handler will trigger when the BLE stack isn&amp;#39;t active.  So latency can be up to a millisecond.&lt;/p&gt;
&lt;p&gt;It would be better to use LFCLK (ie, RTC) instead of HF_CLK as you intended.  The reason being is HF CLK uses gobs of power.  Whereas the RTC uses very little and is running anyway since the BLE stack needs it.  The RTC has a minimum resolution of 1/32768 of a sec or 0.0305 msec. Since RTC&amp;#39;s are always designed around base 2 you might want to rethink your time interval a bit to come with something base 2 savvy.&lt;/p&gt;
&lt;p&gt;Anyway, that does work.  If it&amp;#39;s not working for you then something is wrong with your code.  You will need to post your code for anyone to provide meaningful comments.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>