<?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>Safe UART line idle detection with DMA</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55117/safe-uart-line-idle-detection-with-dma</link><description>Hi, 
 We&amp;#39;ve circled back to this problem, now that we&amp;#39;ve increased speed. 
 We&amp;#39;re using UART to communicate between the nRF52832 and an STM32. 
 Recently we increased the speed to 1M and to do so, have to switch to DMA transfer. We had made some attempts</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Dec 2019 14:14:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55117/safe-uart-line-idle-detection-with-dma" /><item><title>RE: Safe UART line idle detection with DMA</title><link>https://devzone.nordicsemi.com/thread/223636?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2019 14:14:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6b2a94a-9572-4e8d-9346-8c227ecbd23a</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;I think you should not rely on ENDRX event, use it only for switching buffers. Having a byte counter, you can schedule an interrupt after an expected number of bytes on-the-fly with CC registers, and an issue with lost bytes can be solved with a simple software timer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Safe UART line idle detection with DMA</title><link>https://devzone.nordicsemi.com/thread/223599?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2019 12:54:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3888913-fb46-434b-929e-8d2c4a9de855</guid><dc:creator>thefool</dc:creator><description>&lt;p&gt;Thanks for your answer, but this is not our current issue.&lt;/p&gt;
&lt;p&gt;Our protocol has packet headers, so our higher levels detecting packets are no problem - the problem is that we have variable sized packets, and don&amp;#39;t have a continuous data-stream.&lt;/p&gt;
&lt;p&gt;The issue is that sometimes we want to send big amounts of data (255 byte packets, up to 1MB as fast as possible), but usually we&amp;#39;re sending very small packets (5-12&amp;nbsp;bytes) and have to reply to each packet.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Lets say we&amp;#39;ve set DMA to 32 bytes&lt;/p&gt;
&lt;p&gt;When single, small 5 byte packet arrives, we also need to handle that ASAP, and not just after we&amp;#39;ve received the 8th small packet, and filled up the DMA block, when we receive the ENDRX event.&lt;/p&gt;
&lt;p&gt;So we&amp;#39;re looking for a safe method to detect an idle RX line for these small packets which would cause a DMA transfer and and ENDRX event (or similar). But it could also happen, that we get another packet with any amount of delay between the two packets, and we&amp;#39;re worried about that second packet.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;No matter what we would set the idle timeout to, there&amp;#39;s a chance we start receiving more data JUST after the idle timeout.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Our current solution was to pad our packets with 0&amp;#39;s to the exact DMA buffer size, and we thought we&amp;#39;d solved our issue, but then one byte got discarded because of a UART error, and we were left with the same issue, where we received just 31 bytes instead of the expected 32 bytes, and DMA not firing ENDRX until the NEXT packet starts coming in. Of course from then on, this problem continues forever, since 1 byte will always be missing from each of the next packets.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Safe UART line idle detection with DMA</title><link>https://devzone.nordicsemi.com/thread/223506?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2019 09:12:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0d147b4-86ef-44f3-a4a7-c622f8b36552</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;it&amp;#39;s better not to use STOPRX/FLUSHRX stuff if you need continuous reception. Lost bytes is a lesser evil - sometimes you&amp;#39;ll get loss of bitstream synchronization. After some experiments, I came to the most simple and reliable solution for reception: make a double-buffered ring, set ENDRX-STARTRX shortcut&amp;nbsp; and configure a counter for RXDRDY event to know how many bytes are received at the moment.&amp;nbsp; An issue with DMA delay can be handled with higher layer, for example, write a zero to memory where last byte of packet is expected, and make sure that your packet ends with non-zero byte.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Safe UART line idle detection with DMA</title><link>https://devzone.nordicsemi.com/thread/223443?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 23:11:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f652e5d-0547-41c3-9c7b-962f7a2ef148</guid><dc:creator>thefool</dc:creator><description>&lt;p&gt;just FYI: I posted a followup question in a related thread here:&amp;nbsp;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/54792/how-to-use-uarte-in-1m-baud-rxd-amount-will-not-update-until-fill-up-rxbuffer/223419#223419"&gt;devzone.nordicsemi.com/.../223419&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>