<?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>Write loop</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61809/write-loop</link><description>Hi 
 I am using SDK15.2 and trying to do a loop of serial write. 
 The first write is ok, but all other writes fail. 
 This is the code I am using: 
 #include &amp;quot;nrf_serial.h&amp;quot; #define d_NA 0 NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uart0_drv_config, Motor_Dir,</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 May 2020 14:17:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61809/write-loop" /><item><title>RE: Write loop</title><link>https://devzone.nordicsemi.com/thread/251746?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 14:17:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5d75131-105c-4fc6-8853-b2e01978cd12</guid><dc:creator>arikramon</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;OK. Ifound the problem. the parameter NRF_ERROR_TIMEOUT&amp;nbsp; should be changed to NRF_SERIAL_MAX_TIMEOUT&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Write loop</title><link>https://devzone.nordicsemi.com/thread/251740?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 14:05:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89693eff-fa2f-4e3e-8033-7da9c3ec0bae</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;So nrf_serial_write returns 8 == NRF_ERROR_INVALID_STATE when you try to call it after the first time.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I guess it is because the check inside nrf_serial_write:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if (!(p_serial-&amp;gt;p_ctx-&amp;gt;flags &amp;amp; NRF_SERIAL_TX_ENABLED_FLAG))&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;returns true. I can&amp;#39;t see any obvious reason, but here are a few things you can check:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. Your log says &amp;quot;Start UV calibration&amp;quot; and &amp;quot;Start Consol&amp;quot;, so I suspect that the snippet that you attached is a simplified snippet, since this doesn&amp;#39;t print those lines? What do you do between nrf_serial_init() and nrf_serial_write()? Or are those prints from another thread?&lt;/p&gt;
&lt;p&gt;2. You use this delay,&amp;nbsp;&lt;span&gt;vTaskDelay(). Can it be that the UART doesn&amp;#39;t get time to be processed? Perhaps you can try with another form of delay, like a timer or something to allow the UART to print in between the calls to nrf_serial_write?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BR,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Edvin&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>