<?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>UART close breakes whole communication</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47596/uart-close-breakes-whole-communication</link><description>Hello 
 I am writing low-power application where NRF is called from the other chip by interrupt, performs bluetooth scan and sends data back over UART. Of course, I want to close and reopen UART on every interrupt to decrease power consumption. On NRF52832</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 May 2019 12:43:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47596/uart-close-breakes-whole-communication" /><item><title>RE: UART close breakes whole communication</title><link>https://devzone.nordicsemi.com/thread/189052?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 12:43:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b472d64-7412-4c9e-b939-deeb02589af3</guid><dc:creator>mhuk_</dc:creator><description>&lt;p&gt;Thanks, it works as a charm now.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART close breakes whole communication</title><link>https://devzone.nordicsemi.com/thread/188960?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 07:34:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:daf07f18-c3af-49e3-9296-eb480cb80057</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You should wait until you get the&amp;nbsp;&lt;em&gt;APP_UART_TX_EMPTY&amp;nbsp;&lt;/em&gt;event in the handler. And I recommend that you exit the scan_evt_handler before doing any delayin, it might run at a higher priority that will block your transfer from starting.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART close breakes whole communication</title><link>https://devzone.nordicsemi.com/thread/188889?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 15:00:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d00394eb-0ea0-4eba-9ef9-df034e3727c7</guid><dc:creator>mhuk_</dc:creator><description>&lt;p&gt;The purpose is to decrease power consumption.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried to configure UART in blocking mode (without UART handler). Even though it wasn&amp;#39;t working&amp;nbsp;&lt;br /&gt;How to close UART after the transmission has been finished in smart way? Simple delay for a second doesn&amp;#39;t work.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART close breakes whole communication</title><link>https://devzone.nordicsemi.com/thread/188883?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 14:49:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0640261-10f6-45d5-9b2e-6163958a4374</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure I understand the purpose of the app_uart_close call. You are transferring data with app_uart_put inside the handler and the transfers will most likely not start because you close the UART&amp;nbsp;right after queuing the data for transfer. Note that app_uart_put is a non-blocking function that will only put the data into the transfer queue before returning, the actual transfer will happen asynchronously.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART close breakes whole communication</title><link>https://devzone.nordicsemi.com/thread/188600?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 13:52:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59ffc604-c1c6-4c60-9d3a-aee42a5498cb</guid><dc:creator>mhuk_</dc:creator><description>&lt;p&gt;Hello Jorgen,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;DEBUG_ON flag is undefined, here is the example when it doesn&amp;#39;t work (uart_init is&amp;nbsp;initialized&amp;nbsp;in main()). When you comment out app_uart_close() it works. If uart_init is moved to the timeout event right before sending it still works without&amp;nbsp;&lt;span&gt;app_uart_close() and doesn&amp;#39;t work with it.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Function for handling Scanning Module events.
 */
static void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
	switch(p_scan_evt-&amp;gt;scan_evt_id)
	{
		case NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:
		{
            //doing some Math here .....
            
			//fill in final beacon_scan_result packet with 5 closest beacons
			for (uint16_t i = 0; i &amp;lt; SAMPLES_UART_NUM; i++)
			{
				ui32ToByteArray((uint32_t)((maj_result[i] &amp;lt;&amp;lt; 16) | min_result[i]), &amp;amp;beacon_scan_result[i * SAMPLES_PACKET_SIZE]);
				floatToByteArray(rssi_result[i], &amp;amp;beacon_scan_result[i * SAMPLES_PACKET_SIZE + 4]);
			}

			//uart_flag = 1;
			for (uint16_t i = 0; i &amp;lt; SAMPLES_UART_NUM * SAMPLES_PACKET_SIZE; i++)
			{
				while(app_uart_put(beacon_scan_result[i]) != NRF_SUCCESS){};
			}

			app_uart_close();
			//uart_flag = 0;

			#ifdef DEBUG_ON
				SEGGER_RTT_printf(0, &amp;quot;\nUART data sent and port closed\n&amp;quot;);
				SEGGER_RTT_printf(0, &amp;quot;___________________________\n&amp;quot;);
			#endif
		} break;

		default:
		  break;
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Commented out uart_flag&amp;nbsp;was used to test point #3 and I didn&amp;#39;t notice any difference there. My example is based on the ble_app_uart example.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Error codes of what functions? app_uart_close doesn&amp;#39;t have any meaningful error codes as for me.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Max&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART close breakes whole communication</title><link>https://devzone.nordicsemi.com/thread/188576?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 12:54:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c60d4f1b-6c18-4947-a841-e2701ca490d8</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you post the code where you transmit data, and where you call app_uart_close? Are you checking the error codes from the functions?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>