<?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>Drift between HFCLK TIMERs over time</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44831/drift-between-hfclk-timers-over-time</link><description>I have two TIMER instances, TIMER1 and TIMER2, both setup to Clear Mask on timeout (aka restart). I use TIMER1 and PPI to trigger ADC measurements every 5msec. In the ADC handler I add measurements to a queue of size 100. I used TIMER2 to trigger burst</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 15 Mar 2019 17:34:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44831/drift-between-hfclk-timers-over-time" /><item><title>RE: Drift between HFCLK TIMERs over time</title><link>https://devzone.nordicsemi.com/thread/176514?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 17:34:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58998274-9fbd-4f96-936d-22c11b26a3b0</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Thanks for the info Edvin, this helps clear up this issue&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Drift between HFCLK TIMERs over time</title><link>https://devzone.nordicsemi.com/thread/176412?ContentTypeID=1</link><pubDate>Fri, 15 Mar 2019 13:15:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e4e3594-218a-4f4c-8ef3-6a26a714f452</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I see.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My assumption is that when you use the Timer + PPI to trigger events every 5ms, you probably reset the timer count on this event, is that correct?&lt;/p&gt;
&lt;p&gt;The issue is that it takes a couple of ticks to actually do this. If you reset one timer every 5th ms, and the other timer every 500ms, then the 5ms timer is reset 100 times as often as the other. After a while this will lead to a large difference. I have not done the maths, but it sounds plausible that this is the cause.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;From &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fppi.html&amp;amp;cp=2_1_0_21&amp;amp;anchor=concept_sxf_21l_1s" rel="noopener noreferrer" target="_blank"&gt;this page&lt;/a&gt;&amp;nbsp;(sorry for old link, but it is difficult to link to the nRF52832 specification in the new DocLib libraries) :&lt;/p&gt;
&lt;p&gt;&lt;em&gt;On each PPI channel, the signals are synchronized to the 16 MHz clock, to avoid any internal violation of setup and hold timings. As a consequence, events that are synchronous to the 16 MHz clock will be delayed by one clock period, while other asynchronous events will be delayed by up to one 16 MHz clock period.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The question is how you set up the Clear mask. Do you fork it, or do you short it?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;From the same page:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note that shortcuts (as defined in the SHORTS register in each peripheral) are not affected by this 16 MHz synchronization, and are therefore not delayed.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So if you have shorted the clear mask:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;TIMER1-&amp;gt;SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk &amp;lt;&amp;lt; TIMER_RELOAD_CC_NUM; // TIMER_RELOAD_CC_NUM is just the the CC register that you want to reset on. Typically the same as the CC you use for your 5ms delay.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;this should not cause a delay.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, if you FORK this to the TIMER1-&amp;gt;EVENTS_COMPARE ppi channel, then it will be one clock period delay before it is cleared.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Edvin&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Drift between HFCLK TIMERs over time</title><link>https://devzone.nordicsemi.com/thread/176286?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2019 16:46:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e00d137-b087-4296-b4f3-93b0ce154d76</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I solved the issue by running everything off of the same TIMER instance.&amp;nbsp; However I&amp;#39;m still concerned seeing drifts between TIMER instances&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>