<?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>Confusion about double buffered pointer on UARTE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74456/confusion-about-double-buffered-pointer-on-uarte</link><description>I&amp;#39;m using an NRF52811 and trying to configure the UARTE for Tx &amp;amp; Rx at 57600 baud but I&amp;#39;m having trouble with the Rx. I think I am dropping bytes and so want to try and exploit the double buffered DMA pointer, to see if that fixes the problem. I&amp;#39;m using</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Apr 2021 11:32:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74456/confusion-about-double-buffered-pointer-on-uarte" /><item><title>RE: Confusion about double buffered pointer on UARTE</title><link>https://devzone.nordicsemi.com/thread/307449?ContentTypeID=1</link><pubDate>Thu, 29 Apr 2021 11:32:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e21c3d16-d48d-4f24-b70f-97a35b0527bc</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Glad that you have this figured out.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Pete W"]Is there any value in using&amp;nbsp; &amp;nbsp;p_event-&amp;gt;data.rxtx.bytes&amp;nbsp; &amp;nbsp;to get the number of bytes waiting, or can I assume that it will always be the number requested, i.e.&amp;nbsp;&lt;span&gt;RX_BUFFER_SIZE&lt;/span&gt;[/quote]
&lt;p&gt;RX:BUFFER:SIZE not the same as rxtx.&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fstructnrfx__uart__xfer__evt__t.html&amp;amp;anchor=a60e1043ae68becea83e1868e6ee2e482"&gt;bytes&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;RX_BUFFER_SIZE should be larger than the biggest single RX transaction your application does..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Confusion about double buffered pointer on UARTE</title><link>https://devzone.nordicsemi.com/thread/307080?ContentTypeID=1</link><pubDate>Tue, 27 Apr 2021 14:50:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:084b34e9-57f5-41e8-a65a-f1ca8a383dfc</guid><dc:creator>Pete W</dc:creator><description>&lt;p&gt;I think I have a grip of this now. I had a bug in my main byte handler function which wasn&amp;#39;t helping matters, and was the reason I was trying to use two 1-byte buffers. I&amp;nbsp;now have two rx_buffers, each 10 bytes long, which gives me plenty of margin. I initialise the pointers in the initialisation using:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; nrfx_uarte_rx(&amp;amp;uarte0, rx_buffer[0], RX_BUFFER_SIZE);&lt;br /&gt;&amp;nbsp; &amp;nbsp; nrfx_uarte_rx(&amp;amp;uarte0, rx_buffer[1], RX_BUFFER_SIZE);&lt;/p&gt;
&lt;p&gt;and then in my event handler I have:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; case NRFX_UARTE_EVT_RX_DONE:&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p_data = p_event-&amp;gt;data.rxtx.p_data;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; num_bytes = RX_BUFFER_SIZE;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(num_bytes--)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;my_rx_byte_handler(*(p_data++));&amp;nbsp; &amp;nbsp; // call the external handler to dump the latest bytes into large buffer&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nrfx_uarte_rx(&amp;amp;uarte0, p_event-&amp;gt;data.rxtx.p_data, RX_BUFFER_SIZE); // ensure primary and secondary buffers flip&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; case NRFX_UARTE_EVT_ERROR:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nrfx_uarte_rx(&amp;amp;uarte0, rx_buffer[0], RX_BUFFER_SIZE);&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nrfx_uarte_rx(&amp;amp;uarte0, rx_buffer[1], RX_BUFFER_SIZE);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I added a check to see what p_data is doing and it toggles between the two rx buffers, as expected, confirming that the double buffering of the pointers is working.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is there any value in using&amp;nbsp; &amp;nbsp;p_event-&amp;gt;data.rxtx.bytes&amp;nbsp; &amp;nbsp;to get the number of bytes waiting, or can I assume that it will always be the number requested, i.e.&amp;nbsp;&lt;span&gt;RX_BUFFER_SIZE&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Pete&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>