<?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>Programming DK board button to go to system on low power mode and then wake &amp;amp; advertise on consecutive button presses</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51694/programming-dk-board-button-to-go-to-system-on-low-power-mode-and-then-wake-advertise-on-consecutive-button-presses</link><description>Hi I am trying to program the bsp buttons on the NRF52 DK, so pushing button 1 will toggle start advertising and going to sleep by calling sd_app_evt_wait(). 
 I have successfully got the button to go to sleep when pressed, but in my current code below</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Sep 2019 14:09:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51694/programming-dk-board-button-to-go-to-system-on-low-power-mode-and-then-wake-advertise-on-consecutive-button-presses" /><item><title>RE: Programming DK board button to go to system on low power mode and then wake &amp; advertise on consecutive button presses</title><link>https://devzone.nordicsemi.com/thread/208726?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 14:09:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a610b996-d093-404d-9a3f-ede61c71a6b1</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;The function sd_app_evt_wait() will not block the RTC. I think you are mixing &lt;strong&gt;system OFF mode&lt;/strong&gt; and &lt;strong&gt;system ON mode&lt;/strong&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;System OFF mode will put the device into the deepest power saving and disable all peripherals (including RTC)&lt;/li&gt;
&lt;li&gt;System ON mode will put the system in a lighter sleep mode where all the peripherals can be used (including RTC). To put the device into system ON, you call&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=/com.nordic.infocenter.s132.api.v3.0.0/group___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;anchor=ga11d88d38ac99fb72cde74c9385d36433"&gt;sd_app_evt_wait()&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Read &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/36475/nrf52832-go-system-off-low-power-mode-and-wakeup-by-gpio"&gt;this Devzone ticket &lt;/a&gt;for more information about this.&lt;/p&gt;
&lt;p&gt;I would recommend you to remove the call to sd_app_evt_wait() in the&amp;nbsp;bsp_event_handler(). In your code, the chip is already set up to go to sleep. It is done through&amp;nbsp;&lt;em&gt;idle_state_handle()--&amp;gt;nrf_pwr_mgmt_run()--&amp;gt;sd_app_evt_wait()&lt;/em&gt;. The program flow works in this manner:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/600x450/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-bb3762f5135a42a7877dc43bd9243850/pastedimage1568038036726v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;The call to advertising_start() can still remain in&amp;nbsp;&lt;span&gt;bsp_event_handler(), but you should create a boolean variable that checks if advertising is ongoing or not. Set variable to true when advertising is started, and set it to false when advertising is stopped.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming DK board button to go to system on low power mode and then wake &amp; advertise on consecutive button presses</title><link>https://devzone.nordicsemi.com/thread/208028?ContentTypeID=1</link><pubDate>Wed, 04 Sep 2019 16:57:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f0e9bcb-d4e5-4b13-9150-5562176039fa</guid><dc:creator>thoric_fish</dc:creator><description>&lt;p&gt;Hi, for my application the NRF should not power off as I need the RTC to be active, so the RTC should stay on until the NRF runs out of battery. My application also requires that BLE advertising only start when the user presses a button.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I commented out&amp;nbsp;&lt;span&gt;bsp_btn_ble_sleep_mode_prepare() and the problem still persisted. I made some more modifications and it turns out that if I press the button twice while BLE advertising is still active from the first advertising_start() call in main() then there is another call to advertising_start(). It seems like&amp;nbsp;one or more calls to advertising_start() while BLE advertising is already on will generate errors. I will investigate some more.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming DK board button to go to system on low power mode and then wake &amp; advertise on consecutive button presses</title><link>https://devzone.nordicsemi.com/thread/207864?ContentTypeID=1</link><pubDate>Wed, 04 Sep 2019 09:28:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca2d5039-4cd4-4eeb-b586-2f0086c5b507</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Is there a reason why you&amp;#39;re not only using the initial solution? With idle_state_handle() inside the for loop.&lt;br /&gt;Could you try to comment out err_code = bsp_btn_ble_sleep_mode_prepare(); in sleep_mode_enter()&amp;nbsp; and see if the problem still persist?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>