<?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>Power Management blocks main loop</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93207/power-management-blocks-main-loop</link><description>Hi, 
 I am discovering the nrf52 software with the Segger Embedded Studio environment. I have developed an application derived of the ble_app_uart example. 
 I have many events that run well, but I wanted to add some tests in my main loop (detect a button</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Oct 2022 13:44:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93207/power-management-blocks-main-loop" /><item><title>RE: Power Management blocks main loop</title><link>https://devzone.nordicsemi.com/thread/392417?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 13:44:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:849cbde2-db3e-4d59-b1f7-768316bb2c7e</guid><dc:creator>ThomasDmr</dc:creator><description>&lt;p&gt;Thank you very much for these clarifications. &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Management blocks main loop</title><link>https://devzone.nordicsemi.com/thread/392381?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 12:32:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc06cd6d-b8e0-499a-a65c-98ce9c73dc5a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;No problem! &lt;/p&gt;
[quote userid="116018" url="~/f/nordic-q-a/93207/power-management-blocks-main-loop/392372"]If I understand correctly, the main loop is looped through after an interrupt is called by any of the services ?[/quote]
&lt;p&gt;Yes, your understanding is correct.&lt;/p&gt;
[quote userid="116018" url="~/f/nordic-q-a/93207/power-management-blocks-main-loop/392372"]In my case, the flags are indeed updated by bluetooth communication, so I imagine the loop is called afterwards ? (this part of the code was actually working, so this makes sense).[/quote]
&lt;p&gt;Correct. Bluetooth events are notified by the Softdevice to the application through the softdevice interrupt.&lt;/p&gt;
[quote userid="116018" url="~/f/nordic-q-a/93207/power-management-blocks-main-loop/392372"]The only part of the code that was having trouble was the last part where I try to catch GPIO input actions. I guess that I should manage the GPIO through interrupts as well ?[/quote]
&lt;p&gt;Yes, sounds like this will be the solution for you. &lt;/p&gt;
[quote userid="116018" url="~/f/nordic-q-a/93207/power-management-blocks-main-loop/392372"]Related question : what would be the consequence of not putting the device in sleep when operating ? Just a higher power consumption ?[/quote]
&lt;p&gt;Yes, the consequence is increased power consumption.&lt;/p&gt;
[quote userid="116018" url="~/f/nordic-q-a/93207/power-management-blocks-main-loop/392372"]In my case, the device is functioning for a few minutes during which the user configures the device, then, once the alarm is set, the device enters the deep sleep mode. Not using the nrf_pwr_mgmt_run() would only impact the times the board isn&amp;#39;t deep sleep right ?[/quote]
&lt;p&gt;Yes, it will not affect the device when it is in deep sleep (aka System OFF mode).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Management blocks main loop</title><link>https://devzone.nordicsemi.com/thread/392372?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 11:58:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a9bad9c-396b-4317-8291-978fb00b671f</guid><dc:creator>ThomasDmr</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;Thanks a lot for your quick reply !&lt;/p&gt;
&lt;p&gt;If I understand correctly, the main loop is looped through after an interrupt is called by any of the services ?&lt;/p&gt;
&lt;p&gt;In my case, the flags are indeed updated by bluetooth communication, so I imagine the loop is called afterwards ? (this part of the code was actually working, so this makes sense).&lt;/p&gt;
&lt;p&gt;The only part of the code that was having trouble was the last part where I try to catch GPIO input actions. I guess that I should manage the GPIO through interrupts as well ?&lt;/p&gt;
&lt;p&gt;Related question : what would be the consequence of not putting the device in sleep when operating ? Just a higher power consumption ?&lt;/p&gt;
&lt;p&gt;In my case, the device is functioning for a few minutes during which the user configures the device, then, once the alarm is set, the device enters the deep sleep mode. Not using the nrf_pwr_mgmt_run() would only impact the times the board isn&amp;#39;t deep sleep right ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks again for your precious help !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Management blocks main loop</title><link>https://devzone.nordicsemi.com/thread/392339?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2022 10:40:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d087dde6-1384-4e9c-8adf-d5027631d380</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;nrf_pwr_mgmt_run() will make the device enter sleep (i.e. &lt;span&gt;&lt;a title="System ON mode" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=4_2_0_17_2#unique_1905852297"&gt;System ON mode&lt;/a&gt;&lt;/span&gt;), and the program will not return from this function until next time the CPU is woken up by an interrupt.&lt;/p&gt;
&lt;p&gt;The program should iterate through the loop again after servicing the interrupt, even if you enter sleep with nrf_pwr_mgmt_run(). So, Are your state flags (wakeFromAlarm, etc) updated from interrupts?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>