<?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 deal with a case when user takes a battery off while BLE communication?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81856/how-to-deal-with-a-case-when-user-takes-a-battery-off-while-ble-communication</link><description>Nrf52832, SDK 13.0 Softdevice 132 PMIC: bq25150 
 
 I have a battery powered BLE device. When a user takes off the battery and put it back and powering on, the device does not seem start from MBR (master boot record). 
 I have a power button that is connected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 22 Nov 2021 08:28:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81856/how-to-deal-with-a-case-when-user-takes-a-battery-off-while-ble-communication" /><item><title>RE: How to deal with a case when user takes a battery off while BLE communication?</title><link>https://devzone.nordicsemi.com/thread/339964?ContentTypeID=1</link><pubDate>Mon, 22 Nov 2021 08:28:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7186dad6-899e-4373-aa92-a0f447d974fc</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="joojoo5"]&lt;p&gt;When it starts from power on button, the red light stayed about 2 seconds.&lt;/p&gt;
&lt;p&gt;However, when it starts from&amp;nbsp;&lt;span&gt;NVIC_SystemReset(), then it stayed&amp;nbsp; little about 2.5 more more seconds.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can anyone explain why it happens like that?&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;When running on the internal HFCLK, you will see variations up to +/- 6%:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/clock.html?cp=4_2_0_18_3_0#unique_641326801"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/clock.html?cp=4_2_0_18_3_0#unique_641326801&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, if you expect 2 seconds, but see 2.5 seconds in this specific loop:&lt;/p&gt;
[quote user="joojoo5"]nrf_gpio_pin_set(PIN25LED_RED);&lt;br /&gt; nrf_delay_ms(2000);&lt;br /&gt; nrf_gpio_pin_clear(PIN25LED_RED);[/quote]
&lt;p&gt;that is quite strange. Do you measure pulse with a logic analyzer? If yes, can you share the results?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that a startup from power-on-reset will take longer than a soft-reset, as the nRF will be kept in reset for a given time period to ensure that VDD is within a valid area:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=4_2_0_17_9_1#unique_580976277"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=4_2_0_17_9_1#unique_580976277&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to deal with a case when user takes a battery off while BLE communication?</title><link>https://devzone.nordicsemi.com/thread/339723?ContentTypeID=1</link><pubDate>Fri, 19 Nov 2021 00:11:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bb3e5f7-7189-42f8-9aea-945ddf982d4d</guid><dc:creator>joojoo5</dc:creator><description>&lt;p&gt;After more careful investigation, I found that the above statements are not correct.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In fact, the bootloader is executed. However, the speed of execution is different.&lt;/p&gt;
&lt;p&gt;See below code.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;int main(void)&lt;br /&gt;{&lt;br /&gt; uint32_t ret_val;&lt;/p&gt;
&lt;p&gt;(void) NRF_LOG_INIT(NULL);&lt;/p&gt;
&lt;p&gt;NRF_LOG_INFO(&amp;quot;Inside main\r\n&amp;quot;);&lt;/p&gt;
&lt;p&gt;nrf_gpio_cfg_output(PIN25LED_RED);&lt;/p&gt;
&lt;p&gt;nrf_gpio_pin_set(PIN25LED_RED);&lt;br /&gt; nrf_delay_ms(2000);&lt;br /&gt; nrf_gpio_pin_clear(PIN25LED_RED);&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;buttons_init();&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When it starts from power on button, the red light stayed about 2 seconds.&lt;/p&gt;
&lt;p&gt;However, when it starts from&amp;nbsp;&lt;span&gt;NVIC_SystemReset(), then it stayed&amp;nbsp; little about 2.5 more more seconds.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can anyone explain why it happens like that?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;PS: Please note that I had the delay time of 200ms before and I didn&amp;#39;t see the red light. That was why I thought it didn&amp;#39;t start from the bootloader. It came more apparent&amp;nbsp;as I put more delay time. Please discard my original questions.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to deal with a case when user takes a battery off while BLE communication?</title><link>https://devzone.nordicsemi.com/thread/339636?ContentTypeID=1</link><pubDate>Thu, 18 Nov 2021 12:39:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebc325e5-3f53-4f73-8bdb-7d76cd0b0925</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;It is not easy to state where it is stuck, especially without any logs.&lt;/p&gt;
&lt;p&gt;When you power on the device, have you checked where it is stuck by attaching the debugger to a running target?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to deal with a case when user takes a battery off while BLE communication?</title><link>https://devzone.nordicsemi.com/thread/339609?ContentTypeID=1</link><pubDate>Thu, 18 Nov 2021 11:51:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0433e5c3-7d7a-461e-bde3-eccb4b41aa98</guid><dc:creator>joojoo5</dc:creator><description>&lt;p&gt;Just want to correct myself.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Bootloader is not executed when power is on. But, when&amp;nbsp;NVIC_SystemReset() is exucuted, the bootloader is executed.&lt;/p&gt;
&lt;p&gt;Why is it working like that?&lt;/p&gt;
&lt;p&gt;Is there a way I can do so that the bootloader is executed even when battery power is on?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>