<?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>How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29522/how-to-close-uart-to-save-power-for-nrf52810</link><description>Hi, 
 I&amp;#39;m using SDK v14.2 and s112_5.1.0 for nRF52810 basing on the ble_app_uart example. Now we use the uart to communicate with external MCU. Also we want to close uart to save power when there is no data transmitting. I have used the BSP module to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 Jan 2018 12:43:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29522/how-to-close-uart-to-save-power-for-nrf52810" /><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117325?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2018 12:43:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce4c01cc-a68b-4406-8bdb-3fe4c4214df5</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Is it stuck in app_error_fault_handler()? Have you &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;debugged&lt;/a&gt; and checked the error code, line number, and file name?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117324?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2018 01:41:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f98e8112-fddd-4ace-94f9-d11076cf2147</guid><dc:creator>Alice</dc:creator><description>&lt;p&gt;For our application, if the MCU want to send data to the 52810 module via uart, it will keep P0.31 low until finishing sending data then let the P0.31 high to save power.&lt;/p&gt;
&lt;p&gt;There&amp;#39;s no problem that just pushed and released the button much time, because the uart still could output 0x55 0x66 in the handle_uart_sta function.&lt;/p&gt;
&lt;p&gt;But the problem is, once the uart has received data,for example,use UART terminal on the PC to send data to nRF52810, it will get stuck and there&amp;#39;s no any reaction push and releas the button at this time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117323?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2018 11:35:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fcd0828-5ef6-4810-9078-4269c0acf00c</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;I&amp;#39;m still not sure what you are trying to achieve here, but it seems like when:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;you press the button bsp_event_handler() is called with event BSP_EVENT_UART_WORK&lt;/li&gt;
&lt;li&gt;uart_status is set to 2&lt;/li&gt;
&lt;li&gt;After that handle_uart_sta() is called from main context&lt;/li&gt;
&lt;li&gt;Since uart_status = 2 NRF_UARTE0-&amp;gt;ENABLE is set to 8 (enabled).&lt;/li&gt;
&lt;li&gt;Average current consumptions is  ~750uA&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As long as you keep the button pressed the UART still works. When you release the button though:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;bsp_event_handler() is called again with event BSP_EVENT_UART_SLEEP&lt;/li&gt;
&lt;li&gt;uart_status is set to 1&lt;/li&gt;
&lt;li&gt;After that handle_uart_sta() is called from main context&lt;/li&gt;
&lt;li&gt;Since uart_status = 1 NRF_UARTE0-&amp;gt;ENABLE is set to 0 (disabled).&lt;/li&gt;
&lt;li&gt;Average current consumptions goes down to ~190uA&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So i.e. after you have pushed and released the button the UART is disabled.&lt;/p&gt;
&lt;p&gt;Is this your problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117330?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2018 15:09:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dee1f49-ad27-4095-b406-a4ba3650aa52</guid><dc:creator>Alice</dc:creator><description>&lt;p&gt;You could flash it to nRF52810 then it would runs and it would print &amp;quot;Application start&amp;quot; through UART. After that, you could give a high or low level by hand to P0.31. This should work fine. If you use UART terminal on the PC to send data to nRF52810, then give a high or low level by hand, you could see the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117329?ContentTypeID=1</link><pubDate>Tue, 23 Jan 2018 14:54:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4d772fb-c190-4db7-ae24-cdd420459ff8</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Can you give me a step-by-step instruction showing what I should do to reproduce your problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117326?ContentTypeID=1</link><pubDate>Sat, 20 Jan 2018 04:34:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:665f41f0-cc40-4730-a44f-3d4f5bab6dc9</guid><dc:creator>Alice</dc:creator><description>&lt;p&gt;I have declared uart_status as &amp;#39;volatile&amp;#39;. Also I use NRF_UARTE0-&amp;gt;ENABLE = 8; and NRF_UARTE0-&amp;gt;ENABLE = 0; to instead of app_uart_open() and app_uart_close(). I could see the current and it&amp;#39;s 2.6uA when disable UART while it&amp;#39;s about 650uA when enabled UART. UART could send data after it&amp;#39;s enabled. But once use PC to send the UART more than two times, it would  get stuck and stop running at the app_error_fault_handler function. That&amp;#39;s to say, UART couldn&amp;#39;t receive any data after enabled. Could you help me have a test on the ble_app_uart example? Thanks very much.&lt;/p&gt;
&lt;p&gt;This &lt;a href="https://github.com/JackyBruseZhong/52810_ble_uart"&gt;link text&lt;/a&gt; is my complete project. I use P0.31 to generate the high or low level to enabled or disable UART.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117328?ContentTypeID=1</link><pubDate>Fri, 19 Jan 2018 13:41:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04044acf-75b3-494d-9a13-1f6dde10c4a5</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;It seems like you have done what I was thinking.&lt;/p&gt;
&lt;p&gt;Can you try to declare uart_status as &amp;#39;volatile&amp;#39;?&lt;/p&gt;
&lt;p&gt;Have you tried debugging by the way? Do you know where things stop?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117327?ContentTypeID=1</link><pubDate>Fri, 19 Jan 2018 06:43:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:670eda8a-c8b4-4f7d-8e54-f6a01a2bd833</guid><dc:creator>Alice</dc:creator><description>&lt;p&gt;Hi Martin, I&amp;#39;m not sure I have got what you mean. Firstly, I have increase the interrupt priority of the UART to APP_IRQ_PRIORITY_HIGH. Then I have a global variable uart_status. I set uart_status=1 in the BSP_EVENT_UART_SLEEP event while uart_status=2 in the  BSP_EVENT_UART_WORk event. The two dunction  app_uart_close() and app_uart_open() would be called in the main context and  NRF_LOG_FLUSH()  also would be called before  enable or disable the UART  as follow:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint8_t uart_status = 0;
void handle_uart_sta(void){
	switch(uart_status)
	{
		case 1:
						uart_status = 0;
						NRF_LOG_FLUSH();
						app_uart_close();
		break;
		case 2:
						uart_status = 0;
						NRF_LOG_FLUSH();							
		        app_uart_open();
		break;				}		}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the main context:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    for (;;){
    UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
    power_manage();
    handle_uart_sta();
   }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, the problem have not been solved.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117322?ContentTypeID=1</link><pubDate>Thu, 18 Jan 2018 12:18:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddb48cbc-ad23-4be0-822c-53985d091dbb</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Are you using the logger module with UART as backend and without deferred logging? It could be a problem related to my comment from January 11th &lt;a href="https://devzone.nordicsemi.com/question/187271/nrf52832-executing-twi-function-from-app_timer-handler/"&gt;here&lt;/a&gt;. nrf_drv_uart_uninit () is trying to print messages to the logger module, and if you do this over UART I figure that you might get stuck if you call it from the interrupt context of the bsp_event_handler. app_uart_open() will also end up in an error handler if you try to call it more than once without successfully calling nrf_drv_uart_uninit() in between. It could help to either:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Increase the interrupt priority of the UART to e.g. APP_IRQ_PRIORITY_HIGH.&lt;/li&gt;
&lt;li&gt;Move your calls to app_uart_close() and app_uart_open() into your maint context.&lt;/li&gt;
&lt;li&gt;Use deferred logging and flush the message with NRF_LOG_FLUSH() in your main context. Logger documentation.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117320?ContentTypeID=1</link><pubDate>Thu, 18 Jan 2018 11:56:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9e645f5-40c6-481d-a85c-637ed57ee3e9</guid><dc:creator>Alice</dc:creator><description>&lt;p&gt;Yes, I have  define BSP_EVENT_UART_SLEEP and BSP_EVENT_UART_WORK in the bsp_event_t. It also could generate the event and run to the bsp_event_handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117332?ContentTypeID=1</link><pubDate>Thu, 18 Jan 2018 11:51:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ac90be1-a4f8-49f3-8784-079e90e76d92</guid><dc:creator>Alice</dc:creator><description>&lt;p&gt;nrf_uart_disable will be called in the  nrf_drv_uart_uninit function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117331?ContentTypeID=1</link><pubDate>Thu, 18 Jan 2018 09:40:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6bbb3480-9551-40e7-8d52-4ba0bbfef380</guid><dc:creator>Andre</dc:creator><description>&lt;p&gt;Try adding a call to nrf_uart_disable&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to close UART to save power for nRF52810</title><link>https://devzone.nordicsemi.com/thread/117321?ContentTypeID=1</link><pubDate>Thu, 18 Jan 2018 08:26:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bdb3447-11ce-4d2c-a9e7-85d76191ae03</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Did you define &lt;code&gt;BSP_EVENT_UART_SLEEP&lt;/code&gt; and &lt;code&gt;BSP_EVENT_UART_WORK&lt;/code&gt; somewhere? I don&amp;#39;t think such events exist in unmodified BSP module.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>