<?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>How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69739/how-to-manage-saadc-and-ble-run-in-parallel</link><description>I&amp;#39;m trying to send ADC data through BLE using nRF52840. 
 
 According to the example codes named ble_peripheral/ble_app_uart , peripheral/saadc , I wrote a code and it is able to transmit the data. 
 
 But the problem is that the throughput is about 850</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Jan 2021 11:08:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69739/how-to-manage-saadc-and-ble-run-in-parallel" /><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/288356?ContentTypeID=1</link><pubDate>Mon, 11 Jan 2021 11:08:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9885645-f10f-4021-b096-192dc2243f3e</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;No problem, I will consider the case closed then.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/288297?ContentTypeID=1</link><pubDate>Mon, 11 Jan 2021 05:46:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef6c6a11-8d83-47d6-ab56-0890cbb00b1e</guid><dc:creator>DL_November</dc:creator><description>[quote userid="2116" url="~/f/nordic-q-a/69739/how-to-manage-saadc-and-ble-run-in-parallel/287895#287895"]If you have assigned insufficient RAM to the SoftDevice then it will return an error when you try to enable it, and in the standard examples the required RAM settings will be printed to the log.&amp;nbsp;[/quote]
&lt;p&gt;Okay. As there is no error appears, I&amp;#39;ll suppose that enough size of ram is allocated to the SoftDevice. I&amp;#39;ll debug other parts of my code and entire system. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/287895?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 10:02:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fda680ff-8cc0-44fc-b2bb-5ec8e8aab47a</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;If you have chosen the RTT backend for the log library then it will show up in the Segger debug terminal, yes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you have assigned insufficient RAM to the SoftDevice then it will return an error when you try to enable it, and in the standard examples the required RAM settings will be printed to the log.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/287674?ContentTypeID=1</link><pubDate>Wed, 06 Jan 2021 10:29:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ea0e443-0f12-4b72-9bf5-2197d6dde75f</guid><dc:creator>DL_November</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
[quote userid="2116" url="~/f/nordic-q-a/69739/how-to-manage-saadc-and-ble-run-in-parallel/287659#287659"]Did you try to run the code and check the log output?[/quote]
&lt;p&gt;I checked the debug terminal in SEGGER embedded studio. I&amp;#39;m not sure whether this is the log output.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/287669?ContentTypeID=1</link><pubDate>Wed, 06 Jan 2021 10:09:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8dd97fa8-dea3-4dfe-b14e-f9205b076790</guid><dc:creator>DL_November</dc:creator><description>&lt;p&gt;I did not notice that UART &amp;amp;nus handler may slow down the application which runs in high data throughput.&lt;/p&gt;
&lt;p&gt;But, I need to pass through the BLE data to the PC via serial, I think there will be works to be done if I change to the gatts example...&lt;/p&gt;
&lt;p&gt;Thank you for the suggestion and I&amp;#39;ll try if nus example is not sufficient for me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/287659?ContentTypeID=1</link><pubDate>Wed, 06 Jan 2021 09:44:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d46301cb-c88d-4f60-bd21-46a69fd5af6a</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Did you try to run the code and check the log output?&lt;/p&gt;
&lt;p&gt;The SoftDevice will return an error if you assign insufficient RAM to it, and you have to adjust the SoftDevice RAM assignment based on the returning log message.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can find more information about this in the following guide:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/adjustment-of-ram-and-flash-memory"&gt;https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/adjustment-of-ram-and-flash-memory&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/287369?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 02:21:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a84103eb-a1c0-4400-9fb4-7ecc57106383</guid><dc:creator>Henry_Chou</dc:creator><description>&lt;p&gt;I suggest that you can use the gatts example instead of nus. Because your application is more faster throughput. But nus throughput is affected by MTU number and UART &amp;amp;nus handler (ASCII code to real byes) . You may refer \nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_gatts_c&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/287365?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 02:05:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:314b0b1c-f8e0-49ef-b065-cd0595968f34</guid><dc:creator>DL_November</dc:creator><description>&lt;div class="edit_box___1KtZ3 active___3VPGL" id="txtTarget"&gt;[quote userid="2116" url="~/f/nordic-q-a/69739/how-to-manage-saadc-and-ble-run-in-parallel/287232#287232"]The buffer size is based on the&amp;nbsp;NRF_SDH_BLE_GAP_EVENT_LENGTH parameter in sdk_config.h.&amp;nbsp;[/quote]&lt;/div&gt;
&lt;div class="edit_box___1KtZ3 active___3VPGL"&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;I changed the NRF_SDH_BLE_GAP_EVENT_LENGTH from 400 to 800. However, when I checked memory usage in SES debugging mode, only 32.5 KB of 256 KB are used no matter of the NRF_SDH_BLE_GAP_EVENT_LENGTH.&lt;/p&gt;
&lt;p&gt;Is there something I have to change more than sdk_config.h?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/287232?ContentTypeID=1</link><pubDate>Mon, 04 Jan 2021 13:07:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef518050-4baf-4301-94fb-a030426e6635</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The buffer size is based on the&amp;nbsp;NRF_SDH_BLE_GAP_EVENT_LENGTH parameter in sdk_config.h.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The larger this parameter the more buffer size will be allocated in the SoftDevice, but the drawback is that you need to allocate more RAM to the SoftDevice as well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;All the SoftDevice buffers are placed in RAM, not in flash, so you are limited by the amount of RAM available in the nRF device.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/287112?ContentTypeID=1</link><pubDate>Mon, 04 Jan 2021 01:43:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61d0b0f1-bce4-45aa-9af6-981faf512853</guid><dc:creator>DL_November</dc:creator><description>[quote userid="2116" url="~/f/nordic-q-a/69739/how-to-manage-saadc-and-ble-run-in-parallel/286869#286869"]As long as NRF_SUCCESS is returned from the nus_data_send() function the data will be buffered in the SoftDevice, and&amp;nbsp;all the packets buffered in the SoftDevice will be transmitted in sequence as soon as the next connection event occurs.&amp;nbsp;[/quote]
&lt;p&gt;Sorry for the late reply.&lt;/p&gt;
&lt;p&gt;Then, how much data can be buffered in the SoftDevice? Does it have additional memory than 1 MB flash of nRF52840?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/286869?ContentTypeID=1</link><pubDate>Tue, 29 Dec 2020 14:48:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dbe73a8-738a-4d36-ace4-815372daa46b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
[quote user="DL_November"]So, I want to be sure that if I call ble_nus_data_send() functions too fast, then are the data stored in some buffer and transmitted consecutively?[/quote]
&lt;p&gt;As long as NRF_SUCCESS is returned from the nus_data_send() function the data will be buffered in the SoftDevice, and&amp;nbsp;all the packets buffered in the SoftDevice will be transmitted in sequence as soon as the next connection event occurs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In case you have packet loss over the air the SoftDevice might have to retransmit a packet several times before it is received on the other side, so you can&amp;#39;t know exactly how much time it will take to send each packet, but a packet stored in the SoftDevice buffer will never be dropped unless a disconnect occurs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If&amp;nbsp;&lt;span&gt;NRF_ERROR_RESOURCES is returned then no data is sent to the SoftDevice buffer,&amp;nbsp;and it is the responsibility of the application to upload the data again later (or allow it to be dropped).&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In order to be more robust to data transmission delays over the BLE link I would recommend that you use a ring buffer in the application to receive ADC data, and&amp;nbsp;use this as an intermediary buffer between the ADC and the BLE connection. Then you will have some additional buffer for ADC data in case of Bluetooth delays, and once the Bluetooth stack is able to send more data again it can be quickly fed by the buffer.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;With such a system you can fill the ringbuffer in the saadc callback, and empty it from the main loop, which allows the ADC to run more seamlessly in the background even when the SoftDevice is delayed by packet loss.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;A side effect of this is that the average latency could increase, but it should lead to more stable transmission.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/286677?ContentTypeID=1</link><pubDate>Mon, 28 Dec 2020 10:25:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59fcd64c-fc54-4ae2-b1c0-73e0463e2ddb</guid><dc:creator>DL_November</dc:creator><description>&lt;p&gt;Maybe my question was not good...&lt;/p&gt;
&lt;p&gt;So, I want to be sure that if I call ble_nus_data_send() functions too fast, then are the data stored in some buffer and transmitted consecutively?&lt;/p&gt;
&lt;p&gt;Or, the device or SoftDevice or somewhat waits until the transmission is possible and send data and then go back to ADC work?&lt;/p&gt;
&lt;p&gt;Or, lastly, there is no buffer in default so if I can not send data via BLE, then the data just disappear and the next ADC data are sent?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/286400?ContentTypeID=1</link><pubDate>Wed, 23 Dec 2020 02:05:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d932af03-7e18-423c-a634-3464c39c271f</guid><dc:creator>DL_November</dc:creator><description>[quote userid="2116" url="~/f/nordic-q-a/69739/how-to-manage-saadc-and-ble-run-in-parallel/286307#286307"]Do you repeatedly receive the NRF_ERROR_RESOURCES return code when trying to upload data?[/quote]
&lt;p&gt;&amp;nbsp;When I run the code in debug mode, I can see the NRF_ERROR_RESOURCES appear.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;But I&amp;#39;m afraid of delaying Bluetooth transmission to be delayed due to the ADC.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;To be more specific, the ble_nus_data_send() function only puts data into the Bluetooth stack then the transmission is done in parallel no matter of other codes I uploaded. Is this how the SoftDevice works?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/286307?ContentTypeID=1</link><pubDate>Tue, 22 Dec 2020 13:31:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:042ba62c-d249-462e-83f3-d2f47208bb3a</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Do you repeatedly receive the NRF_ERROR_RESOURCES return code when trying to upload data?&lt;/p&gt;
&lt;p&gt;If you are not receiving this it means the application is not able to push data to the Bluetooth stack quickly enough, which will reduce the overall throughput.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/286190?ContentTypeID=1</link><pubDate>Tue, 22 Dec 2020 01:40:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf921716-b80f-4389-ad5e-eae1c70491c3</guid><dc:creator>DL_November</dc:creator><description>&lt;p&gt;I&amp;#39;ve set SAMPLES_IN_BUFFER to 240. And I set MTU = 247 and turned on the data length extension option. Also, I checked 240 bytes of data are received in a client device.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to manage SAADC and BLE run in parallel</title><link>https://devzone.nordicsemi.com/thread/286097?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 15:16:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8444bab-7253-4ca1-8aa4-ac733206864f</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is your&amp;nbsp;SAMPLES_IN_BUFFER parameter set to?&lt;/p&gt;
&lt;p&gt;In order to achieve the maximum possible throughput it is necessary to adjust the packet length depending on the data length that is exchanged during the connection establishment.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you know what connection parameters, data length and ATT MTU settings you are using for the connection?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>