<?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>NRF serial abstraction layer clarification</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29357/nrf-serial-abstraction-layer-clarification</link><description>Can someone please explain the below line mentioned in NRF5 Serial port abstraction layer documentation. 
 
 Do not use synchronous API (timeout_ms
parameter &amp;gt; 0) in IRQ context. It may
lead to a deadlock because the timeout
interrupt cannot preempt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Jan 2018 13:41:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29357/nrf-serial-abstraction-layer-clarification" /><item><title>RE: NRF serial abstraction layer clarification</title><link>https://devzone.nordicsemi.com/thread/116792?ContentTypeID=1</link><pubDate>Fri, 12 Jan 2018 13:41:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d379f063-9614-4522-8c52-8ef32156daed</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Note that the while loop will also hang if the interrupt context has the &lt;strong&gt;same&lt;/strong&gt; priority as the timer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF serial abstraction layer clarification</title><link>https://devzone.nordicsemi.com/thread/116791?ContentTypeID=1</link><pubDate>Fri, 12 Jan 2018 08:59:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88270c4f-b212-4f2b-b433-64ce9f2667aa</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This warning say that you should not use the serial library functions in blocking mode from IRQ context (interrupt handlers), as it can cause deadlocks.&lt;/p&gt;
&lt;p&gt;This functions refered by this warning is &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__serial.html#ga429b73699af2e725894aa95c88778964"&gt;&lt;code&gt;nrf_serial_write()&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__serial.html#ga3402c8874c264174a54fd966e8a7d9d3"&gt;&lt;code&gt;nrf_serial_read()&lt;/code&gt;&lt;/a&gt;, and &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/group__nrf__serial.html#ga4912baad1dcc3d6fa4f05ad7b5acadbb"&gt;&lt;code&gt;nrf_serial_flush()&lt;/code&gt;&lt;/a&gt;. From the API documentation you can see the description of the &lt;code&gt;timeout_ms&lt;/code&gt; parameter:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;timeout_ms&lt;/strong&gt;	Operation timeout, in milliseconds. Pass 0 to operate in non
blocking mode.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The timeout is implemented as a timer and a while loop waiting for the timer to expire or a flag to be set. If the blocking call is made from an interrupt context with higher priority than the serial/timer library, the flag can never be updated, leaving you in a deadlock. It is therefore not recommended to call the blocking functions from IRQ context.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>