<?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>Softdevice timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59489/softdevice-timer</link><description>Hey guys, 
 I&amp;#39;m working with SES, nRF52832 and SDK14.2.0. 
 
 I have a timing problem and would like to describe the problem from the beginning. 
 I have a 1-wire temperature sensor that is read by the slave and then the slave sends the sensor data to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 06 Apr 2020 10:13:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59489/softdevice-timer" /><item><title>RE: Softdevice timer</title><link>https://devzone.nordicsemi.com/thread/243598?ContentTypeID=1</link><pubDate>Mon, 06 Apr 2020 10:13:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfc3b12a-b69f-4266-bd30-5cf07a89c510</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Christoph,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;glad to hear that the answer helped. If you have related questions to this one, then you can reopen the thread again to ask more. For a different questions, please open a new ticket. This would help keep this thread clean and help others find relevant information easier. So I am marking this thread as verified and would be very happy to help you in your ongoing project questions in newer threads. There is no limit on on many threads you can create if you need assistance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Softdevice timer</title><link>https://devzone.nordicsemi.com/thread/243496?ContentTypeID=1</link><pubDate>Sun, 05 Apr 2020 10:08:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c03822f-5395-49e8-97c9-d8d58b5bf418</guid><dc:creator>Christoph_I</dc:creator><description>&lt;p&gt;Hey Susheel,&lt;br /&gt;&lt;br /&gt;I have recommended your first answer as &amp;quot;suggest answer&amp;quot;. I would prefer not to close this thread yet if there are other problems later on (because I currently have other projects in parallel). Is that ok for you?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Christoph&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Softdevice timer</title><link>https://devzone.nordicsemi.com/thread/242435?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 13:14:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4773d8b7-2c10-4715-82e7-621ac82725a4</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="Christoph_I"]First of all it&amp;#39;s good to know where the problem is (SD). Do you know how much time the SD needs to preprocess the RADIO? And maybe there are ways to increase accuracy?[/quote]
&lt;p&gt;&amp;nbsp;Christoph, &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsds_s132%2FSDS%2Fs1xx%2Fprocessor_avail_interrupt_latency%2Fprocessor_usage_patterns.html&amp;amp;cp=4_6_2_0_15_2"&gt;these &lt;/a&gt;pages are very useful for you to read to get understanding of the processor usage by the SD at different instances. One way to increase the accuracy is to use priority&amp;nbsp; 2 or 3 for the timer (configurable in sdk_config.h) so that Bluetooth host does not mask timer callbacks (the problem with this is that at this higher priority callabcks you cannot call any SVC calls, that is you cannot call any softdevice API that looks like sd_xxxx()). The activity in the link layer will still have higher priority since it operates with interrupt priority 0 (highest).&amp;nbsp;&lt;/p&gt;
[quote user="Christoph_I"]Do you know how to create a time stamp on the slave?[/quote]
&lt;p&gt;There are many ways to generate a software timestamp based on the underlying hardware RTC. If you search the devzone you will find many such threads where many users achieved it in a different way, one such example is &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/58923/timestamp-in-nrf52832/239187#239187"&gt;this &lt;/a&gt;one.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Softdevice timer</title><link>https://devzone.nordicsemi.com/thread/242177?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 19:32:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d800c724-e8a9-4f6c-aa12-635ab7b83502</guid><dc:creator>Christoph_I</dc:creator><description>&lt;p&gt;Hey Susheel, &lt;/p&gt;
&lt;p&gt;thank you for your reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/59489/softdevice-timer/241996"]I guess the problem here is that you are doing all this in the connected state which includes a bit of softdevice activity which has higher priority than any other activity in your application.&amp;nbsp;[/quote]
&lt;p&gt;Thats right. &amp;nbsp;I measure the time (timer 2) and run a timer (timer 1 for sending every second) in the connected state, whereby timer 2 only shows random values ​​on the slave side and shows usable values ​​on the master side (when programmed on master side). First I try to measure the temperature conversion time with SD when SD is not connected. (Because I only measured the time in the peripheral example, i.e. in a project without a soft device.)&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Second, i will change the timer irq priority as you recommended. And then I measure again.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/59489/softdevice-timer/241996"]The slave program won&amp;#39;t be able to transmit exactly after 1 second as SD might steal the CPU for some pre processing of RADIO at that exact time. We cannot guarantee that the timer callbacks are called without any delays when they are used alongside the SD while there is a BLE connection. That probably is the reason that you see few milliseconds delay on when you are transmitting the byte in the slave end. And the byte is not guaranteed to be transmitted as soon as you call the BLE send API. The softdevice needs to know if there is enough connection event slot left to be able to send the data or it need to wait until the next connection event started.[/quote]
&lt;p&gt;First of all it&amp;#39;s good to know where the problem is (SD). Do you know how much time the SD needs to preprocess the RADIO? And maybe there are ways to increase accuracy? &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/59489/softdevice-timer/241996"]Out of curiosity, why can&amp;#39;t your master sustain a delay of few milliseconds in getting the temperature sensor data. What application is this that requires the temperature to be sent exactly at 1 second without any delays? Just trying to understand.[/quote]
&lt;p&gt;For your understanding: We have a device in which the temperature sensor and our slave are loacted. The slave should send a measured value to the master every one second (as precisely and constantly as possible). On the one hand the master should store the temperature value and show it on the display on the other.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Do you know how to create a time stamp on the slave?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Christoph&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Softdevice timer</title><link>https://devzone.nordicsemi.com/thread/241996?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 07:18:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e915afe-24b2-4878-8485-d22387ec9cb4</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Christoph,&lt;/p&gt;
&lt;p&gt;I guess the problem here is that you are doing all this in the connected state which includes a bit of softdevice activity which has higher priority than any other activity in your application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First suggestion is to change your timer irq priority which is inside&amp;nbsp;NRF_DRV_TIMER_DEFAULT_CONFIG. The default one I think is using&amp;nbsp;TIMER_DEFAULT_CONFIG_IRQ_PRIORITY which is 6 which is a bit low. You can change that to app priority 3 for example.&lt;/p&gt;
[quote user=""]Here I get values ​​in 1 second intervals, but the values ​​fluctuate very strongly (up to 200 ms) ... That means the master gets values ​​in an interval between 0.8 and 1.2 seconds,[/quote]
&lt;p&gt;The slave program won&amp;#39;t be able to transmit exactly after 1 second as SD might steal the CPU for some pre processing of RADIO at that exact time. We cannot guarantee that the timer callbacks are called without any delays when they are used alongside the SD while there is a BLE connection. That probably is the reason that you see few milliseconds delay on when you are transmitting the byte in the slave end. And the byte is not guaranteed to be transmitted as soon as you call the BLE send API. The softdevice needs to know if there is enough connection event slot left to be able to send the data or it need to wait until the next connection event started.&lt;/p&gt;
&lt;p&gt;Out of curiosity, why can&amp;#39;t your master sustain a delay of few milliseconds in getting the temperature sensor data. What application is this that requires the temperature to be sent exactly at 1 second without any delays? Just trying to understand.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>