<?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>SAADC will not start</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117812/saadc-will-not-start</link><description>Hello, 
 I am trying to use the SAADC peripheral on my nrf5340dk without using the zephyr API; I am writing my program bare-metal. My goal is to set up the ADC in continuous mode (using the internal timer) with a constant sample rate, and I want an interrupt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Jan 2025 15:27:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117812/saadc-will-not-start" /><item><title>RE: SAADC will not start</title><link>https://devzone.nordicsemi.com/thread/517761?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2025 15:27:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:725d4bd5-f369-411d-a02e-cbd71930e287</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;You can&amp;#39;t set a high priority when using Zephyr or any other OS. Change the 1 to 6 and see if that helps. There are lots of examples for interrupts in Zephyr.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Change:
  NVIC_SetPriority(SAADC_IRQn, 1);
to:
  NVIC_SetPriority(SAADC_IRQn, 6);
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC will not start</title><link>https://devzone.nordicsemi.com/thread/517758?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2025 15:18:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:999c2b42-4888-42fe-a6f7-bf706454e696</guid><dc:creator>Taylor Nelson</dc:creator><description>&lt;p&gt;Thankyou,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am still having trouble with interrupts though. I noticed that the specific line that is causing problems is&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    NVIC_EnableIRQ(SAADC_IRQn);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;whenever this line is included in my code, my board will constantly reboot itself over and over. Getting rid of this line causes the board to not reboot itself, but the interrupts are still never triggered.&lt;/p&gt;
&lt;p&gt;From what I have seen from other information online, since I am using nRF Connect for VS Code, Zephyr is automatically included in the build, and that interrupts need to be configured differently when using Zephyr.&lt;/p&gt;
&lt;p&gt;Do you have any information on how to configure the interrupts for a build with Zephyr?&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Taylor&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC will not start</title><link>https://devzone.nordicsemi.com/thread/517556?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2025 21:22:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:342b62e6-0e05-4a17-adfc-4c0711b2be4d</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Don&amp;#39;t clear IRQn in interrupt, but that&amp;#39;s another issue. Depending on compiler, interrupt vector handler must be an exact name match to be called as a vector instead of the default handler. Only END interrupt is enabled, so don&amp;#39;t waste time testing it. Use a DSB instruction to avoid problems later on.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void SAADC_IRQHandler(void)
{
    ADC-&amp;gt;EVENTS_END = 0;
    // In case the code is later modified with no following instructions prevent a spurious extra interrupt
    __DSB();
    printk(&amp;quot;ADC Value: %u\n&amp;quot;, adc_data_buf[0]);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Use volatile keyword:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static volatile uint16_t adc_data_buf[1]; // Single sample buffer&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC will not start</title><link>https://devzone.nordicsemi.com/thread/517536?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2025 16:26:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d734659-c595-4b91-941a-a843acafe77d</guid><dc:creator>Taylor Nelson</dc:creator><description>&lt;p&gt;Thank you,&lt;/p&gt;
&lt;p&gt;That solved the issue of getting out of the infinite loop: while(!ADC-&amp;gt;EVENTS_STARTED), but the interrupt is still not being triggered at all.&lt;/p&gt;
&lt;p&gt;Is there anything that I am doing wrong in terms of setting up the interrupt?&lt;/p&gt;
&lt;p&gt;I modified the IRQ to the code below, and I never see &amp;quot;Interrupt Called&amp;quot; printed to the console, so I know that the IRQ is never executed.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="sass"&gt;void SAADC_IRQHandler()
{
    printk(&amp;quot;Interrupt Called\n&amp;quot;);
    if(ADC-&amp;gt;EVENTS_END)
    {
        ADC-&amp;gt;EVENTS_END = 0;
        printk(&amp;quot;ADC Value: %u\n&amp;quot;, adc_data_buf[0]);
    }
    NVIC_ClearPendingIRQ(SAADC_IRQn);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best,&lt;/p&gt;
&lt;p&gt;Taylor&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC will not start</title><link>https://devzone.nordicsemi.com/thread/517341?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2025 22:34:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e1cfa64-fc45-42e4-ac27-361c3327aff9</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Bug here:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ADC-&amp;gt;INTENSET = SAADC_INTENSET_END_Set;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Fix:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ADC-&amp;gt;INTENSET = SAADC_INTENSET_END_Set &amp;lt;&amp;lt; SAADC_INTENSET_END_Pos;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Some stuff like events are in bit 0, other stuff ain&amp;#39;t ..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>