<?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>libUARTE timer working expl. with app timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61389/libuarte-timer-working-expl-with-app-timer</link><description>Hello, 
 I was reading the nrf_libuarte_async library, and noticed that in the 
 app_timer_handler - 
 calls the 
 local_app_timer_start - 
 again and starts the timer again, 
 could shed some light on why this is called again and also on how the timeout</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 May 2020 14:10:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61389/libuarte-timer-working-expl-with-app-timer" /><item><title>RE: libUARTE timer working expl. with app timer</title><link>https://devzone.nordicsemi.com/thread/249998?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 14:10:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca7d5eb9-1315-4229-ad4f-cdb9c71a23f7</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Exactly why it is done like this, I don&amp;#39;t know, but I assume that it is related to the fact that things go quite quick when using UART, and it may be that starting and stopping the timer on every byte would be too much for the app_timer, so instead, they only check whether any bytes has been received since the last timeout, and if not, it will generate the NRF_LIBUARTE_ASYNC_EVT_RX_DATA event.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Why they use this single shot timer that is started on each timeout instead of a repeated timer, I don&amp;#39;t know.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Also follow up question&amp;nbsp; - the app time starts in the enable function and not after the first byte recived, how does this work ? ideally we should start timer after we detect idle line right ?[/quote]
&lt;p&gt;&amp;nbsp;I guess it is for the same reason. Since this goes very fast, I imagine that there wouldn&amp;#39;t be any time for the app_timer scheculer to actually start the timer. You see, app_timer_start() doesn&amp;#39;t actually start the timer, but it schedules the timer to be started, so if the UART bytes are coming in too fast, the timer scheduler will not have enough time to actually start the timer, which depending on the baudrate may not be until the entire message is sent.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>