<?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>RTC1 IRQ not firing until debugger connected.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45502/rtc1-irq-not-firing-until-debugger-connected</link><description>We&amp;#39;re using an nRF52832, SDK14.0.0, SoftDevice 132 v5. 
 
 Early in our firmware lifecycle, before SoftDevice is enabled, we configure our PMIC. This involves performing some TWI transactions and then setting a single-shot app_timer with an expiry of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 29 Mar 2019 15:01:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45502/rtc1-irq-not-firing-until-debugger-connected" /><item><title>RE: RTC1 IRQ not firing until debugger connected.</title><link>https://devzone.nordicsemi.com/thread/179282?ContentTypeID=1</link><pubDate>Fri, 29 Mar 2019 15:01:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8715cb1b-5575-4db5-bdfb-999b2add8811</guid><dc:creator>charles</dc:creator><description>&lt;p&gt;Continuing the conversation over in&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/45512/guarantee-that-softdevice-won-t-wake-the-cpu-up"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/45512/guarantee-that-softdevice-won-t-wake-the-cpu-up&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;for anyone following along.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC1 IRQ not firing until debugger connected.</title><link>https://devzone.nordicsemi.com/thread/179267?ContentTypeID=1</link><pubDate>Fri, 29 Mar 2019 14:22:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e59e8219-eae3-40b6-bcc2-a2360a519bbd</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Charles,&lt;/p&gt;
&lt;p&gt;Yes, the startup flow sounds good to me. I&amp;nbsp;can&amp;#39;t think of any drawbacks by enabling the Softdevice&amp;nbsp;earlier on startup.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC1 IRQ not firing until debugger connected.</title><link>https://devzone.nordicsemi.com/thread/179255?ContentTypeID=1</link><pubDate>Fri, 29 Mar 2019 13:41:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a35e0565-7c0d-42e2-bbfa-d3fab0dfb6de</guid><dc:creator>charles</dc:creator><description>&lt;p&gt;Thanks for the quick response, Vidar.&lt;/p&gt;
&lt;p&gt;I ended up changing our code to enable (but not yet use) SoftDevice before we do anything else, and we no longer explicitly initialize the lfclk via the nrf_drv_clock module.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;At this point, the only things we do before enabling SoftDevice are:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Read RESETREAS and save it&lt;/p&gt;
&lt;p&gt;Protect our CPU (BPROT, APPROTECT, MPU)&lt;/p&gt;
&lt;p&gt;Initialize SEGGER RTT and our log buffers&lt;/p&gt;
&lt;p&gt;Load and start the hardware watchdog (since we don&amp;#39;t know what nrf_sdh_enable_request actually does)&lt;/p&gt;
&lt;p&gt;Enable SoftDevice&lt;/p&gt;
&lt;p&gt;Initialize app_timer and gpiote&lt;/p&gt;
&lt;p&gt;Start our software watchdog timer&lt;/p&gt;
&lt;p&gt;Start talking to peripherals via SPI/TWI and boot the system.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is this a reasonable startup flow? The RTC1 interrupts now fire as expected, and we don&amp;#39;t have a lot of time right now so I&amp;#39;d prefer to not investigate what was wrong with the previous effort if this new approach is better anyway &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Charles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC1 IRQ not firing until debugger connected.</title><link>https://devzone.nordicsemi.com/thread/179250?ContentTypeID=1</link><pubDate>Fri, 29 Mar 2019 13:24:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22ec2c35-e3ac-4f64-825f-a12ed3982765</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="nicholsonc"]Update, enabling SoftDevice before we start using app_timer seems to fix the issue. I got an answer recently about app_timer and SoftDevice here, so I guess the answer must be something about how we&amp;#39;re sleeping the CPU?[/quote]
&lt;p&gt;The Softdevice starts the low-frequency&amp;nbsp;clock source (crystal or RC oscillator depending on configuration). As a test, could you try to start the LF clock manually at the beginning of main to see if it has the same effect as enabling the Softdevice early, or are you doing this already?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Code to start LF clock:&lt;/p&gt;
&lt;p&gt;NRF_CLOCK-&amp;gt;LFCLKSRC = 1; // Set clock source to external 32KHz crystal. Change to 0 to use internal RC. &lt;br /&gt;NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART = 1;&lt;br /&gt;while (NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0);&amp;nbsp;&lt;/p&gt;
[quote user="nicholsonc"]When a Nordic rep looks at this, could you also explain in precise detail what sd_app_evt_wait does? Maybe post the code? (I wonder if we&amp;#39;re sleeping incorrectly, this is the only time we sleep the chip before SoftDevice is enabled.[/quote]
&lt;p&gt;Calling sd_app_evt_wait is similar to calling the __WFE instruction from the app. The main difference is that sd_app_evt_wait does not return on internal Sofdevice events, only application events.&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><item><title>RE: RTC1 IRQ not firing until debugger connected.</title><link>https://devzone.nordicsemi.com/thread/179055?ContentTypeID=1</link><pubDate>Thu, 28 Mar 2019 17:56:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4f8a495-d9b1-43b9-81a8-ac6c199d291e</guid><dc:creator>charles</dc:creator><description>&lt;p&gt;Update, enabling SoftDevice before we start using app_timer seems to fix the issue. I got an answer recently about app_timer and SoftDevice here, so I guess the answer must be something about how we&amp;#39;re sleeping the CPU?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/45266/ok-to-use-app_timer-before-nrf_sdh_enable_request"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/45266/ok-to-use-app_timer-before-nrf_sdh_enable_request&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC1 IRQ not firing until debugger connected.</title><link>https://devzone.nordicsemi.com/thread/179019?ContentTypeID=1</link><pubDate>Thu, 28 Mar 2019 15:52:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:549f6e5d-9bf9-478e-b6da-ba642cbfc91a</guid><dc:creator>charles</dc:creator><description>&lt;p&gt;Note also that if we delete the call to sleep_cpu() and just spin hard at 100% CPU duty cycle, this problem vanishes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC1 IRQ not firing until debugger connected.</title><link>https://devzone.nordicsemi.com/thread/179013?ContentTypeID=1</link><pubDate>Thu, 28 Mar 2019 15:42:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c03a8b4b-d949-432e-82be-2d35632d9b52</guid><dc:creator>charles</dc:creator><description>&lt;p&gt;Whoops, sorry, I see&amp;nbsp;in nrf_soc.h that sd_app_evt_wait looks like it&amp;#39;s hidden behind a service call, so I don&amp;#39;t know what it does when SoftDevice is enabled.&lt;/p&gt;
&lt;p&gt;When a Nordic rep looks at this, could you also explain in precise detail what sd_app_evt_wait does? Maybe post the code? (I wonder if we&amp;#39;re sleeping incorrectly, this is the only time we sleep the chip before SoftDevice is enabled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>