<?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>SW runs slower without Debugger</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105798/sw-runs-slower-without-debugger</link><description>Another weird one. 
 
 I&amp;#39;m running the example beacon code, when I start it from debugger it runs happily, it advertises, I see the 1ms systick consistently. 
 
 
 But when I detach debugging session with red button execution stops! (it should continue</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Nov 2023 13:58:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105798/sw-runs-slower-without-debugger" /><item><title>RE: SW runs slower without Debugger</title><link>https://devzone.nordicsemi.com/thread/456440?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2023 13:58:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:088c0e06-9725-4e84-9c1a-add6e9681423</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;You can use the&amp;nbsp;&lt;a title="CRITICAL_REGION_ENTER" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__app__util__platform.html?cp=9_1_6_10_61_3#ga61149a977f6ebdaeb8bdeed626dd9392"&gt;CRITICAL_REGION_ENTER&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a title="CRITICAL_REGION_EXIT" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__app__util__platform.html?cp=9_1_6_10_61_4#ga854878240b628e978f760f75aca4e1cc"&gt;CRITICAL_REGION_EXIT&lt;/a&gt;&amp;nbsp;macros for this. If you use critical sections, it is recommended to apply this change recommended in the Softdevice release notes:&amp;nbsp;&lt;/p&gt;
&lt;p&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/pastedimage1700488678625v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SW runs slower without Debugger</title><link>https://devzone.nordicsemi.com/thread/456437?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2023 13:47:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff223861-1683-4ba6-aaef-b3930bc9ccf4</guid><dc:creator>pungent1188</dc:creator><description>&lt;p class=""&gt;What shall I use instead of NVIC_DisableIRQ / NVIC_EnableIRQ when SD is enabled?&lt;/p&gt;
&lt;p class=""&gt;S112_SDS_v3.1 doesn&amp;#39;t say explicitly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SW runs slower without Debugger</title><link>https://devzone.nordicsemi.com/thread/456383?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2023 12:08:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72ced034-a30b-436f-b272-931997c492d1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for confirming. Yes, it&amp;#39;s not necessary continuously poll SD events. The app will poll events from the softdevice after receiving the Softdevice interrupt in the&amp;nbsp;&lt;a title="SoftDevice Handler library" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_softdevice_handler.html?cp=9_1_3_48"&gt;SoftDevice Handler library&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
[quote userid="129638" url="~/f/nordic-q-a/105798/sw-runs-slower-without-debugger/456369"]What if I need to disable interrupt for some time in critical section? Will BLE tolerate missed events?[/quote]
&lt;p&gt;You can not disable interrupts globally as this will break the real time requirements of the stack.&amp;nbsp;You can safely mask application level interrupts, but not Softdevice interrupts.&lt;/p&gt;
[quote userid="129638" url="~/f/nordic-q-a/105798/sw-runs-slower-without-debugger/456369"]Although it&amp;#39;s weird that basic beacon example has power saving, since power saving is not an easy topic and usually comes after main functionality works in the project.[/quote]
&lt;p&gt;It&amp;#39;s designed to be easy on this chip. Most of the power management is automatically handled in hardware, and&amp;nbsp;usually it is sufficient to just call nrf_pwr_mgmt_run() from the main loop.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SW runs slower without Debugger</title><link>https://devzone.nordicsemi.com/thread/456369?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2023 11:26:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53e57e34-c926-440d-b8a8-36068c744e1d</guid><dc:creator>pungent1188</dc:creator><description>&lt;p class=""&gt;Thank you that worked.&lt;/p&gt;
&lt;p class=""&gt;Does that mean BLE stack does not need high frequency polling from while(1) loop, and all communication is interrupt based?&lt;/p&gt;
&lt;p class=""&gt;What if I need to disable interrupt for some time in critical section? Will BLE tolerate missed events?&lt;/p&gt;
&lt;p class=""&gt;&lt;br /&gt;&lt;br /&gt;Although it&amp;#39;s weird that basic beacon example has power saving, since power saving is not an easy topic and usually comes after main functionality works in the project.&lt;br /&gt;&lt;br /&gt;And there is no comment near nrf_pwr_mgmt_run saying it goes to sleep.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SW runs slower without Debugger</title><link>https://devzone.nordicsemi.com/thread/456365?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2023 10:58:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1bc2c4f-64a0-4eb8-a35b-13601f454bb7</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The program enters sleep&amp;nbsp;&lt;span&gt;(&lt;/span&gt;&lt;a title="System ON mode" href="https://infocenter.nordicsemi.com/topic/ps_nrf52805/power.html?cp=5_6_0_4_2_2#unique_508929526"&gt;System ON mode&lt;/a&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;between events when idle_state_handle()-&amp;gt;nrf_pwr_mgmt_run() is called from the main loop.&amp;nbsp;And the Systick timer will be paused when the system is in sleep mode, unless the chip is&amp;nbsp;in debug interface mode.&lt;/p&gt;
&lt;p&gt;You can confirm this by commenting the&amp;nbsp;nrf_pwr_mgmt_run() function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SW runs slower without Debugger</title><link>https://devzone.nordicsemi.com/thread/456362?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2023 10:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af9cf31a-9c8b-4cc8-9784-3b24f301f025</guid><dc:creator>pungent1188</dc:creator><description>&lt;p&gt;Thank you for your reply,&lt;/p&gt;
&lt;p class=""&gt;I was able to reproduce it using the example code, attaching here, could you try it?&lt;/p&gt;
&lt;p class=""&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/beacon_5F00_wrong_5F00_systick.zip"&gt;devzone.nordicsemi.com/.../beacon_5F00_wrong_5F00_systick.zip&lt;/a&gt;&lt;/p&gt;
&lt;p class=""&gt;&lt;/p&gt;
&lt;p class=""&gt;Systick does work, only 315x slower without debugger. There is no low power used as far as I can tell.&lt;/p&gt;
&lt;p&gt;To be run on nrf52 board with s112 softdevice. It&amp;#39;s configured as NRF52810.&lt;/p&gt;
&lt;p class=""&gt;Please scope on pin19.&lt;/p&gt;
&lt;p class=""&gt;&lt;/p&gt;
&lt;p class=""&gt;Last init command is: sd_ble_gap_adv_start&lt;/p&gt;
&lt;p class=""&gt;Then in the infinite loop nrf_pwr_mgmt_run();&lt;/p&gt;
&lt;p class=""&gt;&lt;/p&gt;
&lt;p class=""&gt;Also why program stops when I detach with Jlink, it&amp;#39;s unusual.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SW runs slower without Debugger</title><link>https://devzone.nordicsemi.com/thread/456192?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2023 14:19:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cde521c7-7ee2-448f-9ca7-784cdc74f9a8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The ARM cortex systick timer is only running when the CPU is active or when the chip is debug interface. If you need a low power systick source, we recommend using the RTC tick event:&amp;nbsp;&lt;a title="TICK event" href="https://infocenter.nordicsemi.com/topic/ps_nrf52805/rtc.html?cp=5_6_0_5_12_4#concept_g53_fh4_sr"&gt;TICK event&lt;/a&gt;&lt;/p&gt;
&lt;p&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/pastedimage1700230705449v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a title="CPU" href="https://infocenter.nordicsemi.com/topic/ps_nrf52805/cpu.html?cp=5_6_0_3_0"&gt;CPU&lt;/a&gt;&lt;/p&gt;
[quote user=""]no WFI in mainloop[/quote]
&lt;p&gt;Is there anything else called from the main loop that may cause the chip to enter sleep (&lt;a title="System ON mode" href="https://infocenter.nordicsemi.com/topic/ps_nrf52805/power.html?cp=5_6_0_4_2_2#unique_508929526"&gt;System ON mode&lt;/a&gt;)?&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>