<?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>Blocking UART with timeout using soft timers.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81100/blocking-uart-with-timeout-using-soft-timers</link><description>Hi, 
 
 I am trying to use UART APIs in blocking mode to receive data from another controller. 
 I intend to have a timeout on receiving function so not to stuck if no byte is received from the other controller. Here is the snippet of UART receive function</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Oct 2021 08:07:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81100/blocking-uart-with-timeout-using-soft-timers" /><item><title>RE: Blocking UART with timeout using soft timers.</title><link>https://devzone.nordicsemi.com/thread/336345?ContentTypeID=1</link><pubDate>Thu, 28 Oct 2021 08:07:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:977e5a48-7e86-4f7c-bb60-27e7c6a7768e</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can try reading out the remaining data that is still in the RX buffer on a overrun error. See &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/18481/uart-overrun-error-after-reset/71288#71288"&gt;this&lt;/a&gt;&amp;nbsp;thread.&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: Blocking UART with timeout using soft timers.</title><link>https://devzone.nordicsemi.com/thread/336261?ContentTypeID=1</link><pubDate>Wed, 27 Oct 2021 14:30:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdb34649-4c67-4468-90d3-8d5fd79ebc1a</guid><dc:creator>Shivek</dc:creator><description>&lt;p&gt;Hi Jared,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your response. I figured out that the buffer was filled up from some previous transmissions over UART. So, it was an overrun error.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you suggest me how to flush the FIFOs or is there any API which I can use with this low level library I am using?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Shivek&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Blocking UART with timeout using soft timers.</title><link>https://devzone.nordicsemi.com/thread/336214?ContentTypeID=1</link><pubDate>Wed, 27 Oct 2021 12:47:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74b6ee42-7e30-4f98-8733-0f7a0368df41</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;How is&amp;nbsp;data_array[] defined?&lt;/p&gt;
&lt;p&gt;Like this?:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;data_array&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
[quote user=""]But the code get stuck in the following do while loop of nrfx_uarte_rx() function from nrfx_uarte.c&amp;nbsp;[/quote]
&lt;p&gt;Here the program waits for either:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The buffer to fill up which should produce the ENDRX event.&lt;/li&gt;
&lt;li&gt;The receiver is stopped which produces the RXTO event.&lt;/li&gt;
&lt;li&gt;An error appears, which produces the Error event.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It seems that your buffer isn&amp;#39;t filling up properly. Are you using HWFC? Have you tried probing the data lines and ensured that the data is sent correctly?&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></channel></rss>