<?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>Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74131/hard-fault-handler-issue</link><description>I have app_error_handler and HardFault_Handler defined - I have the WDT enabled. My issue is if I trigger a hard fault: 
 // Enable divide by zero interrupt // SCB-&amp;gt;CCR |= 0x10; 
 int HwTest = 10; int HwDivisor = 0; int HwTrigger = HwTest / HwDivisor;</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 28 May 2023 18:50:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74131/hard-fault-handler-issue" /><item><title>RE: Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/thread/427942?ContentTypeID=1</link><pubDate>Sun, 28 May 2023 18:50:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17be115f-3158-4658-9f6b-bf421c05e39c</guid><dc:creator>GerardB</dc:creator><description>&lt;p&gt;Hi Jeffrey&amp;nbsp;&lt;br /&gt;&lt;br /&gt;As they say &amp;quot;better late than never&amp;quot;! :)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am curious to find out what/if you learnt about the how (or best way) to implement and test a fault-handler that will trigger on a divide by zero, etc..!&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Would you mind sharing what you eventually settled on (code wise)?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;Gerard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/thread/306829?ContentTypeID=1</link><pubDate>Mon, 26 Apr 2021 13:42:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0968787-5cce-4186-8af4-9304cfffc9ac</guid><dc:creator>JeffreyWedekind</dc:creator><description>&lt;p&gt;Einar:&amp;nbsp; Thanks for the quick reply;&lt;/p&gt;
&lt;p&gt;Yes dereferencing a pointer to get a memory fault - great idea.&amp;nbsp; I don&amp;#39;t know why I had a difficult time thinking of how to generate a HardFault :).&lt;/p&gt;
&lt;p&gt;I will re-read the WDT chapter, it must be something simple.&amp;nbsp; I will post any fixes so others can benefit from this ticket.&lt;/p&gt;
&lt;p&gt;Jeff&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/thread/306822?ContentTypeID=1</link><pubDate>Mon, 26 Apr 2021 13:22:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eef2ab8c-e952-4067-a1e6-632d9944b65a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Edvin is OoO so I have taken over this case.&lt;/p&gt;
&lt;p&gt;The simplest way to generate a hard fault is to dereference a pointer to some invalid memory (outside of the memory map).&lt;/p&gt;
&lt;p&gt;Regarding the WDT I have not found any issues that would prevent it from triggering in the situation you describe, as long as it is started. The only exception is if it has been configured to pause during sleep or debug halt (see &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/wdt.html?cp=4_0_0_5_35"&gt;WDT chapter in PS&lt;/a&gt;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/thread/306662?ContentTypeID=1</link><pubDate>Sun, 25 Apr 2021 23:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e46369d9-032c-4561-8259-7d2dca0a17d2</guid><dc:creator>JeffreyWedekind</dc:creator><description>&lt;p&gt;Edvin:&amp;nbsp; Sorry for the late reply, I have been busy on other bugs.&amp;nbsp; Basically I have a BLE test case that triggers a HardFault Error (divide by zero) on purpose so I can verify the HardFault handler works.&amp;nbsp; The tester stated he wasn&amp;#39;t attached to a debugger but I will re-verify that setup.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also it appears since I turned off the floating point hardware the &amp;quot;divide by zero&amp;quot; HardFault might be triggering a software error in the SoftDevice which is why it is going to 0x000008C8 instead of my handler.&amp;nbsp; I&amp;#39;m just trying to understand this IRQ routing better.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m confused why the WDT isn&amp;#39;t triggering a reset but it might be the JTAG emulator.&amp;nbsp; I will get more data.&lt;/p&gt;
&lt;p&gt;Is there another method to trigger a HardFault error?&amp;nbsp; I know you don&amp;#39;t get this question very often but the &amp;quot;Divide by zero&amp;quot; test case is very useful for testing the HardFault logic, saving key data, registers etc.&amp;nbsp; I&amp;#39;m surprised how difficult it is to actually trigger one :).&amp;nbsp; I&amp;#39;m going to keep the code snippet that triggers my next real HardFault.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/thread/305803?ContentTypeID=1</link><pubDate>Tue, 20 Apr 2021 10:47:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec5e5f9f-56bd-4772-a995-0d02b4ed9bde</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Are you in a debug session while the hardfault handler is triggered? If so, try to change the config.behavior to&amp;nbsp;NRF_WDT_BEHAVIOUR_RUN_SLEEP_HALT.&lt;/p&gt;
&lt;p&gt;If the issue is that the watchdog is not resetting when you are hitting a hardfault handler, then the hardfault handler itself will reset when you are not in a debug session. Also, with your current configuration the watchdog timer is halted in breakpoints. Try the RUN_SLEEP_HALT configuration, and see if that works. If not, please explain what sort of behavior you are looking for.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/thread/305629?ContentTypeID=1</link><pubDate>Mon, 19 Apr 2021 15:39:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8928c4aa-1c44-4f21-b338-885a80d19dac</guid><dc:creator>JeffreyWedekind</dc:creator><description>&lt;p&gt;I missed that last part of my WDT code:&lt;/p&gt;
&lt;p&gt;nrf_drv_wdt_config_t config = {0};&lt;br /&gt; &lt;br /&gt; config.behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP;&lt;br /&gt; config.interrupt_priority = WDT_CONFIG_IRQ_PRIORITY;&lt;br /&gt; config.reload_value = SOFTWARE_WATCHDOG_TIMEOUT;&lt;br /&gt; &lt;br /&gt; err_code = nrf_drv_wdt_init(&amp;amp;config, wdt_event_handler);&lt;br /&gt; ISP_STARTUP_ERROR_CHECK(err_code, ISP_STARTUP_LOG_ID_WDT_INIT);&lt;br /&gt; &lt;br /&gt; err_code = nrf_drv_wdt_channel_alloc(&amp;amp;s_wdt_channel_id);&lt;br /&gt; ISP_STARTUP_ERROR_CHECK(err_code, ISP_STARTUP_LOG_ID_WDT_CHANNEL);&lt;br /&gt; nrf_drv_wdt_enable();&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/thread/305628?ContentTypeID=1</link><pubDate>Mon, 19 Apr 2021 15:38:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb2029f0-a4dd-4a85-9017-ff0aac9ae03e</guid><dc:creator>JeffreyWedekind</dc:creator><description>&lt;p&gt;Edvin - Yes that is one of the issue.&amp;nbsp; The other issue is - are there hard faults I can&amp;#39;t catch at the app level?&amp;nbsp; I wasn&amp;#39;t able to hit any handler breakpoints for divde by zero.&lt;/p&gt;
&lt;p&gt;/** @var s_channel_id&lt;br /&gt; * @brief Watchdog Channel Id&lt;br /&gt; */&lt;br /&gt;static nrf_drv_wdt_channel_id s_wdt_channel_id = 0;&lt;/p&gt;
&lt;p&gt;/** @brief WDT events handler.&lt;br /&gt; */&lt;br /&gt;void wdt_event_handler(void)&lt;br /&gt;{&lt;br /&gt; IspSystemReset_IncrementWatchdogResets();&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hard Fault Handler Issue</title><link>https://devzone.nordicsemi.com/thread/305530?ContentTypeID=1</link><pubDate>Mon, 19 Apr 2021 12:24:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13c2b69f-5d95-48b8-903f-59b21f6d2e59</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Can you share some information on how you set up your watchdog timer?&lt;/p&gt;
&lt;p&gt;Do I understand you correctly if your question is why the watchdog timer is not kicking in and restarting the device when you are in the hardfault handler?&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>