<?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>UARTE driver with eASY DMA Giving wrong Rx length in runtime.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66126/uarte-driver-with-easy-dma-giving-wrong-rx-length-in-runtime</link><description>Hi Team, 
 We are using the UARTE(UARTE1) module with DMA for our application with nRF52840 board, for that we are using the &amp;quot; libuarte &amp;quot; example project. For testing purpose we are sending the data from Teraterm continuously and same data we transmitting</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Sep 2020 09:42:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66126/uarte-driver-with-easy-dma-giving-wrong-rx-length-in-runtime" /><item><title>RE: UARTE driver with eASY DMA Giving wrong Rx length in runtime.</title><link>https://devzone.nordicsemi.com/thread/270777?ContentTypeID=1</link><pubDate>Tue, 22 Sep 2020 09:42:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2ebd7b6-26e9-4fc1-9874-cac90d2148fb</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Srinivas.V,&lt;/p&gt;
[quote user="Srinivas V"]Thanks for your reply.&amp;nbsp;[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="Srinivas V"]We have added the rx data queue structure to Live watch window,from there we have observed this data.[/quote]
&lt;p&gt;So, you are seeing that the function sometimes is called with a larger than expected RX_len value?&lt;br /&gt;Did you define the DEBUG preprocessor define, as shown in the image of my previous post?&lt;br /&gt;&lt;br /&gt;Could you show me the declaration of your global&amp;nbsp;Rx_Read_buf variable. Is this declared as a const?&lt;br /&gt;I suspect that you are changing the RX length somewhere, since you are seeing it shift in the live watch.&lt;br /&gt;If you set this buf to const, you should get a compiler error for every line that tries to change its contents.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE driver with eASY DMA Giving wrong Rx length in runtime.</title><link>https://devzone.nordicsemi.com/thread/270673?ContentTypeID=1</link><pubDate>Mon, 21 Sep 2020 16:46:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cba0f310-6001-49c3-9a4d-21005eaa6311</guid><dc:creator>Srinivas V</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We observed this behaviour while debugging,We have added the rx data queue structure to Live watch window,from there we have observed this data.&lt;/p&gt;
&lt;p&gt;We are continuously sending the fixed data but some times the length is not updating and corresponding data also not getting.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We are not getting any errors, i kept one break point at error case in event handler.&lt;/p&gt;
&lt;p&gt;We are seeing the wrong RX length in the&amp;nbsp; f&lt;span&gt;unction &amp;quot;nrf_libuarte_async_rx_read&amp;quot;&amp;nbsp; from the varibles &amp;quot;Rx_Read_buf.p_data&amp;quot;, and&amp;nbsp; &amp;quot;Rx_Read_buf.length&amp;quot;. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Added the code part .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void nrf_libuarte_async_rx_read(void)
{
  ret_code_t ret;

  if (!nrf_queue_is_empty(&amp;amp;m_buf_queue))
  {
    ret = nrf_queue_pop(&amp;amp;m_buf_queue, &amp;amp;Rx_Read_buf);
    APP_ERROR_CHECK(ret);
  }
}

int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);
    
    ret_code_t ret = nrf_drv_clock_init();
    APP_ERROR_CHECK(ret);
  
    nrf_drv_clock_lfclk_request(NULL);

    ret_code_t err_code = NRF_LOG_INIT(app_timer_cnt_get);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    nrf_libuarte_async_config_t nrf_libuarte_async_config = {
            .tx_pin     = TX_PIN_NUMBER,
            .rx_pin     = RX_PIN_NUMBER,
            .baudrate   = NRF_UARTE_BAUDRATE_115200,
            .parity     = NRF_UARTE_PARITY_EXCLUDED,
            .hwfc       = NRF_UARTE_HWFC_DISABLED,
            .timeout_us = 200,
            .int_prio   = APP_IRQ_PRIORITY_LOW
    };

    err_code = nrf_libuarte_async_init(&amp;amp;libuarte, &amp;amp;nrf_libuarte_async_config, uart_event_handler, (void *)&amp;amp;libuarte);

    APP_ERROR_CHECK(err_code);

    nrf_libuarte_async_enable(&amp;amp;libuarte);
    
    GenerateMACENCKeys();                     //Generates Encryption Keys, this should be obfuscated for implementation
  
    Identification();                         //Handshake the broker and Host
 
  
    while (true)
    {
       if(rx_done_flag) This is updated in event handler after receiving the data
       {
          rx_done_flag = 0;
          nrf_libuarte_async_rx_read();
         
          err_code = nrf_libuarte_async_tx(&amp;amp;libuarte, Rx_Read_buf.p_data, Rx_Read_buf.length);
          
          if((NRF_SUCCESS != err_code) &amp;amp;&amp;amp; (NRF_ERROR_BUSY != err_code))
          {
              APP_ERROR_CHECK(err_code);
          }
          
        }
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Srinivas.V&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE driver with eASY DMA Giving wrong Rx length in runtime.</title><link>https://devzone.nordicsemi.com/thread/270639?ContentTypeID=1</link><pubDate>Mon, 21 Sep 2020 14:17:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fd1d570-212d-472e-a8e7-d2d4e0807443</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello, Srinivas.V&lt;/p&gt;
[quote user=""]We have observed that some times we getting wrong Rx length while we sending the data from Tera term terminal, out of 10 times we are missing two times. Here with i am sharding my code changes what we did for testing.[/quote][quote user=""]With the above code we are able to read the some of the packets,in between&amp;nbsp;we are getting wrong length vallue.[/quote]
&lt;p&gt;Are there any errors being generated by the application, if so - which errors is this?&lt;br /&gt;Could you elaborate more on the issue you are observing, perhaps with some examples of what you are sending in on Tera term, and what you are seeing in the application?&lt;br /&gt;Exactly which function is seeing the wrong RX length, and how are you alerted to this?&lt;br /&gt;&lt;br /&gt;Could you make sure that DEBUG is defined in your preprocessor defines, like shown in the included image?&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-0e16e6d3061a47549e496ece6a6a85c0/enabling_5F00_debug_5F00_SES.PNG" /&gt;&amp;nbsp;&lt;br /&gt;This will allow you to have both the error and generating function printed to the logger, if an error is passed to an APP_ERROR_CHECK.&lt;br /&gt;&lt;br /&gt;For future reference, please use the &amp;quot;Insert-&amp;gt;Code&amp;quot; option when sharing code here on DevZone - it drastically increases readability of the shared code.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>