<?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>Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112615/crash-in-sd_clock_hfclk_is_running-on-soft-device-s140-7-3-0</link><description>Hi, I recently noticed crashing in sd_clock_hfclk_is_running() on a nrf52840 using SoftDevice S140 7.3.0. This is the callstack: 
 
 
 ??@0x00000ac4 (Unknown Source:0) 
 &amp;lt;signal handler called&amp;gt;@0xffffffe9 (Unknown Source:0) 
 sd_clock_hfclk_is_running</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 14 May 2025 11:37:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112615/crash-in-sd_clock_hfclk_is_running-on-soft-device-s140-7-3-0" /><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/535308?ContentTypeID=1</link><pubDate>Wed, 14 May 2025 11:37:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b345d96-8fdf-4516-ac4b-6433fb118b8b</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;Interesting theory, but my APP_USBD_CONFIG_EVENT_QUEUE_ENABLE is not explicitly defined, but set to 1 in config/nrf52840/config/sdk_config.h and NRFX_USBD_CONFIG_IRQ_PRIORITY is set to 6&lt;/p&gt;
&lt;p&gt;The full set of defines I make explicitly regarding USB are:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_ENABLED&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_CONFIG_SELF_POWERED&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_CONFIG_SOF_HANDLING_MODE&lt;/span&gt;&lt;span&gt; APP_USBD_SOF_HANDLING_INTERRUPT&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_CONFIG_POWER_EVENTS_PROCESS&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_HID_ENABLED&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_HID_GENERIC_ENABLED&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_STRING_SERIAL&lt;/span&gt;&lt;span&gt; globalSerialNumber&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_STRING_SERIAL_EXTERN&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_STRINGS_MANUFACTURER&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_STRINGS_MANUFACTURER&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_STRINGS_MANUFACTURER_EXTERN&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_STRINGS_PRODUCT&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_STRINGS_PRODUCT&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_STRINGS_PRODUCT_EXTERN&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;NRFX_USBD_ENABLED&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;APP_USBD_CDC_ACM_ENABLED&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The rest are from&amp;nbsp;config/nrf52840/config/sdk_config.h&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/535305?ContentTypeID=1</link><pubDate>Wed, 14 May 2025 11:08:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99e73d8c-c5ea-48bf-871d-b377aad52503</guid><dc:creator>Niziak</dc:creator><description>&lt;p&gt;Looks like generic case where USB handlers works from USB IRQ (APP_USBD_CONFIG_EVENT_QUEUE_ENABLE is 0) and USB IRQ is higher (&amp;lt;4) than SoftDevice&amp;#39;s SVC IRQ (==4).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/499865?ContentTypeID=1</link><pubDate>Tue, 27 Aug 2024 02:13:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94eb232d-0ac7-4a95-ad18-4d588ac2a726</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;My linker file is set up like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;MEMORY&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x7d000&lt;br /&gt;&amp;nbsp; RAM (rwx) : ORIGIN = 0x20008000, LENGTH = 0x38000&lt;br /&gt;&amp;nbsp; CODE_RAM (rx) : ORIGIN = 0x808000, LENGTH = 0x38000&lt;br /&gt;}&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;And this was based on the notes in&amp;nbsp;s140_nrf52_7.2.0_release-notes-update-1.pdf.&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/Screenshot-2024_2D00_08_2D00_27-at-10.10.28_2F20_AM.png" /&gt;&lt;/p&gt;
&lt;p&gt;The callstack clearly had `&lt;span&gt;sd_clock_hfclk_is_running` in it, which looks like it&amp;#39;s going into the SVC.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Is &lt;span&gt;0x25ed8&lt;/span&gt; not in the soft device memory space?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;gt; it is optional to use two different stacks for interrupts and &amp;quot;main mode&amp;quot;, so I&amp;#39;m not sure what your application does.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What flag/code would help identify whether two different stacks are being used?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/499736?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2024 11:58:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3d6bd02-d33d-4dbd-8c9f-d06ead56e62b</guid><dc:creator>Martin Tverdal</dc:creator><description>&lt;p&gt;Thanks for sharing latest stack frame, Im not able to see anything interesting from it, other than that now the fault seems to happen somewhere in&amp;nbsp; your application&amp;nbsp;(beaus&amp;nbsp;0x25ed8 is higher than the highest address in s140).&amp;nbsp; or is&amp;nbsp;0x25ed8 just an adress in your hardfault-handler maybe?&lt;/p&gt;
&lt;p&gt;Since it happens on many different boards, and also on pretty fresh boards then I think we can rule out flash-wearing too.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Coretex has concept of two differint stacks, msp and psp. one for &amp;quot;main mode&amp;quot; (also called &amp;quot;thread mode), that cpu is using when it is not handling interrupts, and another callsstack it uses for interrupts. it is optional to use two different stacks for interrupts and &amp;quot;main mode&amp;quot;, so I&amp;#39;m not sure what your application does.&lt;/p&gt;
&lt;p&gt;But all of the code in Softdevice anyway runs in interrupt mode, since all the calls to Softdevice is implemented as SVC interrupts.&amp;nbsp; And since there is only one callstack for all interrupts, Softdevice and application end up sharing the same callstack.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/499653?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2024 01:28:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e683fff7-9b8c-451c-8032-78a9b37aeba8</guid><dc:creator>jthlim</dc:creator><description>&lt;blockquote&gt;
&lt;div&gt;&lt;span&gt;Another explanation might be corruption of callstack somehow, maybe you can try increasing the interrupt callstack a bit and see &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; problem goes away?&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Just to make sure I&amp;#39;m not mis-understanding it - is the stack here shared with user and interrupts? Or is interrupts separate?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I use an 8kb stack size on the nrf52840, and the code (minus nrf5 specific stuff) runs on a 2kb stack on another mcu.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/499652?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2024 01:21:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d21ef4f4-e2d0-4188-8549-ee8cda3f87b1</guid><dc:creator>jthlim</dc:creator><description>&lt;blockquote&gt;
&lt;div&gt;&lt;span&gt;One possible explanation is corruption of the instruction in FLASH itself, does this happen easily &lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; you on many different boards?&amp;nbsp;&lt;/span&gt;&lt;span&gt;If you have only reproduced it on only one board, is it possible that you have exhausted the number flash erase cycles nrf52840 supports.&amp;nbsp;&lt;/span&gt;&lt;span&gt;From top of my head I think&amp;nbsp;that is&amp;nbsp;&lt;/span&gt;&lt;span&gt;10&amp;#39;000.&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;To answer this question - this happens on every board I&amp;#39;ve tested on, some with single digit erase cycles&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/499634?ContentTypeID=1</link><pubDate>Sat, 24 Aug 2024 07:41:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a801ae3d-fd3a-40b8-a6b1-061362140c4e</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;I tried this again today, and the `&lt;span&gt;NRF_CLOCK&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;EVENTS_HFCLKSTARTED == 0` works, but testing with the old&amp;nbsp;sd_clock_hfclk_request() approach again gave me a different callstack:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The call hung, and stopping execution landed on 0x25ed8:&lt;/span&gt;&lt;/p&gt;
&lt;div id="list_id_9_89" class="monaco-list-row" data-index="89" data-last-element="false" data-parity="odd"&gt;
&lt;div class="monaco-tl-row"&gt;
&lt;div class="monaco-tl-contents output"&gt;
&lt;blockquote&gt;
&lt;div class="output expression value-and-source"&gt;&lt;span class="value warn"&gt;&lt;span&gt;&lt;span class=""&gt; 0x00025ed2: mrs r1, MSP &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;div class="source"&gt;0x00025ed6: ldr r0, [r1, #24]&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;blockquote&gt;
&lt;div id="list_id_9_90" class="monaco-list-row" data-index="90" data-last-element="false" data-parity="even"&gt;
&lt;div class="monaco-tl-row"&gt;
&lt;div class="monaco-tl-contents output"&gt;
&lt;div class="output expression value-and-source"&gt;
&lt;div class="source"&gt;&lt;strong&gt;0x00025ed8: subs r0, #2&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id="list_id_9_91" class="monaco-list-row" data-index="91" data-last-element="false" data-parity="odd"&gt;
&lt;div class="monaco-tl-row"&gt;
&lt;div class="monaco-tl-contents output"&gt;
&lt;div class="output expression value-and-source"&gt;
&lt;div class="source"&gt;0x00025eda: ldrb r0, [r0, #0]&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id="list_id_9_92" class="monaco-list-row" data-index="92" data-last-element="false" data-parity="even"&gt;
&lt;div class="monaco-tl-row"&gt;
&lt;div class="monaco-tl-contents output"&gt;
&lt;div class="output expression value-and-source"&gt;
&lt;div class="source"&gt;0x00025edc: cmp r0, #16&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div id="list_id_9_93" class="monaco-list-row" data-index="93" data-last-element="false" data-parity="odd"&gt;
&lt;div class="monaco-tl-row"&gt;
&lt;div class="monaco-tl-contents output"&gt;
&lt;div class="output expression value-and-source"&gt;
&lt;blockquote&gt;
&lt;div class="source"&gt;0x00025ede: blt.n 0x25f08&lt;/div&gt;
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id="list_id_9_94" class="monaco-list-row" data-index="94" data-last-element="false" data-parity="even"&gt;
&lt;div class="monaco-tl-row"&gt;
&lt;div class="monaco-tl-contents output"&gt;
&lt;div class="output expression value-and-source"&gt;
&lt;div&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/Screenshot-2024_2D00_08_2D00_24-at-3.40.27_2F20_PM.png" alt=" " /&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Sharing this in case it helps at all.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/499569?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2024 12:53:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48403a10-f433-4098-a2e9-816f2a27bb00</guid><dc:creator>Martin Tverdal</dc:creator><description>&lt;p&gt;yes, good point pan-201 should not be a concern for you then!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/499560?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2024 12:31:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9488aa76-b445-416a-bc7a-0f5e58808595</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;Thanks so much for such a detailed reply.&lt;/p&gt;
&lt;p&gt;I should clarify -- the device enters a non-responsive state, and loses BLE connections, but doesn&amp;#39;t trigger the debugger automatically. If I pause execution, I get that call stack.&lt;/p&gt;
&lt;p&gt;Regarding pan-201 -- I see that it&amp;#39;s listed in rev1, but not rev2 of the nrf52840. Is it safe to assume pan-201 is not an issue since I&amp;#39;m running on rev2?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/499514?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2024 10:36:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c5f585d-6db7-47aa-b63e-97091f73f983</guid><dc:creator>Martin Tverdal</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve been looking into this a bit and I&amp;#39;m not sure what the root cause&amp;nbsp;&lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; the crash you see can be.&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;You seem to be hitting a hardfault/busfault at instruction at &lt;/span&gt;&lt;span&gt;0xac4&lt;/span&gt;&lt;span&gt;, that is an instruction inside&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;the SVC handler in the MBR, master boot record. The function you are calling in the softdevice sd_clock_hfclk_is_running,&amp;nbsp;&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;is implemented as a SVC intrrupt, and the MBR simply forwards it to the Softdevice, and judging by your stack-frame you posted,&amp;nbsp;&lt;/span&gt;&lt;span&gt;when the crash happens, it seems like the it hasn&amp;#39;t even reached the Softdevice, it crashes&amp;nbsp;inside the MBR, in the code that simply forwards interrupts (including SVC interrupts) to Softdevice.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;One possible explanation is corruption of the instruction in FLASH itself, does this happen easily &lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; you on many different boards?&amp;nbsp;&lt;/span&gt;&lt;span&gt;If you have only reproduced it on only one board, is it possible that you have exhausted the number flash erase cycles nrf52840 supports.&amp;nbsp;&lt;/span&gt;&lt;span&gt;From top of my head I think&amp;nbsp;that is&amp;nbsp;&lt;/span&gt;&lt;span&gt;10&amp;#39;000.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;Another explanation might be corruption of callstack somehow, maybe you can try increasing the interrupt callstack a bit and see &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; problem goes away?&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;span&gt;Reading &lt;/span&gt;&lt;span&gt;NRF_CLOCK&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;HFCLKSTAT&lt;/span&gt;&lt;span&gt; like you have found to work sounds safe to me, meaning Softdevice doesn&amp;#39;t protect NRF_CLOCK peripheral from being read.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;So you busy-waiting &lt;/span&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; that to change to &lt;/span&gt;&lt;span&gt;0x10001&lt;/span&gt;&lt;span&gt; sounds safe in that &lt;/span&gt;&lt;span&gt;regards&lt;/span&gt;&lt;span&gt;. &lt;/span&gt;&lt;span&gt;However&lt;/span&gt;&lt;span&gt;, because of &amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Ferrata_nRF52840_Rev1%2FERR%2FnRF52840%2FRev1%2Flatest%2Fanomaly_840_201.html&amp;amp;cp=5_0_1_3_1_32"&gt;pan-201&lt;/a&gt;&lt;/span&gt;&lt;span&gt;, you might want to &lt;/span&gt;&lt;span&gt;switch&lt;/span&gt;&lt;span&gt;&lt;span&gt; to NRF_CLOCK-&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;EVENTS_HFCLKSTARTED&amp;nbsp;&lt;/span&gt;instead.&lt;/div&gt;
&lt;div&gt;&lt;span&gt;That is what the Softdevice will read &lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; you call sd_clock_hfclk_is_running.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;So in this sense, I think switching to while (&lt;/span&gt;&lt;/span&gt;&lt;span&gt;NRF_CLOCK&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;EVENTS_HFCLKSTARTED == 0) is a good solution. However, even if that works, I still have a feeling there is something wrong that might fail in a different way somewhere else.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;Best regards,&lt;/div&gt;
&lt;div&gt;Martin Tverdal&lt;/div&gt;
&lt;div&gt;Softdevice team.&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/497872?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2024 16:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14a49607-11d6-4975-a422-00836018c22a</guid><dc:creator>jthlim</dc:creator><description>&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/Screenshot-2024_2D00_08_2D00_13-at-12.24.42_2F20_AM.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The value seems right -- `00 10 00 00` bytes at the address. Note that another reason I don&amp;#39;t think it&amp;#39;s the interrupt disabled issue is that when I replace the&amp;nbsp;&lt;span&gt;sd_clock_hfclk_is_running with my manual register lookup, it all works, despite there being a&amp;nbsp;&lt;/span&gt;sd_clock_hfclk_release call later, which should also crash according to that&amp;nbsp;theory.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/497727?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2024 06:56:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:223cf097-c52c-49ee-abec-ea95a0cacfbf</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;I was informed by our experts about another suspicion after looking more closely at your callstack contents, &lt;br /&gt;??@0x00000ac4 (Unknown Source:0)&lt;br /&gt; &lt;br /&gt;That line there on top of your callstack makes us suspect that the content of address 0x20000000 (so the first address in RAM), has been corrupted somehow. &lt;br /&gt;Please&amp;nbsp;check that before you call sd_clock_hfclk_is_running().&lt;br /&gt;The content should, in your case, always be 00001000. it is that address at which the MBR stores where to forward interrupts and 0x1000 will make MBR forward interrupts to Softdevice.&lt;br /&gt; &lt;br /&gt;You&amp;nbsp;can check this, for example, by adding the following code before the call to sd_clock_hfclk_is_running that fails, and see if you get stuck there, and tell us what the value at 0x20000000 is if it hangs there:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; if(*((uint32_t*)0x20000000)!=0x1000)&lt;br /&gt; {&lt;br /&gt; while(1);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Or maybe you can just connect with debugger and see what content is at 0x20000000 when the program has crashed.&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/497678?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2024 18:32:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff2abe03-fb66-4829-ac5c-bb328d171850</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;So is there any condition under which&amp;nbsp;&lt;span&gt;sd_clock_hfclk_request() or the nrf5 sdk disables irqs? I don&amp;#39;t have a single disable_irq in my entire codebase.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/497577?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2024 08:28:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9da56921-6e42-43e1-9892-a13e2283b1e5</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Yes, that is true, unless this code gets interrupted by another interrupt, and that interupt disables irqs for example, and then return.&lt;br /&gt;To demonstrate, you can see this simple program.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;void SVC_Handler(void)&lt;/em&gt;&lt;br /&gt;&lt;em&gt;{ &lt;/em&gt;&lt;br /&gt;&lt;em&gt; __disable_irq();&lt;/em&gt;&lt;br /&gt;&lt;em&gt;}&lt;/em&gt;&lt;br /&gt; &lt;br /&gt;&lt;em&gt;void __svc( 10 ) dummy( void ) ;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;int main(void)&lt;/em&gt;&lt;br /&gt;&lt;em&gt;{&lt;/em&gt;&lt;br /&gt;&lt;em&gt; dummy();&lt;/em&gt;&lt;br /&gt;&lt;em&gt; __nop();&lt;/em&gt;&lt;br /&gt;&lt;em&gt; __nop();&lt;/em&gt;&lt;br /&gt;&lt;em&gt; __nop();&lt;/em&gt;&lt;br /&gt;&lt;em&gt; __nop();&lt;/em&gt;&lt;br /&gt;&lt;em&gt; dummy();&lt;/em&gt;&lt;br /&gt;&lt;em&gt; while(1)&lt;/em&gt;&lt;br /&gt;&lt;em&gt; {&lt;/em&gt;&lt;br /&gt;&lt;em&gt; }&lt;/em&gt;&lt;br /&gt;&lt;em&gt;}&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;It will hardfault on the second call to dummy(), because the first time the SVC handler ran, it disabled interrupts and then returned.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/497567?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2024 08:08:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d13a2c74-c90f-440b-af44-69e9de3f4b65</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;The flow of the program is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;sd_clock_hfclk_request();&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;do { &lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; sd_clock_hfclk_is_running(...);&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;} while (...);&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div&gt;&lt;span&gt;If any SVC interrupt causes a hard fault when called in an interrupt, would it not crash when calling sd_clock_hfclk_request first?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/497435?ContentTypeID=1</link><pubDate>Thu, 08 Aug 2024 07:51:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a7d9a95-70c9-4f39-9267-cb25ccabde3a</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We still feel that&amp;nbsp;there might be&amp;nbsp;some mess-up with svc and interrupt configuration. Maybe&amp;nbsp;you end up at this point, calling sd_clock_hfclk_is_running while&amp;nbsp;you have&amp;nbsp;disabled interrupts then?&lt;br /&gt; &lt;br /&gt;The call to all sd_ functions is just implemented as triggering svc interrupts, and when we tried on purpose to do that in a simple program like this, it does hardfault.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/496933?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2024 09:55:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c5bb11f-88b2-4fa1-b8ec-75111a8d928b</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;&lt;span&gt;`sd_clock_hfclk_is_running` is defined as such in the disassembly at that address:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;svc 68 @ 0x44&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;bx lr&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The address is just a stub into the soft device.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t believe it is ever being called from an interrupt handler (I&amp;#39;m pretty sure it&amp;#39;s not, other things would be very problematic in the code path). There is a call right above it which succeeds to the softdevice too: &lt;span&gt;sd_clock_hfclk_request()&lt;/span&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/496917?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2024 08:35:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41d7c027-7225-4752-90a5-0c039d8af931</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;From the callstack, it looks like the crash has happened in application and not inside sd_clock_hfclk_is_running, since the address is 0x000276ae, which is outside Softdevice..&lt;br /&gt; &lt;br /&gt;One possibility is that you&amp;nbsp;end up calling sd_clock_hfclk_is_running from an interrupt handler that has higher (or equal) priority than SVC priority, that is not allowed by design. If you call any SD function from a interrupt handler like that, it will hardfault.&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/496861?ContentTypeID=1</link><pubDate>Fri, 02 Aug 2024 17:49:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1065259-3ff8-4e7b-804d-6291cfe0b354</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;I am yet to hear from them. I will check your suggestion too in the meantime.&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/496705?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 18:42:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43dd2a5d-2188-4067-93f7-6bbce11360ee</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;Is there any other way to avoid the errata other than turning on the hfclk? it&amp;#39;d be nice to avoid the power draw that is associated with this workaround.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/495856?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 19:11:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8a3615d-94b7-4a18-8022-b015c1d8f2a9</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;Thanks for the update, looking forward to hearing more!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/495529?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2024 05:52:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6b74661-e075-4e0b-b891-3922ecc77211</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Apologies for the delay. De to the summer holidays we are understaffed at the moment. I have consulted your issue internally with experts, but please expect a slight delay. I will get back to you as soon as I hear form them.&lt;/p&gt;
&lt;p&gt;Thank you for your patience.&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/494879?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2024 17:37:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f19a93fc-ef84-4941-b964-abda09d00db3</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;Can you give an example of how my code to check HFCLK won&amp;#39;t function properly? Before, you said the code was correct, now you&amp;#39;re saying it may not function properly.&lt;/p&gt;
&lt;p&gt;I would like to use the SoftDevice API, but it crashes. So that isn&amp;#39;t an option, unless you can advise why it&amp;#39;s crashing, and how this can be avoided.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/494819?ContentTypeID=1</link><pubDate>Fri, 19 Jul 2024 13:06:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9297f9cd-b0f9-4693-b68c-7818ca4eb941</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It&amp;#39;s true that the function &lt;em&gt;sd_clock_hfclk_is_running&lt;/em&gt; does not change any state, but it simply checks the state of the HFCLK. So let&amp;#39;s take a scenario where your HFCLK does not function properly, and&amp;nbsp;this function is also not called, and then it can affect your program. Moreover, if you are not using this function,&amp;nbsp;then you are using direct register checks, and&amp;nbsp;if your HFCLK state is misinterpreted, this can lead to BLE radio issues. So it&amp;#39;s always recommended to use the provided SoftDevice API functions to ensure proper operation.&lt;/p&gt;
&lt;p&gt;Also, it does depend on your implementation, rather the way you use it in your code according to your needs, can vary depending on your implementation.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Crash in sd_clock_hfclk_is_running on Soft Device S140, 7.3.0</title><link>https://devzone.nordicsemi.com/thread/493416?ContentTypeID=1</link><pubDate>Thu, 11 Jul 2024 12:26:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:935387ab-eec6-41af-b104-c5ce60f7580c</guid><dc:creator>jthlim</dc:creator><description>&lt;p&gt;huh? That doesn&amp;#39;t make any sense.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is a query function -- asking is the hfclk running off the xtal -- not something that is meant to change any state. Can you elaborate why BLE radio may not function properly if the register is used to check if hfclk is running vs calling&amp;nbsp;&lt;span&gt;sd_clock_hfclk_is_running?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;And how does&amp;nbsp;&lt;span&gt;sd_clock_hfclk_is_running depend on my implementation? This function is provided through SVC by the softdevice.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>