<?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>Time gap between each team sending data via BLE nrf52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102973/time-gap-between-each-team-sending-data-via-ble-nrf52840</link><description>Good day support team, 
 In my project, I save the packet of 60bytes then send it via BLE with ble_nus_data_send(). (20kHz sampling rate) 
 I set the timer = 50us. 
 uint16_t count; void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 Aug 2023 04:37:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102973/time-gap-between-each-team-sending-data-via-ble-nrf52840" /><item><title>RE: Time gap between each team sending data via BLE nrf52840</title><link>https://devzone.nordicsemi.com/thread/443082?ContentTypeID=1</link><pubDate>Fri, 25 Aug 2023 04:37:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:584c7137-1316-4b7e-9b35-c3d64bcb0f3c</guid><dc:creator>MinhDuc</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I increase the&amp;nbsp;&lt;span&gt;hvn_tx_queue_size, extend the connection event. I solve the problem.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;ble_cfg.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = 50;&lt;/p&gt;
&lt;p&gt;opt.common_opt.conn_evt_ext.enable = 1;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Time gap between each team sending data via BLE nrf52840</title><link>https://devzone.nordicsemi.com/thread/442885?ContentTypeID=1</link><pubDate>Thu, 24 Aug 2023 07:34:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d6c8b5c-d68b-4098-a70b-93d9f525cb10</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="MinhDuc"]But after that the function need ~30ms to complete sending the packet of 243 bytes. Why is it too long? Is there any way to fasten it?&amp;nbsp;[/quote]
&lt;p&gt;Hoang, There are a lot of variables that contributes to the delay in your send function. Most importantly, the priority of the timer handler function and if there are any other higher priority context running. I would suggest you to enable &lt;a href="https://www.zephyrproject.org/tracing-zephyr-applications-with-segger-systemview/"&gt;systemview debugging&lt;/a&gt;&amp;nbsp;to get an overview of all the contexts that are running in your application so you get a clear picture as to why you see that 30ms delay.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Time gap between each team sending data via BLE nrf52840</title><link>https://devzone.nordicsemi.com/thread/442392?ContentTypeID=1</link><pubDate>Tue, 22 Aug 2023 00:28:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:728b1e36-b6f6-4116-b347-6b07d54c374c</guid><dc:creator>MinhDuc</dc:creator><description>&lt;p&gt;I just want to update some information.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I put GPIO before and after ble_nus_data_send() function.&lt;/p&gt;
&lt;p&gt;In the first 4 cycle,&amp;nbsp;&lt;span&gt;ble_nus_data_send() need around &amp;lt; 100us to complete.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;But after that the function need ~30ms to complete sending the packet of 243 bytes. Why is it too long? Is there any way to fasten it?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Time gap between each team sending data via BLE nrf52840</title><link>https://devzone.nordicsemi.com/thread/442185?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2023 00:12:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56fd9e54-0e0f-40c7-a24b-a4755a0a9f9c</guid><dc:creator>MinhDuc</dc:creator><description>&lt;p&gt;Glad to hear you Nuguru.&lt;/p&gt;
&lt;p&gt;Here is my main while loop to send BLE.&lt;/p&gt;
&lt;p&gt;Actually I sent the packet of 240 data bytes and 3 bytes header. 60 bytes/channel&lt;/p&gt;
&lt;p&gt;while(true)&lt;br /&gt; { &lt;br /&gt; &lt;br /&gt; if (BLE_send_state == true &amp;amp;&amp;amp; ADC_SPI_state == true &amp;amp;&amp;amp; index_buffer &amp;lt; sizeof(data_save_buffer))&lt;br /&gt; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; uint16_t ADC_4 = read_ADC_reg(false,false,true,false,CONVERT_6);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; uint16_t ADC_5 = read_ADC_reg(false,false,true,false,CONVERT_7);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; uint16_t ADC_6 = read_ADC_reg(false,false,true,false,CONVERT_8);&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;uint16_t ADC_7 = read_ADC_reg(false,false,true,false,CONVERT_4);&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;uint16_t ADC_8 = read_ADC_reg(false,false,true,false,CONVERT_5);&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer] = (ADC_4 &amp;gt;&amp;gt; 0) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+1] = (ADC_4 &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+2] = (ADC_5 &amp;gt;&amp;gt; 0) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+3] = (ADC_5 &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+4] = (ADC_6 &amp;gt;&amp;gt; 0) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+5] = (ADC_6 &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+6] = (ADC_7 &amp;gt;&amp;gt; 0) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+7] = (ADC_7 &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+8] = (ADC_8 &amp;gt;&amp;gt; 0) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;data_save_buffer[index_buffer+9] = (ADC_8 &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;index_buffer+=10;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;ADC_SPI_state = false;&lt;/p&gt;
&lt;p&gt;}&lt;br /&gt; &lt;br /&gt; if( index_buffer == sizeof(data_save_buffer))&lt;br /&gt; { &lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;uint32_t err_code;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;uint16_t index_data_send = sizeof(data_send_buffer); &lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;do&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;{ &lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;err_code = ble_nus_data_send(&amp;amp;m_nus, data_save_buffer, &amp;amp;index_data_send, m_conn_handle); &lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;if ((err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;(err_code != NRF_ERROR_RESOURCES) &amp;amp;&amp;amp;&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;(err_code != NRF_ERROR_NOT_FOUND))&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;APP_ERROR_CHECK(err_code);&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;} while (err_code == NRF_ERROR_RESOURCES);&lt;br /&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;index_buffer = 0;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Is it inside the timer handler?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Save data in buffer --&amp;gt; yes. send BLE --&amp;gt; No&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;what is the priority of the timer interrupt?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Default : 3&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What is the processing time of the handler in which ble_nus_data_send is being called?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I think it is around 50us&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;#define MIN_CONN_INTERVAL&amp;nbsp; 7.5ms&lt;/p&gt;
&lt;p&gt;&lt;span&gt;#define MAX_CONN_INTERVAL&amp;nbsp; 7.5ms&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BLE_GATT_ATT_MTU_DEFAULT = 243&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Time gap between each team sending data via BLE nrf52840</title><link>https://devzone.nordicsemi.com/thread/442052?ContentTypeID=1</link><pubDate>Fri, 18 Aug 2023 10:18:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a112152-63eb-410e-9e16-fab2b131a448</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do not see the code snippet where you actually send the BLE packet.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is it inside the timer handler?&lt;/li&gt;
&lt;li&gt;what is the priority of the timer interrupt?&lt;/li&gt;
&lt;li&gt;What is the processing time of the handler in which ble_nus_data_send is being called?&lt;/li&gt;
&lt;li&gt;50uS can be very ambitious speed if you have something other than the timer handler running in the background (for example you have other contexts where you get and process sensor data)&lt;/li&gt;
&lt;li&gt;You need to add some GPIO toggles in the handler start and end where you call ble_nus_data_send to know the actual latencies of your handlers. You should do the same with another gpio for other contexts you have in the same/higher priority as the priority of the handler you can ble_nus_data_send.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you can share all your application handler contexts and the interrupt priorities and the GPIO toggle timing for each of this context, then we will have enough information to see if you can transmit 60Bytes of data with 20KHz frequency of incoming sampled data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also check your MTU size and see to it that it is bigger than 60 bytes so that every data is sent in one packet and not in multiple packets.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>