<?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>regarding Sleep Mode of nRF51</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12494/regarding-sleep-mode-of-nrf51</link><description>Hi.
I&amp;#39;m using PCA10028, SDK10.0.0 S130. 
 I want to make nRF51 goes sleep mode.
So I tested linked source code as below.
 github.com/.../main.c 
 It works well.
But after I add this code in &amp;quot;ble_app_hrs_c&amp;quot; as below, it doesn&amp;#39;t work. 
 int main</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Mar 2016 02:49:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12494/regarding-sleep-mode-of-nrf51" /><item><title>RE: regarding Sleep Mode of nRF51</title><link>https://devzone.nordicsemi.com/thread/47348?ContentTypeID=1</link><pubDate>Wed, 16 Mar 2016 02:49:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:890a7a9b-c156-463e-b550-754e05accf86</guid><dc:creator>roger.k</dc:creator><description>&lt;p&gt;Thanks a lot. It&amp;#39;s very helpful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: regarding Sleep Mode of nRF51</title><link>https://devzone.nordicsemi.com/thread/47347?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2016 11:46:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f39e4d57-9383-4994-8173-6f623d7275ba</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;ble_app_hrs in the SDK has not been power optimized. There is one power optimized example in the SDK, &lt;strong&gt;ble_app_pwr_profiling&lt;/strong&gt;, I would recommend you to take a look at that.&lt;/p&gt;
&lt;p&gt;A power consumption of approximately 1 mA could be a result of the chip being in debug mode, the chip can exit debug mode using one of the following methods:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Power reset&lt;/li&gt;
&lt;li&gt;Pin reset using nrfjprog from the command line: nrfjprog --pinreset&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: regarding Sleep Mode of nRF51</title><link>https://devzone.nordicsemi.com/thread/47345?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 23:49:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc99f2d6-dca0-4d72-834e-e56641998266</guid><dc:creator>roger.k</dc:creator><description>&lt;p&gt;Please refer to my new Answer as below.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: regarding Sleep Mode of nRF51</title><link>https://devzone.nordicsemi.com/thread/47346?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 23:48:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d83aea8b-993c-4c30-99a3-8e0e5ef0fd47</guid><dc:creator>roger.k</dc:creator><description>&lt;p&gt;Thank you for your help.&lt;/p&gt;
&lt;p&gt;Q1. It&amp;#39;s very helpful. Let me try.&lt;/p&gt;
&lt;p&gt;Q2. I still have problem.
My goal is that it should be advertising in low power mode.
That&amp;#39;s why I&amp;#39;m developing BLE.
As I&amp;#39;ve tested &amp;quot;ble_app_hrs&amp;quot; as peripheral.
Its current cunsumption is too high.
As I think, that&amp;#39;s because &amp;quot;ble_app_hrs&amp;quot; advertising speed is very fast.
So I changed source code as below.
But its current consumption is still 1mA around.
I think there is the other good way to save current consumption even it&amp;#39;s advertising.
Could you give me more advice?
If i have to use slow advertising mode, that&amp;#39;s no problem.
I need your help.&lt;/p&gt;
&lt;p&gt;#define APP_ADV_INTERVAL                 100000&lt;/p&gt;
&lt;p&gt;static void advertising_init(void)
{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint32_t      err_code;
ble_advdata_t advdata;

// Build advertising data struct to pass into @ref ble_advertising_init.
memset(&amp;amp;advdata, 0, sizeof(advdata));

advdata.name_type               = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance      = true;
advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
advdata.uuids_complete.p_uuids  = m_adv_uuids;

ble_adv_modes_config_t options = {0};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;#if 0 // fast mode
options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
options.ble_adv_fast_interval = APP_ADV_INTERVAL;
options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
#else // slow mode
options.ble_adv_slow_enabled  = BLE_ADV_SLOW_ENABLED;
options.ble_adv_slow_interval = APP_ADV_INTERVAL;
options.ble_adv_slow_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
#endif&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = ble_advertising_init(&amp;amp;advdata, NULL, &amp;amp;options, on_adv_evt, NULL);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;int main(void)
{&lt;/p&gt;
&lt;p&gt;......&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = ble_advertising_start(BLE_ADV_MODE_SLOW);
APP_ERROR_CHECK(err_code);

// Enter main loop.
for (;;)
{
    power_manage();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: regarding Sleep Mode of nRF51</title><link>https://devzone.nordicsemi.com/thread/47344?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 14:42:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dcb5cc0-865f-4b4e-9228-b01dda4ca6f8</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;&lt;strong&gt;Q1)&lt;/strong&gt; When the BSP library is included in the project, I would recommend you to not use the buttons used by that library, button 1 and 2. BSP is by default included in the projects in the SDK. As you can see in the &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Fexamples_bsp.html&amp;amp;cp=4_0_0_3_4_0_1&amp;amp;anchor=examples_ble_button_functionality"&gt;BSP documentation&lt;/a&gt;, button 1 will put the chip to sleep. If you change the button that triggers the system OFF mode to button 3 or 4 you will see that it works.&lt;/p&gt;
&lt;p&gt;When using the softdevice, and want to put the chip to system OFF, you should use the function &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s130.api.v2.0.0%2Fgroup___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;cp=2_7_2_1_0_2_7_2_25&amp;amp;anchor=ga774947ee0e200456ea3aec3fc7f8bd6b"&gt;sd_power_system_off(..)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The same would be for the RAM on/off register; use &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s130.api.v2.0.0%2Fgroup___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;cp=2_7_2_1_0_2_7_2_22&amp;amp;anchor=ga3e7395f75509209909c47a9dc9fa8a2b"&gt;sd_power_ramon_set(..)/get(..)/clr(..)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As you may know, the LEDs are &amp;quot;inverted&amp;quot; on the nRF51-DK. It means that nrf_gpio_pin_clear(LED) will turn the LED on.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Q2)&lt;/strong&gt; sd_power_system_off(..)/ NRF_POWER-&amp;gt;SYSTEMOFF = 1 will put the chip to system OFF. When the chip wakes up, the chip will be reset, see the nRF51 Series Reference Manual, chapter 12.1.5.&lt;/p&gt;
&lt;p&gt;If you want the chip to sleep between the advertising/scanning events, you should use &lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s130.api.v2.0.0%2Fgroup___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;cp=2_7_2_1_0_2_7_2_0&amp;amp;anchor=ga11d88d38ac99fb72cde74c9385d36433"&gt;sd_app_evt_wait(..)&lt;/a&gt;. All SDK examples do this using power_manage().&lt;/p&gt;
&lt;p&gt;For your reference, I have attached a modified version of your code that sets the chip in system OFF when pushing button 3:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
    bool erase_bonds;
		uint32_t err_code;

    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
    buttons_leds_init(&amp;amp;erase_bonds);
    nrf_log_init();
    APPL_LOG(&amp;quot;Heart rate collector example\r\n&amp;quot;);
    ble_stack_init();
    device_manager_init(erase_bonds);
    db_discovery_init();
    hrs_c_init();
    bas_c_init();
	
		// Configure BUTTON1 as a regular input 
    nrf_gpio_cfg_input(BUTTON_3, NRF_GPIO_PIN_PULLUP); 
  
    // Configure BUTTON2 with SENSE enabled  
    nrf_gpio_cfg_sense_input(BUTTON_4, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW); 
  
    // Configure the LED pins as outputs 
    nrf_gpio_range_cfg_output(LED_START, LED_STOP); 

    scan_start();
 		
		nrf_gpio_pin_clear(LED_3); // todo
		nrf_gpio_pin_set(LED_4);
		
    for (;; )
    {
			// If BUTTON1 is pressed.. 
      if(nrf_gpio_pin_read(BUTTON_3) == 0) 
      { 
          // Clear LED1
          nrf_gpio_pin_toggle(LED_4); 
          // Enter system OFF. After wakeup the chip will be reset, and the MCU will run from the top 
					err_code = sd_power_system_off();
					APP_ERROR_CHECK(err_code);
          //NRF_POWER-&amp;gt;SYSTEMOFF = 1; 
      } 
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>