<?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>Why does nRF52 hrs sdk11 example sd_power_off return 6?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15677/why-does-nrf52-hrs-sdk11-example-sd_power_off-return-6</link><description>Hello all:
I am running a nRF52832QF AAB0 pca10040 board with SDK11 in Segger embedded studio.
I followed the &amp;#39;getting started&amp;#39; tutorial. 
 After pressing button 1, I noticed an error handler was being triggered. It was the sd_power_system_off call</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Aug 2016 06:08:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15677/why-does-nrf52-hrs-sdk11-example-sd_power_off-return-6" /><item><title>RE: Why does nRF52 hrs sdk11 example sd_power_off return 6?</title><link>https://devzone.nordicsemi.com/thread/59879?ContentTypeID=1</link><pubDate>Fri, 12 Aug 2016 06:08:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a80ce63c-16ce-4422-abed-403809e380fe</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;forgot to add while loop in debug mode. fixed it now . Yes both in normal system off and emulated system off, wakeup source will generate a reset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why does nRF52 hrs sdk11 example sd_power_off return 6?</title><link>https://devzone.nordicsemi.com/thread/59878?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2016 19:35:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4a9dd31-4704-4ed7-9126-1ce585a76083</guid><dc:creator>syntroniks</dc:creator><description>&lt;p&gt;That looks interesting. So theoretically a wakeup source (let&amp;#39;s pick an IO pin, maybe a button press) will in fact generate a reset when in emulated system OFF. Is that correct? Perhaps I will add that while loop.&lt;/p&gt;
&lt;p&gt;Thanks for the snippet!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why does nRF52 hrs sdk11 example sd_power_off return 6?</title><link>https://devzone.nordicsemi.com/thread/59877?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2016 07:08:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:752ce0aa-cad4-4af4-ac85-a089c76c360a</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;This is defined in nrf_error_soc.h&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN         (NRF_ERROR_SOC_BASE_NUM + 6)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The reason is explained by Emulated system off mode.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If the device is in debug interface
mode, System OFF will be emulated to
secure that all required resources
needed for debugging are available
during System OFF. See Debug and trace
on page 99 for more information.
Required resources needed for
debugging include the following key
components:  Since the CPU is kept on
in an emulated System OFF mode, it is
recommended to add an infinite loop
directly after entering System OFF, to
prevent the CPU from executing code
that normally should not be executed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In normal system off mode, the CPU goes to deep sleep and on wakeup a reset is generated and the CPU execution starts from address 0x0. In emulated system OFF, the CPU keeps on going, but the wakeup resource will generate a reset. sd_power_system_off() function expects that it should not return which is correct in non debug mode.&lt;/p&gt;
&lt;p&gt;I would suggest to to ignore the error in debug mode&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#ifdef DEBUG_NRF
 (void) sd_power_system_off();
 while(1);
#else
  APP_ERROR_CHECK(sd_power_system_off());
#endif  // DEBUG_NRF
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you have to manually add this (DEBUG_NRF) flag in your project.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why does nRF52 hrs sdk11 example sd_power_off return 6?</title><link>https://devzone.nordicsemi.com/thread/59881?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2016 23:40:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60aed521-476e-4b54-967a-6af96f7373c2</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I&amp;#39;ve seen errors like this when you try and call an sd_ function without having initialized the softdevice.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why does nRF52 hrs sdk11 example sd_power_off return 6?</title><link>https://devzone.nordicsemi.com/thread/59880?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2016 18:08:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:344907b0-5957-4c17-8b5e-a13beb8c97e2</guid><dc:creator>syntroniks</dc:creator><description>&lt;p&gt;Proposed solution after some searching:
&lt;a href="https://devzone.nordicsemi.com/question/64370/sd_power_system_off-returns-immediately-and-forces-reset/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Will investigate and report back.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;EDIT&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;You can not call sd_power_system_off when a debugger is attached.&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;(you can, it just won&amp;#39;t work)&lt;/p&gt;
&lt;p&gt;I have confirmed the application runs as expected when the debugger is not attached. The error code makes sense, this is a good example of a &amp;#39;gotcha&amp;#39;. The nice thing about mistakes is you never have to make the same one again for the rest of your life. Now I know.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>