<?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>ble connection trace after power down</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107063/ble-connection-trace-after-power-down</link><description>hello Nordic 
 i am workig with nrf52840 and nrf52832 with ncs v2.5.0 
 i sometimes get power down resets while connecting via BLE cause of low battery. 
 since i know at rise-up that reset reason was power i would also like to know if my device was connected</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 03 Jan 2024 12:44:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107063/ble-connection-trace-after-power-down" /><item><title>RE: ble connection trace after power down</title><link>https://devzone.nordicsemi.com/thread/462491?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2024 12:44:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:788e9a58-a8af-4682-a30b-5501fc9dd70b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is no register keeping information about BLE connection status. BLE protocol state is known only to the software stack, the RADIO peripheral just sends/receives packets defined by the SW.&lt;/p&gt;
&lt;p&gt;You can use the&amp;nbsp;&lt;a title="Power supply supervisor" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=5_2_0_17_3#unique_570929384"&gt;Power supply supervisor&lt;/a&gt;&amp;nbsp;to get an early warning when battery voltage becomes too low, but unfortunately, it is not possible to write the connection state to flash directly if you get into this state: &amp;quot;&lt;em&gt;If power-fail warning is enabled and the supply voltage is below V&lt;sub&gt;POF&lt;/sub&gt;&lt;/em&gt;&lt;span&gt;&lt;em&gt;&amp;nbsp;the power-fail comparator will prevent the NVMC from performing write operations to the NVM.&lt;/em&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Depending on the voltage level where the warning is generated, you could disable the Power supply supervisor feature (or perform a soft reset with&amp;nbsp;&lt;a title="  GPREGRET  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=5_2_0_17_8_6#register.GPREGRET"&gt;GPREGRET&lt;/a&gt;&amp;nbsp;register set to a specific value that is written to flash on boot) to write the state to flash before the device is powered down.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Another alternative is to always write the connection state to flash, for instance using &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.0/zephyr/services/storage/nvs/nvs.html"&gt;NVS library&lt;/a&gt;, but this could wear out flash over time if you have lots of connect/disconnects (flash is rated for &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/abs_max_ratings.html#abs_max_ratings"&gt;10000 write/erase cycles per page&lt;/a&gt;).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>