<?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>Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/120017/sleep-does-not-work-with-ble-advertise</link><description>Hi, 
 nRF52832, SDK 17.1.0 with Softdevice S132. 
 Softdevice sleep does not work when advertising. Application flow is to advertise one packet, then go to sleep for X seconds. Sleep part waits for a flag from &amp;quot; BLE_GAP_EVT_ADV_SET_TERMINATED &amp;quot; event</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Apr 2025 16:56:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/120017/sleep-does-not-work-with-ble-advertise" /><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/530061?ContentTypeID=1</link><pubDate>Tue, 01 Apr 2025 16:56:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2df699fc-5df2-4dc5-bd20-453702522137</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;Everything is ok. Problem is in PPK2 due to AMD chipset and USB. This is how it looks when USB is ok&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1743526567688v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/529367?ContentTypeID=1</link><pubDate>Thu, 27 Mar 2025 17:32:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:add29a48-f62d-433f-9dc4-43c05367cc80</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/example.ppk2"&gt;devzone.nordicsemi.com/.../example.ppk2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s code from example ppk2 file -&amp;nbsp;&lt;a href="https://github.com/silvio3105/sTPMS_FW/tree/nrf_sleep"&gt;github.com/.../nrf_sleep&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Advertise period is 5s, 1 advertise, wakeup with RTC2&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/no-rtc.ppk2"&gt;devzone.nordicsemi.com/.../no-rtc.ppk2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is example when RTC2 is not inited(in System::init) and body of System::startWakeupTimer is removed. WDT resets the MCU. It still advertises on startup(1 advertise).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Even if I disable SD before sleep, and replace sleep with __WFI I still gets those peaks at 1/2 of measure period.&lt;/p&gt;
&lt;p&gt;Should I open new ticket?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/529315?ContentTypeID=1</link><pubDate>Thu, 27 Mar 2025 13:52:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3dea242-62fd-47fd-86f1-878ce7b15d99</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;No, I would like to get the .ppk2 files first to see if the pattern looks familliar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/529313?ContentTypeID=1</link><pubDate>Thu, 27 Mar 2025 13:48:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fb9f748-1477-4266-b4a6-2a1943692fc2</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;Did you find anything in the code? I use RTC2 and as we see, it causes some problems with peaks every cc/2.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/529300?ContentTypeID=1</link><pubDate>Thu, 27 Mar 2025 13:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea77bae9-ba51-4efa-b52d-d091bf07062a</guid><dc:creator>Einar Thorsrud</dc:creator><description>[quote user="silvio3105"]Is there any way to use softdevice for wakeup with periods up to 60 seconds?[/quote]
&lt;p&gt;The SoftDevice it self will wake the CPU (based on RTC0) when needed, but it will put the CPU to sleep again without fordarding to the application unless there are events for the application. For the application to wake on a specific ime, you need to use your own RTC instances (either like you do with RTC2, or for instance using the app_timer library which is based on RTC1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/529245?ContentTypeID=1</link><pubDate>Thu, 27 Mar 2025 09:48:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7798c3eb-2be5-440f-be00-1fce76950e18</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;Code is at&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/silvio3105/sTPMS_FW/blob/dev/Application/Main.cpp"&gt;github.com/.../Main.cpp&lt;/a&gt;&lt;br /&gt;&lt;a id="" href="https://github.com/silvio3105/sTPMS_FW/tree/dev/Modules"&gt;https://github.com/silvio3105/sTPMS_FW/tree/dev/Modules&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I did a test -&amp;nbsp;did not used RTC2 and its wakeup(just commented RTC stuff) and let watchdog do the reset. It had peaks every 9 seconds(WDT period is measure period + 4 seconds). At that time, softdevice was enabled and BLE is used for advertise(1 adv event) right after startup and before sleep.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is there any way to use softdevice for wakeup with periods up to 60 seconds?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/529240?ContentTypeID=1</link><pubDate>Thu, 27 Mar 2025 09:33:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd4b0e88-062f-474a-88f6-6f3ecb9002f5</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I see, so you are triggering errata &lt;a href="https://docs.nordicsemi.com/bundle/errata_nRF52832_Rev2/page/ERR/nRF52832/Rev2/latest/anomaly_832_179.html#anomaly_832_179"&gt;179&lt;/a&gt; from your use?&lt;/p&gt;
&lt;p&gt;The zoomed in is still a bit fare out, but it could look like the first is BLE advertising (though it is still ab it dificult to see clearly, so you could export and upload the .ppk2 file). But other than that, we would probably&amp;nbsp; need to look in your code to understand what any other wakups are, as the SoftDevice will not wake the device unless it has work to do (which it will not have outside of BLE events when you use a 32.768 kHz crytsal).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/529161?ContentTypeID=1</link><pubDate>Wed, 26 Mar 2025 22:19:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:054d0578-095a-496c-a046-52eaa4b8ec65</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;So I reduced base power consumption when in sleep to ~5uA. Only problem is that I have peaks(BLE/SD?) every 2.5 seconds. Wakeup period is 5s.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1743027523164v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1743027548568v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Closer look to 2.5s peaks&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1743027604720v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT:&lt;/p&gt;
&lt;p&gt;Seems like RTC2 is cause of wakeup. Not sure why since I don&amp;#39;t see anything related to CC / 2 wakeup/interrupt/event.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;EDIT2: Errata for rev2 - section 3.47&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/529156?ContentTypeID=1</link><pubDate>Wed, 26 Mar 2025 21:19:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efd9d6a6-9690-4cb7-9889-df504c03e91b</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;I think is not HW problem.&lt;/p&gt;
&lt;p&gt;I did this&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;main()&lt;br /&gt;{&lt;/p&gt;
&lt;p&gt;NRF_POWER-&amp;gt;POFCON = 0;&lt;/p&gt;
&lt;p&gt;NRF_POWER-&amp;gt;DCDCEN = 1;&lt;/p&gt;
&lt;p&gt;while ()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;__WFI();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;// OLD CODE&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And consumption is ~7uA&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528808?ContentTypeID=1</link><pubDate>Tue, 25 Mar 2025 11:04:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c8bd9eb-c92a-415c-ae09-80230aac8ad4</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;I use RTT for logging. Only RTC2 is enabled during sleep. ADC is stopped and disabled on&amp;nbsp;EVENTS_END.&lt;/p&gt;
&lt;p&gt;VDD is 3V from PPK2. Only PPK2 is connected, no J-Link.&lt;br /&gt;RTC2 wakeup period(and advertise period) is 5s.&lt;/p&gt;
&lt;p&gt;When you say BLE events - what do you mean by BLE events? I use only BLE for advertise. Scanner and connect stuff should be disabled, so no BLE events for that?&lt;br /&gt;&lt;br /&gt;I use custom board&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1742900444803v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;DCDC is disabled before sleep and enabled after wakeup(due to higher consumption with DCDC on during sleep).&lt;br /&gt;&lt;br /&gt;Code is:&amp;nbsp;&lt;a id="" href="https://github.com/silvio3105/sTPMS_FW/tree/dev"&gt;https://github.com/silvio3105/sTPMS_FW/tree/dev&lt;/a&gt;&amp;nbsp;(dev branch, application and modules folder)&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1742900581368v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ppk2_2D00_20250325T110356.ppk2"&gt;devzone.nordicsemi.com/.../ppk2_2D00_20250325T110356.ppk2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is done with DEBUG build(DEBUG flag is added during build, NRF_LOG is enabled over RTT)&lt;br /&gt;Most os these peaks are 2.5s apart. nRF connect app says period is 5 seconds.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528751?ContentTypeID=1</link><pubDate>Tue, 25 Mar 2025 08:04:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee311724-c003-46cf-8bd5-da1d1cc71e3c</guid><dc:creator>Einar Thorsrud</dc:creator><description>[quote user="silvio3105"]Does DEBUG flag or LOG module has effect on wakeups?[/quote]
&lt;p&gt;No. If you don&amp;#39;t use deferred logging, logs will be processed whenever there is logging. If you use deferred logging, you process logs in your main loop before calling&amp;nbsp;sd_app_evt_wait() (as you can see in most SDK examples).&lt;/p&gt;
[quote user="silvio3105"]This is power consumption without DEBUG flag and NRF LOG module. Softdevice is disabled before calling __WFI();&lt;br /&gt;It looks the same as consumption without DEBUG and LOG module and SD is not disabled before calling SD sleep function.[/quote]
&lt;p&gt;sd_app_evt_wait() will only make the CPU sleep, it does not do anythign else to put the system in a low power mode (like stopping peripherals etc). If you use UART&amp;nbsp;for logging(?) for instance, that will increase power consumption as the UART will stay on also in sleeep.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you could zoom in the time scale so we see the actual current consumption pattern of just the peak, with some luck, we&amp;nbsp;may be able to recognize what it could be. Also, are you using a DK or a custom board, and is the DCDC enabled or not? And if not using a DK, what is the supply voltage? (this could help in understanding what wee see in a zoomed in current consumption plot). Perhaps you can also export and update the data from the power analyser so that I can zoom in and look at this on my end?&lt;/p&gt;
[quote user="silvio3105"]Is there any way to disable LF calibration from Softdevice?[/quote]
&lt;p&gt;Calibration is only used when the LFRC is enabled. It is not possible (nor needed) to calibrate the LFXO, so this should not be relevant as you write that. you have configured LFXO.&lt;/p&gt;
[quote user="silvio3105"]Softdevice is used only for advertise. I don&amp;#39;t know why I have double peaks and why MCU is woken up when measure/advertise period is 5 seconds.[/quote]
&lt;p&gt;As mentionned, we need to look more closely at the peaks to know what they could represent. And the next is to look at your code. As you use LFXO, the SoftDevice will only wake up for BLE events.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528698?ContentTypeID=1</link><pubDate>Mon, 24 Mar 2025 18:16:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87697552-8acd-4e63-9b27-5ebeebae1884</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;Does DEBUG flag or LOG module has effect on wakeups?&lt;br /&gt;This is power consumption without DEBUG flag and NRF LOG module. Softdevice is disabled before calling __WFI();&lt;br /&gt;It looks the same as consumption without DEBUG and LOG module and SD is not disabled before calling SD sleep function.&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1742840182071v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528696?ContentTypeID=1</link><pubDate>Mon, 24 Mar 2025 17:43:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16ea6a4c-871f-4dda-bbeb-443369f777f8</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;Okey.&lt;br /&gt;&lt;br /&gt;Is there any way to disable LF calibration from Softdevice?&lt;/p&gt;
&lt;p&gt;In SDK config XTAL is selected, ppm is set to 20 and CTIV values are set to 0. I guess 0 will disable it but I&amp;#39;m not sure.&lt;br /&gt;&lt;br /&gt;Softdevice is used only for advertise. I don&amp;#39;t know why I have double peaks and why MCU is woken up when measure/advertise period is 5 seconds.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528643?ContentTypeID=1</link><pubDate>Mon, 24 Mar 2025 14:08:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c05e424d-3a2d-454b-9514-ce2c8344edff</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="silvio3105"]If advertise is ongoing, MCU will not go to sleep until it&amp;#39;s done. I guess Softdevice will reject sleep until it&amp;#39;s done with advertise.[/quote]
&lt;p&gt;That depends on what you mean. As long as you call sd_app_evt_wait from the main loop, the SoftDevice will enter sleep whenever it has processed it&amp;#39;s interrupts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528570?ContentTypeID=1</link><pubDate>Mon, 24 Mar 2025 09:59:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70d47569-aa86-4347-beb2-32979bca6878</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;Thanks.&lt;br /&gt;&lt;br /&gt;If advertise is ongoing, MCU will not go to sleep until it&amp;#39;s done. I guess Softdevice will reject sleep until it&amp;#39;s done with advertise. So I don&amp;#39;t see the difference between calling sleep after starting advertise or waiting for flag for advertise is done.&lt;br /&gt;It is not clear(maybe) but device will advertise only one packet:&lt;br /&gt;- Measure stuff&lt;br /&gt;- Advertise measured data only once&lt;br /&gt;- Sleep for X seconds&lt;br /&gt;- Repeat&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I use external LXFO(configured in SDK config). Maybe SD wakes up to check is someone wants to connect? I don&amp;#39;t need connection, just advertise. Something wakes up the MCU and it&amp;#39;s not RTC2.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528563?ContentTypeID=1</link><pubDate>Mon, 24 Mar 2025 09:34:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a004fb3d-422e-4ce0-9c48-b2747415a03f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="silvio3105"]&lt;p&gt;Should I wait for advertise to end or just go to sleep without waiting?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Go to sleep withotu waiting.&lt;/p&gt;
[quote user="silvio3105"]If I get you right - I should call SD sleep from main loop only if there is nothing else to do?[/quote]
&lt;p&gt;No, &lt;em&gt;always&lt;/em&gt; call&amp;nbsp;sd_app_evt_wait() from the main loop. This way, the CPU will enter sleep whenever there is nothing to do, and be woken up when there is work to do (the SoftDevice will wake up on RTC0 for anythign it shoudl do), your application wakes up on other interrupts, for instance RTC2 (also RTC1 if you use the app_timer), and any other interrupt sources (could for instance be GPIO pin interrupt).&lt;/p&gt;
[quote user="silvio3105"]&lt;p&gt;Something like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;No. It is essential that you enter sleep also when advertising. There is no point in spending power on busy waiting the CPU when advertising, whcih most of the time is waiting for the next advertising event.&lt;/p&gt;
[quote user="silvio3105"]Why are there double peaks?[/quote]
&lt;p&gt;I would need to see a much zoomed in view to be able to see what this current consumption pattern could represent (though I notice they are periodic).&lt;/p&gt;
[quote user="silvio3105"]Why Softdevice wakes up the device when it does not scan or advertise? Seems odd to me.[/quote]
&lt;p&gt;Do you use a 32.768 kHz crystall or the internal LFRC? If you use the internal LFRC, you probably (and must) enable regular calibration of the LFRC. The SoftDevice will wake up to perform check temperature and perform calibration, normally every 4 seconds (this is configured when initializing the SoftDevice). This happens a bit too often for that to be likely, but you could check the configuration. Other than that, then SoftDevice will normally only wake up when there are Bluetooth events (scanning, advertising or maintaing a connection).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528460?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 18:30:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1b5a41d-5598-4cc7-8e11-7ab7c209d801</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;Code like this works. Sleeps well wiith little peaks.&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1742581700360v1.png" alt=" " /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1742581753406v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Why are there double peaks? Why Softdevice wakes up the device when it does not scan or advertise? Seems odd to me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528436?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 15:01:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf4c446f-9568-40f6-9283-80ace1c7de84</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	//BLE::advertise(&amp;amp;data, sizeof(data));

	while (1)
	{
		/*if (System::isWoken() == Return_t::OK)
		{
			BLE::advertise(&amp;amp;data, sizeof(data));
		}*/

		//if (BLE::isAdvertiseDone() == Return_t::OK)
		if (1)
		{
			System::startWakeupTimer();
			System::sleep();
		}

		// Feed the dog
		System::feedWatchdog();
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is in main loop. There is no RTOS.&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;span&gt;BLE::isAdvertiseDone()&lt;/span&gt;&amp;quot; checks advertise flag. Device waits for advertise to end to go to sleep.&lt;/p&gt;
&lt;p&gt;This is BLE event handler&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void onBLEEvent(ble_evt_t const* event, void* context)
{
	_PRINTF_INFO(&amp;quot;BLE EVT %u\n&amp;quot;, event-&amp;gt;header.evt_id);
	ret_code_t ret = NRF_SUCCESS;

	switch (event-&amp;gt;header.evt_id)
	{
		case BLE_GAP_EVT_DISCONNECTED:
		{
			_PRINT_INFO(&amp;quot;BLE disconnected\n&amp;quot;);
			break;
		}

		case BLE_GAP_EVT_CONNECTED:
		{
			_PRINT_INFO(&amp;quot;BLE connect\n&amp;quot;);
			ret = sd_ble_gap_disconnect(event-&amp;gt;evt.gattc_evt.conn_handle,
				BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
			APP_ERROR_CHECK(ret);
			break;
		}

		case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
		{
			_PRINT_INFO(&amp;quot;PHY update request\n&amp;quot;);
			static const ble_gap_phys_t phys =
			{
				.tx_phys = BLE_GAP_PHY_AUTO,
				.rx_phys = BLE_GAP_PHY_AUTO,
			};
			ret = sd_ble_gap_phy_update(event-&amp;gt;evt.gap_evt.conn_handle, &amp;amp;phys);
			APP_ERROR_CHECK(ret);
			break;
		} 

		case BLE_GATTC_EVT_TIMEOUT:
		{
			_PRINT_INFO(&amp;quot;GATT Client Timeout\n&amp;quot;);
			ret = sd_ble_gap_disconnect(event-&amp;gt;evt.gattc_evt.conn_handle,
												BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
			APP_ERROR_CHECK(ret);
			break;
		}

		case BLE_GATTS_EVT_TIMEOUT:
		{
			_PRINT_INFO(&amp;quot;GATT Server Timeout\n&amp;quot;);
			ret = sd_ble_gap_disconnect(event-&amp;gt;evt.gatts_evt.conn_handle,
												BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
			APP_ERROR_CHECK(ret);
			break;
		}

		case BLE_GAP_EVT_ADV_SET_TERMINATED:
		{
			advDone = 1;	
			_PRINT_INFO(&amp;quot;Advertise done\n&amp;quot;);
			break;
		}

		default: break;
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is whole project(dev branch) - main.cpp is in Application folder and System and BLE are in Modules folder.&amp;nbsp;&lt;a id="" href="https://github.com/silvio3105/sTPMS_FW/tree/dev"&gt;https://github.com/silvio3105/sTPMS_FW/tree/dev&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Should I wait for advertise to end or just go to sleep without waiting?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If I get you right - I should call SD sleep from main loop only if there is nothing else to do?&lt;br /&gt;What wakes up the device? I don&amp;#39;t expect to be waken up by SoftDevice, only RTC2.&lt;/p&gt;
&lt;p&gt;Something like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;switch (state)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;case MEASURE: // Measure pressure&lt;/p&gt;
&lt;p&gt;case ADVERTISE: // Advertise data over BLE&lt;/p&gt;
&lt;p&gt;default: // Sleep&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528422?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 13:58:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0293447c-87db-4e17-8d09-c3f980313aef</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see. There is no need to disable the SoftDevice in order to sleep, but you must call sd_app_evt_wait() in you rmain loop.&amp;nbsp;However, I see that you only call your sleep() function when&amp;nbsp;BLE::isAdvertiseDone(). This looks like a mistake. You should &lt;em&gt;always&lt;/em&gt; call&amp;nbsp;sd_app_evt_wait() from you rmain loop.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528417?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 13:47:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f012bf4-0f14-452e-a912-2a407f9cc79b</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;I do tests like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;- Make some changes in code.&lt;/p&gt;
&lt;p&gt;- Flash new code to the device via J-Link&lt;/p&gt;
&lt;p&gt;- Unplug the device from J-Link&lt;/p&gt;
&lt;p&gt;- Connect the device to PPK2 (set to 3V)&lt;/p&gt;
&lt;p&gt;- Turn on PPK2 power supply&lt;/p&gt;
&lt;p&gt;- Measure power consumption with 100kHz&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When advertise function is called, sleep does not work and device uses ~3.5mA. If advertise function is not called(but BLE::init is called before while(1)) then sleep works and power consumption is around 170uA(ignore that high number, pressure sensor and I2C bus is not implemented yet).&lt;br /&gt;&lt;br /&gt;I did not try to disable Softdevice before going to sleep. I&amp;#39;ll try that since it seems like it&amp;#39;s the only option for sleep&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528414?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 13:43:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a80dd62-ba7a-455e-90db-257a9f04da3b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do not see anyting problematic with the advertising related code. However, I did not understand the explanation about how the device does not seem to be sleeping as you can connect to it via SWD. Can you explain what you mean by the device not sleeping? And how you have tested and verified? Have you checked the current consumptoin or do you test in some other way?&lt;/p&gt;
&lt;p&gt;(If testing current consumption, note that an active debug session will cause a high current consumption due to clocks and reculators being kept on, so you sould check without debugging).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528413?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 13:35:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a00a3653-de97-4a80-b3bc-a4f5b3751ef7</guid><dc:creator>silvio3105</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;BLE functions are added to main post.&lt;br /&gt;&lt;br /&gt;Seems like device does not go to sleep since I can connect to it via SWD(J-Link). I guess some BLE event prevents sleep.&lt;br /&gt;I tried __WFI just for test otherwise SD sleep function is used.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sleep does not work with BLE advertise</title><link>https://devzone.nordicsemi.com/thread/528404?ContentTypeID=1</link><pubDate>Fri, 21 Mar 2025 12:41:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79eebad2-baa0-4a39-a6e1-4fcea6bbc884</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;When using a SoftDevice you should wait by calling&amp;nbsp;sd_app_evt_wait(), and not WFI (or WFE for that matter) directly. Advertising in itself should not cause any probem,&amp;nbsp;should not contribute to current consumption in between advertising events. Can you show the implementation of your&amp;nbsp;BLE::advertise(), as it is including that that increases the current consumption?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>