<?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>device lockup by serial write in critical region</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/63768/device-lockup-by-serial-write-in-critical-region</link><description>Hi, 
 In my project, there is a device lock up and I found the problematic point that a debug log using nrf_serial_write() in critical region. 
 I think it is not a good idea to use debug log in critical region and I suspected if the previous critical</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Jul 2020 14:42:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/63768/device-lockup-by-serial-write-in-critical-region" /><item><title>RE: device lockup by serial write in critical region</title><link>https://devzone.nordicsemi.com/thread/260185?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 14:42:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae8ecb6a-8c8b-42ee-88d2-3a2788355126</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;When you enter a critical region, all peripheral interrupts will be disabled/masked. Most likely, the&amp;nbsp;&lt;span&gt;nrf_serial_write does a blocking wait for some event (transfer completed, timeout, error, etc). If you call this inside the critical region, the interrupts will never fire and the function will never complete.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you need to use logging inside the critical region, you may use the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/lib_nrf_log.html#nrf_log_processing"&gt;NRF_LOG library in deferred mode&lt;/a&gt;. This will add the logs to a buffer, and you need to process the buffer in the main loop to send the actual logs on UART.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>