<?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>BLE affects TIMER1/2 accuracy</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/13919/ble-affects-timer1-2-accuracy</link><description>Hi, 
 I&amp;#39;m building a product using RF Digital&amp;#39;s Simblee that uses the nrF51822 ver 3 chip. I&amp;#39;ve narrowed down a TIMER accuracy issue to BLE. The code below starts and stops TIMER1 (16 bit, prescaler=9) on low-to-hi and hi-to-low, respectively, of a GPIO</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 May 2016 14:53:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/13919/ble-affects-timer1-2-accuracy" /><item><title>RE: BLE affects TIMER1/2 accuracy</title><link>https://devzone.nordicsemi.com/thread/53204?ContentTypeID=1</link><pubDate>Mon, 23 May 2016 14:53:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d6fae51-b384-4ba2-97e6-ec26a0257a53</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Thanks Aryan. You are correct. Unfortunately my app does not have access to the softdevice API. The Simblee designers have acknowledged the issue and will fix in a future release, hopefully by exposing the hfclk softdevice calls so my app, as you suggest, can call sd_clock_hfclk_request after calling SimbleeBLE.begin(). Many thanks for your help with this Aryan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE affects TIMER1/2 accuracy</title><link>https://devzone.nordicsemi.com/thread/53205?ContentTypeID=1</link><pubDate>Fri, 20 May 2016 07:20:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9cacf81-b37f-41b8-9a50-d2fd9896465d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;RTC does not use HFCLK, it only works on LFCLK.&lt;/p&gt;
&lt;p&gt;The softdevice keeps and internal counter for requests and release of HFCLK. So you have to request the HFCLK through softdevice API for it to know that the app explicitly requested HFCLK XTAL.  Otherwise it will turn it on and off as per own usage.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;When you change the LFCLK to XTAL before begin(), it does not matter as the begin function will change it anyways (if it is not using XTAL).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Seems like your application before calling SimbleeBLE.begin(); has started Xtal HFCLK. This means that the softdevice have no idea about this and will assume that after enabling it no one else apart from it is using Xtal HFCLK. You have to change you code little bit here.&lt;/p&gt;
&lt;p&gt;. first enable softdevice&lt;br /&gt;
. request hfclk xtal using softdevice api sd_clock_hfclk_request. If you do not have access directly to softdevice API then ask the team who has to expose that API to you.
. Now configure your Timer&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;What we will achieve here is to let softdevice know that you are a user of the xtal hfclk. and Keep it on after it has finished its calibration. I would expect this to work for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE affects TIMER1/2 accuracy</title><link>https://devzone.nordicsemi.com/thread/53203?ContentTypeID=1</link><pubDate>Thu, 19 May 2016 22:23:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb9853fe-aef8-485e-a04b-a34c9dfef30d</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Thanks Aryan. The call to SimbleeBLE.begin() starts the softdevice. Unfortunately I don&amp;#39;t have access to that code. Before calling SimbleeBLE.begin(), I change the LFCLK source to Xtal and no difference in behaviour. I did notice something interesting though. When I check the NRF_CLOCK-&amp;gt;HFCLKSTAT register before calling SimbleeBLE.begin(), I get the value 0x00010001, which, according to the Nordic nRF51822 v3 reference manual, means the HFCLK source is Xtal (16 MHz HFCLK crystal). After calling SimbleeBLE.begin(), the NRF_CLOCK-&amp;gt;HFCLKSTAT register changes to 0x00010000, which means the HFCLK source is now RC (16 MHz RC oscillator). Unlike LFCLK, I don&amp;#39;t see a task for setting the HFCLK source. Regardless, though, I presume I can&amp;#39;t change it once the softdevice has started. Also interesting, if I repeat the above test using RTC1 instead of TIMER1, RTC1 values are accurate. Thoughts? Thx!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE affects TIMER1/2 accuracy</title><link>https://devzone.nordicsemi.com/thread/53202?ContentTypeID=1</link><pubDate>Thu, 19 May 2016 06:41:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7350bd90-b67d-4f75-bf73-a737184dd9b9</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;You said that the capture value is always 31589 ±3 when you start BLE, this is very interesting. What LFCLK clock are you using when you enable the softdevice? is it RC LFCLK with regular calibration? If so, the calibration of RC clock starts crystal HFCLK until the calibration is done. This could affect the accuracy of the TIMER because of the switch happening many times during these two seconds?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE affects TIMER1/2 accuracy</title><link>https://devzone.nordicsemi.com/thread/53201?ContentTypeID=1</link><pubDate>Wed, 18 May 2016 05:57:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83aca1f6-bacf-490a-b61c-7c2079c9a9c6</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Thanks RK. I think I share your understanding. I realize that interrupt routine calls can be delayed due to softdevice priority. As I see it, my code &lt;em&gt;does&lt;/em&gt; use PPI (simblee_ppi_channel_assign), along with GPIOTE, to start and stop the timer according to the function generator&amp;#39;s 1 second pulse. Before my interrupt routine is called, PPI has already stopped the timer, so no matter what the delay is into the interrupt routine, the timer value should reflect the duration of the 1 second pulse. The interrupt routine then clears the timer to get ready for the next pulse. This code is just for investigation purposes. You give me hope that using TIMER, PPI and GPIOTE, I can get a stable, accurate timer. Thx.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE affects TIMER1/2 accuracy</title><link>https://devzone.nordicsemi.com/thread/53200?ContentTypeID=1</link><pubDate>Wed, 18 May 2016 03:12:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecee9657-7e94-46bf-9026-20f7aa17be0f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;oh note you can probably get the cycle more to the correct length by using the SHORT between COMPARE and CLEAR instead of clearing in your IRQ handler - however the result of that will just be to get the average period about right, but increase the amount of variability your IRQ handler gets called with.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE affects TIMER1/2 accuracy</title><link>https://devzone.nordicsemi.com/thread/53199?ContentTypeID=1</link><pubDate>Wed, 18 May 2016 02:35:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ac18509-72fa-4750-a772-eee6c40e65f5</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Yes - do a search - this is discussed many times a week.&lt;/p&gt;
&lt;p&gt;The softdevice has a higher interrupt priority than anything else, it has to have, it has critical timing requirements. So your interrupt can get delayed by up to several milliseconds, the more the bluetooth stack does, the more you get delayed. All the timings are in the softdevice specification. Once you&amp;#39;re in a connection shoving data around, your delays are going to get only larger.&lt;/p&gt;
&lt;p&gt;You cannot do interrupt-based precise timings with the softdevice in use, it doesn&amp;#39;t work. You need to use PPI or the PWM module which Nordic provides which uses PPI to work independently of the softdevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>