<?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>Unwanted reset</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/22494/unwanted-reset</link><description>Hi,
I&amp;#39;m working on a firmware that is used in a nrf51822. I discovered an unwanted behavior of my system.
When the system is in power_manage mode, it can wake up in two different ways: 
 
 pressing a button 
 waiting 10 minutes 
 
 After pressing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Jun 2017 12:50:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/22494/unwanted-reset" /><item><title>RE: Unwanted reset</title><link>https://devzone.nordicsemi.com/thread/88498?ContentTypeID=1</link><pubDate>Fri, 09 Jun 2017 12:50:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3fbc4f75-303a-441c-a584-12cbcfa0b2d5</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;To make sure the RESETREAS register gives you the correct it should be cleared after a reset and after reading the value. When you read the value, its meaning can be decoded by reading the register meaning in the nRF51 Series reference manual.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unwanted reset</title><link>https://devzone.nordicsemi.com/thread/88502?ContentTypeID=1</link><pubDate>Fri, 09 Jun 2017 11:51:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dfb1604-4ee8-4af7-ba0c-c182541ab7e0</guid><dc:creator>Francesca</dc:creator><description>&lt;p&gt;@kristin I red the first thread that you suggested me. Where do you suggest to write the code 		uint32_t reset_reason = NRF_POWER-&amp;gt;RESETREAS; ?
Maybe before the for(;;)?
Anyway, I wrote this code before a sd_power_system_off() and the returned value is always 0x00010005. What does it mean?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unwanted reset</title><link>https://devzone.nordicsemi.com/thread/88501?ContentTypeID=1</link><pubDate>Tue, 06 Jun 2017 13:27:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8626e925-6130-4663-aabe-4e74e266b253</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;Unless &amp;quot;DEBUG&amp;quot; is defined, APP_ERROR_CHECK() will trigger a reset upon an error, see the  APP_ERROR_CHECK() function and &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;this&lt;/a&gt; thread.&lt;/p&gt;
&lt;p&gt;To read the RESETREAS register:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrfjprog --memrd 0x40000400
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It can also be useful to have a look at &lt;a href="https://devzone.nordicsemi.com/question/101631/i-can-read-nrf_power-resetreas-in-code-but-i-cant-with-nrfjprog/"&gt;this&lt;/a&gt; thread.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unwanted reset</title><link>https://devzone.nordicsemi.com/thread/88500?ContentTypeID=1</link><pubDate>Tue, 06 Jun 2017 09:01:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:168819ae-14c6-4690-babb-df07f6847f16</guid><dc:creator>Francesca</dc:creator><description>&lt;p&gt;@kristin How can I check the reset reason register using Keil uVision5 debugger?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unwanted reset</title><link>https://devzone.nordicsemi.com/thread/88499?ContentTypeID=1</link><pubDate>Tue, 06 Jun 2017 08:56:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe6ffdda-1726-4deb-b4fa-49ed7a276ff2</guid><dc:creator>Francesca</dc:creator><description>&lt;p&gt;I discovered which code line is generating the reset.
Before entering power manage mode this code is executed&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void pre_power_manage_settings(void)
{
	//Timers stop
//	system_timer_stop(); 
	one_sec_timer_stop();
	button_idle_timer_stop();
	//buzzer_timer_stop();
	//rele_timer_stop();
	//led_repetition_timer_stop();
	//led_timer_stop();
	//wdt_refresh_timer_stop();
	three_min_timer_start();

	//Stop advertising
	beacon_advertising_stop();
	
	
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After having waited 10 minutes the system wakes up and this code is executed&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void post_power_manage_settings(void) 
{
	//Timers stop
//	system_timer_stop(); 
	one_sec_timer_start();
	button_idle_timer_start();	
	//Stop advertising
	beacon_advertising_start();		
}

void beacon_advertising_start(void)
{

	uint32_t err_code;
	ble_gap_addr_t ble_gap_addr;

	err_code = sd_ble_gap_address_get(&amp;amp;ble_gap_addr);
	

	err_code = sd_ble_gap_adv_start(&amp;amp;m_adv_params);
	if (err_code == NRF_SUCCESS)
			advertising_start = true;

	APP_ERROR_CHECK(err_code);
}
    void beacon_advertising_stop(void)
{
	uint32_t err_code;
	err_code = sd_ble_gap_adv_stop();
	if (err_code == NRF_SUCCESS)
			advertising_start = false;
	APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case the system doesn&amp;#39;t reset and advertising starts and timers reload with no problem.
The same code is executed after pressing the button but in this particular case the system restarts. In order to avoid reset after pressing button, I should comment the code line     	beacon_advertising_start();		
How can I start advertising again without generating a reset after pressing the button?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unwanted reset</title><link>https://devzone.nordicsemi.com/thread/88497?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2017 14:45:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc1cc43b-9b00-4242-b24e-a3e51ebd66cb</guid><dc:creator>CBD</dc:creator><description>&lt;p&gt;This is a good first step.
You may also wish to check that you&amp;#39;re not initialising your timer when it is already initialised. I have found that this can cause an ASSERT which will then trigger a hardware reset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unwanted reset</title><link>https://devzone.nordicsemi.com/thread/88496?ContentTypeID=1</link><pubDate>Thu, 01 Jun 2017 13:53:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e56a3e2-c4fb-4fa9-8475-c9231eaeff86</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;The first step would be to check the reset reason register (RESETREAS) after the reset. Chapter 12.1.11 in the nRF51 Series Reference Manual explains the various reset sources.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>