<?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>Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42239/running-critical-time-constrained-task-during-ble-communication</link><description>Our products are based on nrf52832 / nrf52840 chips as application mcu which run freeRTOS. 
 One of high priority task implements algorithm for controlling motor (using QDEC and PWM embedded modules) and it is critical time constrained task e.g. it should</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Jan 2019 09:36:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42239/running-critical-time-constrained-task-during-ble-communication" /><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/165380?ContentTypeID=1</link><pubDate>Mon, 14 Jan 2019 09:36:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb4db531-3928-4fa0-a0c5-5d5593cb9eca</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I had to ask my Colleague to give his opinion on this one. He said&lt;/p&gt;
&lt;p&gt;&amp;quot;If you&amp;nbsp;just want to time beacon events in between the critical events. You could do that if you uses a custom advertiser, of course you will not be able to compy with the spec forr the random time component, but I think it should be ok apart from that. If you alse controls the other end you might want to use a custom protocol&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/164889?ContentTypeID=1</link><pubDate>Thu, 10 Jan 2019 11:53:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0fb20bc-e878-4d2e-8953-c0af8579eea8</guid><dc:creator>yes</dc:creator><description>&lt;p&gt;Regarding Beacon:&lt;/p&gt;
&lt;p&gt;BLE communication is controlled by the client and it is a-synchronized to server tasks i.e. a-synchronized high priority interrupts when server receives client periodically communication which&amp;nbsp;follow by connection interval.&lt;/p&gt;
&lt;p&gt;When Beacon is used it can be synchronized to idle time between critical tasks and its schedule is controlled totally by the server.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It is one directional communication i.e. the server buffers data and broadcasts it as part of low task during critical task idle time.&lt;/p&gt;
&lt;p&gt;The idle time of critical task is known or atleast can be calculated per cycle and only if it long enough Beacon message can be sent by the server.&lt;/p&gt;
&lt;p&gt;Obviously Beacon data isn&amp;#39;t&amp;nbsp;secured and open for all observers in range.&amp;nbsp;If encryption is needed it should be part of the application (not required for our specific case)&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/164878?ContentTypeID=1</link><pubDate>Thu, 10 Jan 2019 11:30:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:175b45a4-2131-4955-9cbe-ddff10b5c4de</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="yes"]-&amp;gt;&amp;nbsp; time constrained tasks can&amp;#39;t be run as part of the application or their timing should be flexible enough for timing deviation caused by SD.[/quote]
&lt;p&gt;&amp;nbsp;This is absolutely correct.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="yes"]2) Does using Beacon which its transmission time can be controlled by application is practical for workaround this issue?&amp;nbsp;[/quote]
&lt;p&gt;Can you please tell me more on why you think the softdevice activity will be different in the case of a Beacon? I think beacon is just a special type of advertisement and the underlying softdevice activity is similar to advertising role of the device.&lt;/p&gt;
[quote user="yes"]3) Any other suggestion for solving this issue?[/quote]
&lt;p&gt;You can disable the softdevice (get disconnected) and have your motor task running and buffering the results that needs to be transmitted to the peer. Else you can use a long connection interval, in which case you will have a lot of slots between each connection interval for the motor controlling task to run and once every connection interval, the motor task will be masked by the SD. If your application can survive this, then it is currently a simple work around to just increase the connection interval to say 200ms and you will have your motor task running for 200/3 = 66 times before it is blocked once (maybe twice).&lt;/p&gt;
&lt;p&gt;If the above scenario does not fit your needs, then you need to have a dual core system where the BLE stack is running on one and the application has a dedicated CPU to run its time critical tasks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/164693?ContentTypeID=1</link><pubDate>Wed, 09 Jan 2019 11:46:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8db18668-4731-43ad-84cd-74385a82dfbf</guid><dc:creator>yes</dc:creator><description>&lt;p&gt;If I may summarize above discussion:&lt;/p&gt;
&lt;p&gt;SD has priority 0 which can&amp;#39;t be changed (it is not exposed to application developer) and its interrupts should not be masked&lt;/p&gt;
&lt;p&gt;According to&amp;nbsp;&lt;a href="https://www.novelbits.io/bluetooth-5-speed-maximum-throughput/" rel="noopener noreferrer" target="_blank"&gt;link&lt;/a&gt;&amp;nbsp;connection interval (aka timing deviation) can&amp;nbsp;be (1M bits PHY) between&amp;nbsp; ~ 0.5&amp;nbsp; - 2.5 mSec&amp;nbsp; &amp;nbsp; &amp;nbsp; ( for empty packet&amp;nbsp; and&amp;nbsp;247 Bytes data packet, respectively).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-&amp;gt;&amp;nbsp; time constrained tasks can&amp;#39;t be run as part of the application or their timing should be flexible enough for timing deviation caused by SD.&lt;/p&gt;
&lt;p&gt;1) Do I miss something?&lt;/p&gt;
&lt;p&gt;2) Does using Beacon which its transmission time can be controlled by application is practical for workaround this issue?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;3) Any other suggestion for solving this issue?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1547036190364v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/164687?ContentTypeID=1</link><pubDate>Wed, 09 Jan 2019 10:59:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81c140e5-5c5a-40a2-a004-2ebd4b9e29a8</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;SD should have highest priority for its link layer activities. Most of the other tasks can be done at a lower priority. But Priority 0 is reserved for softdevice, so application cannot use it. This makes the design for both softdevice and application simple.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/164590?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 21:05:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6bf87b6e-d430-46c1-a78f-466665a9b2e8</guid><dc:creator>yes</dc:creator><description>&lt;p&gt;According to your clarification above, SD task should have the highest priority of all tasks in the system, otherwise higher priority task might cause BLE communication error&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/164584?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 19:27:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92966452-48cf-495f-a968-8086891f938e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;It is not about correcting the missing ticks, its about missed housekeeping it needs to do in its many layers (Link Layer/Host/Gatt) at the exact time + it most likely need to reply to the peer at the exact time. Missing few micro seconds might already get it out of the spec and impossible to get qualified. Hence, as a rule of thumb you never should mask SD interrupts as you do not know as an application what type of house keeping SD is doing to maintain the connection or any other role.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/164578?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 18:59:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e9891b9-da8f-4615-8bbf-5a79ff164455</guid><dc:creator>yes</dc:creator><description>&lt;p&gt;Doesn&amp;#39;t SD know to recovery from lost of one cycle?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running critical time constrained task during BLE communication</title><link>https://devzone.nordicsemi.com/thread/164573?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 17:25:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac33c229-f8f6-49a1-9b2d-8dcc55494a4c</guid><dc:creator>Turbo J</dc:creator><description>[quote userid="71582" url="~/f/nordic-q-a/42239/running-critical-time-constrained-task-during-ble-communication"]1) Masking BLE interrupts at enter to critical task and unmasking when the critical task is yielded&amp;nbsp; - How would it influence on BLE communication?[/quote]
&lt;p&gt;BLE communication won&amp;#39;t work. The softdevice requires tight timings, and checks whether those are met in code.&lt;/p&gt;
&lt;p&gt;You will get errors when sd detects timing violations, which are usually followed by a device reset. Check softdevice specifications for a more detailed description.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>