<?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>Missing UART received data with ble_app_uart</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77584/missing-uart-received-data-with-ble_app_uart</link><description>nRF52832 nRF5 SDK V17.0.2 SoftDevice S132 V7.2.0 
 I am running the sample program ble_app_uart in the above environment, but sometimes I miss UART received data. Teraterm is used for data transmission to UART of nRF52832, and self-made software (C #</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 30 Jul 2021 10:12:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77584/missing-uart-received-data-with-ble_app_uart" /><item><title>RE: Missing UART received data with ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/322632?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 10:12:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b0bce28-9840-4323-9f95-6a579bcf12d8</guid><dc:creator>matsumiya</dc:creator><description>&lt;p&gt;Hi.Jared&lt;/p&gt;
&lt;p&gt;By moving BLE transmit to MAIN instead of UART_EVENT_HANDLE&lt;br /&gt;UART The problem of missing data was solved.&lt;/p&gt;
&lt;p&gt;UART_EVENT_HANDLE counts the number of UART receive bytes, and when the BLE packet size is reached, BLE transmit request flag is set.&lt;br /&gt;If Main is a BLE transmission request flag standing, BLE transmit is performed.&lt;br /&gt;If the UART received data does not come for a predetermined time, it transmits the received UART data even if the BLE packet size is not satisfied.&lt;br /&gt;By doing this, UART receive data could be prevented from being missing.&lt;/p&gt;
&lt;p&gt;Thank you for your response.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;main:&lt;/p&gt;
&lt;p&gt;for (;;)&lt;br /&gt; {&lt;br /&gt; if (nrf_sdh_is_enabled())&lt;br /&gt; {&lt;br /&gt; sd_app_evt_wait();&lt;br /&gt; while( 0 &amp;lt; uartToBleChkReq )&lt;br /&gt; {&lt;br /&gt; uartToBleChkReq--;&lt;br /&gt; result_app_uart_get = NRF_SUCCESS;&lt;br /&gt; i = 0;&lt;br /&gt; while(( result_app_uart_get == NRF_SUCCESS ) &amp;amp;&amp;amp; ( i &amp;lt; m_ble_nus_max_data_len ))&lt;br /&gt; {&lt;br /&gt; result_app_uart_get = app_uart_get( &amp;amp;uartRxBuf[ i++ ]);&lt;br /&gt; }&lt;br /&gt; if( result_app_uart_get != NRF_SUCCESS )&lt;br /&gt; {&lt;br /&gt; i--;&lt;br /&gt; } &lt;br /&gt; if( ( result_app_uart_get == NRF_SUCCESS ) ||&lt;br /&gt; (( result_app_uart_get != NRF_SUCCESS ) &amp;amp;&amp;amp; ( 0 &amp;lt; i ))&lt;br /&gt; )&lt;br /&gt; {&lt;br /&gt; SEGGER_RTT_printf( 0,&amp;quot;[INFO] main : Do BLE Tx(%hu).\n&amp;quot;, i );&lt;br /&gt; do&lt;br /&gt; {&lt;br /&gt; err_code = ble_nus_data_send(&amp;amp;m_nus, uartRxBuf, &amp;amp;i, m_conn_handle);&lt;br /&gt; } while (err_code == NRF_ERROR_RESOURCES);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;uart event handler:&lt;/p&gt;
&lt;p&gt;void uart_event_handle(app_uart_evt_t * p_event)&lt;br /&gt;{&lt;br /&gt; switch (p_event-&amp;gt;evt_type)&lt;br /&gt; {&lt;br /&gt; &lt;br /&gt; case APP_UART_DATA_READY:&lt;br /&gt; uartRxCnt++;&lt;br /&gt; nrfx_rtc_cc_disable( &amp;amp;rtc, RTC_CH_UART_TMOUT );&lt;br /&gt; if( m_ble_nus_max_data_len &amp;lt;= uartRxCnt )&lt;br /&gt; {&lt;br /&gt; uartToBleChkReq++;&lt;br /&gt; uartRxCnt = 0;&lt;br /&gt; }&lt;br /&gt; nrfx_rtc_cc_set( &amp;amp;rtc, RTC_CH_UART_TMOUT, ( nrfx_rtc_counter_get( &amp;amp;rtc ) + RTC_CNT_UART_TMOUT ) &amp;amp; 0x00ffffff, true );&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;RTC event handler:(Use RTC2)&lt;/p&gt;
&lt;p&gt;static void rtc_handler(nrf_drv_rtc_int_type_t int_type)&lt;br /&gt;{&lt;/p&gt;
&lt;p&gt;cntr = nrfx_rtc_counter_get( &amp;amp;rtc );&lt;br /&gt; if (int_type == NRF_DRV_RTC_INT_COMPARE0) // UART RX TIMEOUT&lt;br /&gt; {&lt;/p&gt;
&lt;p&gt;uartToBleChkReq++;&lt;br /&gt; nrfx_rtc_cc_disable( &amp;amp;rtc, RTC_CH_UART_TMOUT );&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;matsumiya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Missing UART received data with ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/322565?ContentTypeID=1</link><pubDate>Fri, 30 Jul 2021 04:42:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d9ddf40-2935-40a6-9a8c-449074c14843</guid><dc:creator>matsumiya</dc:creator><description>&lt;p&gt;Thank you for telling me.&lt;br /&gt;The second measures have already been decided to make sure it is effective.&lt;br /&gt;I will try the first measures from now on.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Missing UART received data with ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/322495?ContentTypeID=1</link><pubDate>Thu, 29 Jul 2021 13:53:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:960a55f9-ae72-45df-917b-ae9fd2e285c9</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Most likely you are getting an error because the FIFO fills up. The application is not able to process the data in the FIFO before new data arrives. I think you have to rewrite this application for it work as you intend. You could:&lt;/p&gt;
&lt;p&gt;1. Define a buffer that you can use to store the data from the FIFO while it&amp;#39;s processed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. The ble_app_uart example sends the data as soon as it receives a newline. This is not good for maximum throughput as it causes the application to send multiple ble packets without filling them completely up. The sending of data has some overhead, so preferably you would only want to do it when the ble packet is full. Try removing&amp;nbsp;this check:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1627566722712v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Missing UART received data with ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/322395?ContentTypeID=1</link><pubDate>Thu, 29 Jul 2021 09:02:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:718b6337-7b0f-4ed2-9221-203e5404d7f1</guid><dc:creator>matsumiya</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,Jared&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;APP_UART_COMMUNICATION_ERROR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;APP_UART_FIFO_ERROR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;These events are currently ignored.&lt;br /&gt;Do I need to add processing to clear the error?&lt;br /&gt;UART flow control can not be used because the communication partner does not support.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;void uart_event_handle(app_uart_evt_t * p_event)&lt;br /&gt;{&lt;br /&gt; uint32_t err_code;&lt;/p&gt;
&lt;p&gt;switch (p_event-&amp;gt;evt_type)&lt;br /&gt; {&lt;br /&gt; &lt;br /&gt; case APP_UART_DATA_READY:&lt;br /&gt; if( uartEventRxBlockIf0 != 0 )&lt;br /&gt; {&lt;br /&gt; UNUSED_VARIABLE(app_uart_get( &amp;amp;uartRxBuf[ uartRxBufIndex ]));&lt;br /&gt; uartRxBufIndex++;&lt;br /&gt; if (( uartToBleBlockIf0 != 0 ) &amp;amp;&amp;amp; ( uartRxBufIndex &amp;gt;= m_ble_nus_max_data_len))&lt;br /&gt; {&lt;br /&gt; nrfx_rtc_cc_disable( &amp;amp;rtc, RTC_CH_UART_TMOUT );&lt;br /&gt; if ( 0 &amp;lt; uartRxBufIndex )&lt;br /&gt; {&lt;br /&gt; do&lt;br /&gt; {&lt;br /&gt; err_code = ble_nus_data_send(&amp;amp;m_nus, uartRxBuf, &amp;amp;uartRxBufIndex, m_conn_handle);&lt;br /&gt; } while (err_code == NRF_ERROR_RESOURCES);&lt;br /&gt; }&lt;br /&gt; uartRxBufIndex = 0;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; nrfx_rtc_cc_set( &amp;amp;rtc, RTC_CH_UART_TMOUT, ( nrfx_rtc_counter_get( &amp;amp;rtc ) + RTC_CNT_UART_TMOUT ) &amp;amp; 0x00ffffff, true );&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;case APP_UART_COMMUNICATION_ERROR:&lt;br /&gt;// modified from sample&amp;nbsp; &amp;nbsp;APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;case APP_UART_FIFO_ERROR:&lt;br /&gt;&lt;span&gt;// modified from sample&amp;nbsp; &amp;nbsp;&lt;/span&gt;&amp;nbsp;APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);&lt;br /&gt; break;&lt;/p&gt;
&lt;p&gt;default:&lt;br /&gt; break;&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;matsumiya&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Missing UART received data with ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/322388?ContentTypeID=1</link><pubDate>Thu, 29 Jul 2021 08:49:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cb16187-a507-4054-a230-8271b1bbe867</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you disabled&amp;nbsp;&lt;span&gt;&lt;span&gt;APP_UART_COMMUNICATION_ERROR and&amp;nbsp;&lt;/span&gt;&lt;/span&gt;APP_UART_FIFO_ERROR in uart_event_handle()? The application should assert if the FIFO gets full. On a second thought, can you use uart flow control in your project?&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Missing UART received data with ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/321669?ContentTypeID=1</link><pubDate>Mon, 26 Jul 2021 02:40:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2acbbe93-afec-4b84-ab2e-579e07637467</guid><dc:creator>matsumiya</dc:creator><description>&lt;p&gt;Hi,Jared&lt;/p&gt;
&lt;p&gt;sorry for the late reply.&lt;br /&gt;Thank you for your response.&lt;br /&gt;I tried to set UART_TX_BUF_SIZE and UART_RX_BUF_SIZE 4096 but did not get better.&lt;br /&gt;The IRQ priority set by UART_INIT did not want to change the priority.&lt;br /&gt;(APP_IRQ_PRIORITY_HIGHEST, APP_IRQ_PRIORITY_HIGH, APP_IRQ_PRIORITY_MID did not work:Hanged)&lt;/p&gt;
&lt;p&gt;Eliminate CR / LF reception from the condition that sends to BLE, add it&lt;br /&gt;By setting MIN_CONN_INTERVAL to 8 and MAX_CONN_INTERVAL&lt;br /&gt;UART The missing data missing is not zero but improved.&lt;/p&gt;
&lt;p&gt;It is likely to reply because it works on this work,&lt;br /&gt;I will try if I can improve a little more.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Before correction:&lt;/p&gt;
&lt;p&gt;void uart_event_handle(app_uart_evt_t * p_event)&lt;br /&gt;{&lt;br /&gt; static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];&lt;br /&gt; static uint8_t index = 0;&lt;br /&gt; uint32_t err_code;&lt;/p&gt;
&lt;p&gt;switch (p_event-&amp;gt;evt_type)&lt;br /&gt; {&lt;br /&gt; case APP_UART_DATA_READY:&lt;br /&gt; UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));&lt;br /&gt; index++;&lt;/p&gt;
&lt;p&gt;if ((data_array[index - 1] == &amp;#39;\n&amp;#39;) || // &amp;lt;- Remove&lt;br /&gt; (data_array[index - 1] == &amp;#39;\r&amp;#39;) || // &amp;lt;- Remove&lt;br /&gt; (index &amp;gt;= m_ble_nus_max_data_len))&lt;br /&gt; {&lt;br /&gt; if (index &amp;gt; 1)&lt;br /&gt; {&lt;br /&gt; NRF_LOG_DEBUG(&amp;quot;Ready to send data over BLE NUS&amp;quot;);&lt;br /&gt; NRF_LOG_HEXDUMP_DEBUG(data_array, index);&lt;/p&gt;
&lt;p&gt;do&lt;br /&gt; {&lt;br /&gt; uint16_t length = (uint16_t)index;&lt;br /&gt; err_code = ble_nus_data_send(&amp;amp;m_nus, data_array, &amp;amp;length, m_conn_handle);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Revised:&lt;/p&gt;
&lt;p&gt;void uart_event_handle(app_uart_evt_t * p_event)&lt;br /&gt;{&lt;br /&gt; uint32_t err_code;&lt;/p&gt;
&lt;p&gt;switch (p_event-&amp;gt;evt_type)&lt;br /&gt; {&lt;br /&gt; &lt;br /&gt; case APP_UART_DATA_READY:&lt;br /&gt; if( uartEventRxBlockIf0 != 0 )&lt;br /&gt; {&lt;br /&gt; UNUSED_VARIABLE(app_uart_get( &amp;amp;uartRxBuf[ uartRxBufIndex ]));&lt;br /&gt; uartRxBufIndex++;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;regards&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Matsumiya&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Missing UART received data with ble_app_uart</title><link>https://devzone.nordicsemi.com/thread/320906?ContentTypeID=1</link><pubDate>Tue, 20 Jul 2021 12:51:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad730703-5dc8-41ff-9396-8c2b44f6b812</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Have you tried increasing UART buffer size by adjusting&amp;nbsp;&lt;span&gt;UART_TX_BUF_SIZE&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;span&gt;UART_RX_BUF_SIZE?&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;regards&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Jared&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>