<?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>Testing SD fault handlers</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103835/testing-sd-fault-handlers</link><description>I have fault handling code that I want to test for the soft device. How can I cause the soft device to generate a fault for NRF_FAULT_ID_SD_ASSERT, and NRF_FAULT_ID_APP_MEMACC.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Sep 2023 09:13:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103835/testing-sd-fault-handlers" /><item><title>RE: Testing SD fault handlers</title><link>https://devzone.nordicsemi.com/thread/446433?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2023 09:13:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83f81219-3f84-4dc0-b1d3-27839714970b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You can use the functions below to trigger these faults.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;nrf_delay.h&amp;quot;

// Must be called when the Softdevice is active handling protocol events. E.g. after starting advertising. 
static void trigger_sd_assert(void)
{
    /*  Trigger assert by blocking internal Softdevice interrupts. The SD will assert
     *  when it detects that its real-time requirements have not been met. 
     */ 
    __disable_irq();
    nrf_delay_ms(1000);
    __enable_irq();
}

static void trigger_sd_memacc(void)
{
    /* NRF_FAULT_ID_APP_MEMACC is raised if the application tries to access peripherals or memory (RAM) 
     * reserved to the Softdevice - https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/sd_resource_reqs/sd_resource_reqs.html 
     */
     
     // Option #1: write to the Softdevice&amp;#39;s RAM region
     *(uint32_t *) 0x20001000 = 1;
     // Option #2 Perform a write access to a SoftDevice reserved peripheral.
     NRF_TIMER0-&amp;gt;TASKS_START = 1;
}
&lt;/pre&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>