<?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>UART FIFO Missing bytes when BLE transmission is going on</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/75150/uart-fifo-missing-bytes-when-ble-transmission-is-going-on</link><description>Hello, 
 I am using Nordic nRF52840 (nRF5SDK v16.0.0) and softdevice : s140. 
 Nordic MCU is connected to Host MCU over UART interface (baudrate = 115200). I have below observation: 
 When we send byte stream from Host MCU to Nordic and Nordic is transmitting</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 May 2021 13:08:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/75150/uart-fifo-missing-bytes-when-ble-transmission-is-going-on" /><item><title>RE: UART FIFO Missing bytes when BLE transmission is going on</title><link>https://devzone.nordicsemi.com/thread/310173?ContentTypeID=1</link><pubDate>Tue, 18 May 2021 13:08:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7bb601d1-ac2f-4479-9e97-7c8a4474e55e</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="onishant82"]I just observed that at times i do get&amp;nbsp;&lt;span&gt;APP_UART_COMMUNICATION_ERROR&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;Yes, it means that you need to go and look into the&amp;nbsp;&lt;span&gt;p_event&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;error_communication and check it with &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fuarte.html&amp;amp;cp=4_0_0_5_33_8&amp;amp;anchor=register.ERRORSRC"&gt;ERRORSRC&lt;/a&gt;. Like i suspected on my first reply, this most likely could be OVERRUN error. This happens if you are receiving bytes faster than you could process it (very common on high baudrates and no flowcontrol setup). With overrun error, the data is lost as the hw buffers are overwritten before the application could pull it, so there is no recovery of lost bytes possible unless you develop a mechanism from the application to ask the peer to retransmit&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART FIFO Missing bytes when BLE transmission is going on</title><link>https://devzone.nordicsemi.com/thread/310154?ContentTypeID=1</link><pubDate>Tue, 18 May 2021 12:34:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:184445ec-6e0f-462a-a40d-f88f3d046da1</guid><dc:creator>onishant82</dc:creator><description>&lt;p&gt;Hello Susheel,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I just observed that at times i do get&amp;nbsp;&lt;span&gt;APP_UART_COMMUNICATION_ERROR. Since we already have hardware and we did not planned for RTS/CTS , so these hardware options are not there.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any suggestion for&amp;nbsp;APP_UART_COMMUNICATION_ERROR root cause ?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART FIFO Missing bytes when BLE transmission is going on</title><link>https://devzone.nordicsemi.com/thread/310109?ContentTypeID=1</link><pubDate>Tue, 18 May 2021 10:47:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c37b70f-ea7a-4471-9e56-debdd69e1173</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="onishant82"]Still issue happens : when Bluetooth send API is called (ble_nus_data_send (..)) and during this transmission, if host controller is sending any data over uart, we are missing bytes at times.[/quote]
&lt;p&gt;&amp;nbsp;The bytes cannot go missing&amp;nbsp;without any error in the receiving side. Can you please add some logs in the uart_event_handle like below to see if there is ANY error at all.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;case&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;APP_UART_COMMUNICATION_ERROR&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_LOG_ERROR&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;Communication&amp;nbsp;error&amp;nbsp;occurred&amp;nbsp;while&amp;nbsp;handling&amp;nbsp;UART.&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;If not, then I have to understand more on what you mean exactly by missing bytes. With FIFO in place and no RX errors, i have not heard of any missing bytes in UART.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;One other thing you can check is to temporarily enable flow control in nRF and also peer uart and connect the two pins (RTS/CTS to peer). Check if this improves the situation. What i am trying to get at is that it is hard for me to understand missing bytes without UART RX throwing some error. I am trying to exclude HW errors, so that we can purely focus on software.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART FIFO Missing bytes when BLE transmission is going on</title><link>https://devzone.nordicsemi.com/thread/309794?ContentTypeID=1</link><pubDate>Fri, 14 May 2021 13:19:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac603991-1e2d-4a1f-910b-8feb5f6648cf</guid><dc:creator>onishant82</dc:creator><description>&lt;p&gt;Thanks for your reply, i did tried moving the send routing to main loop (out of interrupt) and implement an application layer FIFO to handle data from interrupt to main loop.&lt;/p&gt;
&lt;p&gt;Still issue happens : when Bluetooth send API is called (ble_nus_data_send (..)) and during this transmission, if host controller is sending any data over uart, we are missing bytes at times.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART FIFO Missing bytes when BLE transmission is going on</title><link>https://devzone.nordicsemi.com/thread/309773?ContentTypeID=1</link><pubDate>Fri, 14 May 2021 11:54:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03b27372-1200-4a41-8000-1b7871607952</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I think you need to understand the time it takes for receiving/transmitting your uart data and sending that on BLE. 178 bytes should not be a problem if you have a larger MTU size. You also have to fine tune your connection interval/MTU size/UART priority and analyze how much overhead (pre and post processing) time is spent for UART tx/rx and also BLE TX/RX.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It looks to me that the baudrate is too high for the overhead you have for processing your data for rx and tx. Either optimize your data processing time to reduce it to a bare minimal in ISR or reduce the baudrate.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART FIFO Missing bytes when BLE transmission is going on</title><link>https://devzone.nordicsemi.com/thread/309769?ContentTypeID=1</link><pubDate>Fri, 14 May 2021 11:46:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8afde233-abca-487c-9ba7-ac74b65cddd4</guid><dc:creator>onishant82</dc:creator><description>&lt;p&gt;Hello Susheel,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;No i am not using HW flow control BUT i did checked for overrun error and i am not getting any error for overrun.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Currently priority used is :&amp;nbsp;APP_IRQ_PRIORITY_LOWEST (default configuration in test example). If try to make is high :&amp;nbsp;APP_IRQ_PRIORITY_HIGH, Bluetooth transmission doesnt work correctly).&lt;/p&gt;
&lt;p&gt;It appears that in some flow of Softdevices transmission, either UART interrupt is disabled OR bluetooth transmission time is high and we need to add delay in transmission from host controller, not sure for this and need your help.&lt;/p&gt;
&lt;p&gt;If i keep on receiving 178 bytes over UART but only send 10 bytes over Bluetooth, byte reception works fine. If i make this Bluetooth send count to 50 , again i miss bytes during reception.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Triggering of bluetooth transmission is same as in example : from void uart_event_handle(app_uart_evt_t * p_event) -&amp;gt;&amp;nbsp;&lt;strong&gt;&amp;nbsp;err_code = ble_nus_data_send(&amp;amp;m_nus, &amp;amp;data_array[3], &amp;amp;length, m_conn_handle);&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART FIFO Missing bytes when BLE transmission is going on</title><link>https://devzone.nordicsemi.com/thread/309740?ContentTypeID=1</link><pubDate>Fri, 14 May 2021 10:35:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae229558-4421-40c4-a2c2-556f4b47c66e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Are you using HW flowcontrol for the uart? if not, that could explain the missing rx bytes as there could be&lt;a href="https://devzone.nordicsemi.com/search?q=uart%20overrun%20error"&gt; overrun errors &lt;/a&gt;when used with high baudrate and in the combination of bLE.&lt;/p&gt;
&lt;p&gt;The workarounds/solutions for these can be&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;use uart hw flow control&lt;/li&gt;
&lt;li&gt;increase the uart interrupt priority while initializing uart (increase priority in ARM is reducing the priority numberm lower the value in NVIC, higher the priority.)&lt;/li&gt;
&lt;li&gt;handle the overrun error in when you get the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fgroup__app__uart.html&amp;amp;anchor=ga9346b21b144fd9499e24853bbf781e17"&gt;APP_UART_COMMUNICATION_ERROR&lt;/a&gt;&amp;nbsp;and figure out a way to tell the peer uart to retransmit the whole transaction or just ignore the lost packet and reset your communication.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>