<?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>Advertising causes timer1 delay?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/6928/advertising-causes-timer1-delay</link><description>My project: nRF51422, S110, based on SDK 7.1. 
 My project employs several application timers (run via the scheduler) and a continuously running Timer1-based 1ms timestamp counter. Timer1 increments a static counter variable on each CC0 interrupt. An</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Jul 2016 07:38:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/6928/advertising-causes-timer1-delay" /><item><title>RE: Advertising causes timer1 delay?</title><link>https://devzone.nordicsemi.com/thread/24435?ContentTypeID=1</link><pubDate>Thu, 07 Jul 2016 07:38:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98fe2a99-37b9-4757-8af6-63985c170809</guid><dc:creator>hawk</dc:creator><description>&lt;p&gt;@stefan， we have the external crystal oscillator，// Initialize the SoftDevice handler module.
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false); the detail is described in this url： &lt;a href="https://devzone.nordicsemi.com/question/86089/app-timer-has-some-delay/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising causes timer1 delay?</title><link>https://devzone.nordicsemi.com/thread/24434?ContentTypeID=1</link><pubDate>Wed, 06 Jul 2016 11:18:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d5f1e02-ebf0-4d8e-9f51-f02769230a8a</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;@hawk    The app timer uses RTC1 in the background which in turns uses 32kHz clock source. What clock source are you using? The app_timer drift can be caused by the drift of the clock source chosen.&lt;/p&gt;
&lt;p&gt;How to choose a clock source:  When you initialize and enable the softdevice by calling ble_stack_init, you have several clock source options which either use external 32kHz crystal or internal 32kHz RC oscillator. If you use the RC, the accuracy is 250ppm, when you use crystal, it usually has better accuracy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising causes timer1 delay?</title><link>https://devzone.nordicsemi.com/thread/24433?ContentTypeID=1</link><pubDate>Tue, 05 Jul 2016 05:37:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:324f99bd-bda3-4cbf-80d1-4dad088b8b49</guid><dc:creator>hawk</dc:creator><description>&lt;p&gt;I use the old SDK 5.2.0 and S110 6.0.0; I use the app timer to count sec,min,hour(make one time clock), and found that the second of mine is less after i set an initial sec/min/hour and run for some days. how to avoid delay the app timer of old SDK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising causes timer1 delay?</title><link>https://devzone.nordicsemi.com/thread/24431?ContentTypeID=1</link><pubDate>Tue, 12 May 2015 13:27:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ab3348d-6cb6-4061-ad03-3797a61f5485</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;To decrease the CPU blocking time, you do not need SDK 8.0.0/8.1.0 + S110 8.0.0. You can continue using SDK 7.1.0 and S110 7.1.0 and &lt;a href="https://devzone.nordicsemi.com/question/18751/how-to-unblock-the-cpu-during-connection-intervals-with-s110-v710/"&gt;unblock the CPU&lt;/a&gt; in order to have maximum latency less than 1ms during advertising.  But again, unblocking the CPU will only work if you have third revision nRF51.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising causes timer1 delay?</title><link>https://devzone.nordicsemi.com/thread/24432?ContentTypeID=1</link><pubDate>Fri, 08 May 2015 12:43:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f782a58-ed96-4eb0-9aea-f33177ca9baa</guid><dc:creator>gwayne</dc:creator><description>&lt;p&gt;Thanks for your response.  I attempted to update my project to 8.0 a while ago, but ran into a number of issues and had to back off.  The changes were difficult to reconcile and frequently undocumented.  Updating to 8.0 is probably the best ultimate best solution, so I plan to try once again.  For now 10ms of resolution works well enough for this project to move forward.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising causes timer1 delay?</title><link>https://devzone.nordicsemi.com/thread/24430?ContentTypeID=1</link><pubDate>Thu, 07 May 2015 12:34:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02266aa8-a145-4fd1-aa0f-961e80660aad</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I think your assumption is correct. The peripheral will send an advertising packet, then start the RX receiver in order to listen for a potential connection request or scan request. If the central device is an active scanner (i.e. sends a scan request) the peripheral will respond with a scan response packet, which will increase the blocking time of the CPU.&lt;/p&gt;
&lt;p&gt;IOS generally performs active scanning when the IOS app is in the foreground, which explains the behavior. When the peripheral is advertising and does not send scan response packet, I suspect the CPU is blocked for less than 1 ms, but when sending scan response packet the CPU is blocked for more than 1 ms.&lt;/p&gt;
&lt;p&gt;If the CPU is blocked during two consecutive Timer1 interrupts, you will lose one interrupt, i.e. for two timer1 interrupts, the counter will only be incremented once.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I suspect the problem can be solved by using third revision nRF51 hardware and softdevice 110 7.1+ which allows for the CPU to be used during radio activity. See &lt;a href="https://devzone.nordicsemi.com/question/18751/how-to-unblock-the-cpu-during-connection-intervals-with-s110-v710/"&gt;this thread&lt;/a&gt; how to unblock the CPU for S110 v7.1.0 (only works with third revision nRF51, see &lt;a href="https://www.nordicsemi.com/eng/nordic/Products/nRF51822/ATTN-51/41917"&gt;comp matrix&lt;/a&gt; for what nRF51 devices are third revision). For S110 v8.0.0, the CPU is unblocked by default.&lt;/p&gt;
&lt;p&gt;If you look at the S110_softdevice Specification version 1.3 (targeted at softdevice 7.0.0), section 11.3.1, you see that the softdevice can block the CPU up to 1700 us. If you however look at the same section in S110_softdevice Specification version 2.0 (targeted at softdevice 8.0.0), you see the CPU blocking time during advertising is only 440 us.&lt;/p&gt;
&lt;p&gt;An idea of a workaround is to use Timer1 with 1ms interrupt frequency and use Timer2 as counter, and let Timer1 CC0 event trigger a counter task on Timer2 trough a PPI channel. That way, no CPU is needed to increment the ms counter.&lt;/p&gt;
&lt;p&gt;Another dirty workaround would be to advertise with whitelist. The peripheral will not send scan response packet to a central that is not in the whitelist.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>