<?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>ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66786/adc-interupt-based-on-saadc-limit-monitoring-or-lpcomp</link><description>Greetings, 
 We are using nrf-sdk v1.3.0. 
 We would like to monitor an adc channel using either limit event monitoring or maybe LPCOMP. 
 I was able to find &amp;quot;low level&amp;quot; documentation, describing the registers and such, but no actual example code using</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Oct 2020 10:14:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66786/adc-interupt-based-on-saadc-limit-monitoring-or-lpcomp" /><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/277568?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2020 10:14:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cda227b5-ecab-4c28-a331-d79a1860a1d3</guid><dc:creator>Tjaz</dc:creator><description>&lt;p&gt;Hey,&lt;/p&gt;
&lt;p&gt;ignore the above. I have made some progress, but my code gets stuck.&lt;/p&gt;
&lt;p&gt;I have:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;NOTE: I am using nrf-sdk v1.3.0&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;prj.conf:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# ADC
CONFIG_ADC=y
CONFIG_ADC_NRFX_SAADC=y
CONFIG_NRFX_SAADC=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;main:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr.h&amp;gt;

#include &amp;lt;drivers/adc.h&amp;gt;

#include &amp;lt;nrfx_saadc.h&amp;gt;

#include &amp;lt;logging/log.h&amp;gt;
LOG_MODULE_REGISTER(main);

#define SAADC_BUFFER_LEN 1
static int16_t saadc_results_buffer[SAADC_BUFFER_LEN];

void saadc_event_handler(nrfx_saadc_evt_t const *p_event)
{
    LOG_INF(&amp;quot;SAADC EVENT: %d&amp;quot;, p_event-&amp;gt;type);
}

void main(void)
{
#define CHANNEL 0
#define AIN_50HZ_AMP NRF_SAADC_INPUT_AIN0
#define LIMIT_LOW 0
#define LIMIT_HIGH 50

    LOG_INF(&amp;quot;OPT 2&amp;quot;);
    LOG_INF(&amp;quot;INIT SAADC&amp;quot;);
    nrfx_err_t nrfx_err = nrfx_saadc_init(0);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_init, err: %d&amp;quot;, nrfx_err);
    }

    nrfx_err = nrfx_saadc_offset_calibrate(NULL);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_offset_calibrate, err: %d&amp;quot;, nrfx_err);
    }

    nrfx_saadc_channel_t saacd_channel_cfg = NRFX_SAADC_DEFAULT_CHANNEL_SE(AIN_50HZ_AMP, CHANNEL); // AIN 0 and channel 1
    nrfx_saadc_adv_config_t saadc_adv_config = NRFX_SAADC_DEFAULT_ADV_CONFIG;
    saadc_adv_config.internal_timer_cc = 200;

    nrfx_err = nrfx_saadc_channels_config(&amp;amp;saacd_channel_cfg, 1);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_channels_config, err: %d&amp;quot;, nrfx_err);
    }

    nrfx_err = nrfx_saadc_advanced_mode_set(BIT(CHANNEL), NRF_SAADC_RESOLUTION_12BIT, &amp;amp;saadc_adv_config, saadc_event_handler);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_advanced_mode_set, err: %d&amp;quot;, nrfx_err);
    }

    nrfx_err = nrfx_saadc_buffer_set(saadc_results_buffer, SAADC_BUFFER_LEN);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_buffer_set, err: %d&amp;quot;, nrfx_err);
    }

    nrfx_err = nrfx_saadc_limits_set(CHANNEL, LIMIT_LOW, LIMIT_HIGH);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_limits_set, err: %d&amp;quot;, nrfx_err);
    }
    LOG_INF(&amp;quot;AFTER INIT SAADC&amp;quot;);

    LOG_INF(&amp;quot;START SAADC SAMPLING&amp;quot;);
    nrfx_err = nrfx_saadc_mode_trigger();  // !!code gets stuck here!!
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_mode_trigger, err: %d&amp;quot;, nrfx_err);
    }

    LOG_INF(&amp;quot;sleep 5 s&amp;quot;);
    k_sleep(K_SECONDS(5));
    LOG_INF(&amp;quot;STOP SAADC SAMPLING&amp;quot;);
    nrfx_saadc_abort();
    
    // main goes to sleep;
    while (1)
    {
        k_sleep(K_SECONDS(3600));
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The code gets stuck on line 69.&lt;/p&gt;
&lt;p&gt;Tracing this further into the called function (&lt;em&gt;nrfx_saadc_mode_trigger&lt;/em&gt;), is gets tuck at&amp;nbsp;&lt;strong&gt;line 509 in nrfx_saadc.c&lt;/strong&gt;, where it calls:&lt;br /&gt;&lt;em&gt;nrf_saadc_task_trigger(NRF_SAADC, NRF_SAADC_TASK_START);&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;wich is just a&amp;nbsp;simple function setting a register (in nrf_saadc.h):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_STATIC_INLINE void nrf_saadc_task_trigger(NRF_SAADC_Type * p_reg, nrf_saadc_task_t task)
{
    *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Any&amp;nbsp;suggestions on how to debug this?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Tjaž&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/277406?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2020 13:49:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b00a399-b3e7-4d18-9d31-82d20e869d2f</guid><dc:creator>Tjaz</dc:creator><description>&lt;p&gt;Ok.&lt;/p&gt;
&lt;p&gt;Based on your reply I ahve abandoned RTC/Timer, and am now trying to set up SAADC internal timer.&lt;/p&gt;
&lt;p&gt;I have the following code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;LOG_INF(&amp;quot;INIT SAADC&amp;quot;);
    nrfx_err_t nrfx_err = nrfx_saadc_init(0);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_init, err: %d&amp;quot;, nrfx_err);
    }

    // ...
    nrfx_saadc_channel_t saacd_channel_cfg[1] = {NRFX_SAADC_DEFAULT_CHANNEL_SE(0, 0)}; // AIN 0 and channel 1
    nrfx_saadc_adv_config_t saadc_adv_config = NRFX_SAADC_DEFAULT_ADV_CONFIG;

    nrfx_err = nrfx_saadc_channels_config(saacd_channel_cfg, 1);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_channels_config, err: %d&amp;quot;, nrfx_err);
    }

    nrfx_err = nrfx_saadc_advanced_mode_set(BIT(0), NRF_SAADC_RESOLUTION_12BIT, &amp;amp;saadc_adv_config, saadc_event_handler);
    if (nrfx_err != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;nrfx_saadc_advanced_mode_set, err: %d&amp;quot;, nrfx_err);
    }

    nrfx_err = nrfx_saadc_buffer_set(saadc_results_buffer, 100);

    LOG_INF(&amp;quot;AFTER INIT SAADC&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The code crashed in&amp;nbsp;&lt;em&gt;nrfx_saadc_channels_config&lt;/em&gt; with:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ASSERTION FAIL [p_channels[i].pin_p] @ /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/ncs_v1.3.0/modules/hal/nordic/nrfx/drivers/src/nrfx_saadc.c:289
[00:00:00.224,060] &amp;lt;err&amp;gt; os: r0/a1:  0x00000004  r1/a2:  0x00000121  r2/a3:  0x00000001
[00:00:00.232,788] &amp;lt;err&amp;gt; os: r3/a4:  0x00000000 r12/ip:  0x00020000 r14/lr:  0x000383eb
[00:00:00.241,516] &amp;lt;err&amp;gt; os:  xpsr:  0x61000000
[00:00:00.246,765] &amp;lt;err&amp;gt; os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
[00:00:00.257,263] &amp;lt;err&amp;gt; os: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
[00:00:00.267,761] &amp;lt;err&amp;gt; os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
[00:00:00.278,228] &amp;lt;err&amp;gt; os: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
[00:00:00.288,726] &amp;lt;err&amp;gt; os: fpscr:  0x00039e39
[00:00:00.293,975] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x0001f9c8
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;At the line specified there is an assert statement:&amp;nbsp;&lt;strong&gt;NRFX_ASSERT(p_channels[i].pin_p);&lt;br /&gt;&lt;/strong&gt;So it seems like&amp;nbsp;&lt;em&gt;nrf_saadc_channel_init&amp;nbsp;&lt;/em&gt;that is called before it does not set up the channel correctly.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How can I fix this?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Tjaž&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/277199?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 15:46:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:282d1a13-4581-460b-8bb1-8a7323775ca4</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;And by the way, I just realized in regards to your last comment / error:&amp;nbsp;&lt;/p&gt;
[quote user="Tjaz"]I get the following runtime error when the interrupt&amp;nbsp;should happen (there are no compile errors or warnings):[/quote]
&lt;p&gt;Have you configured SPM correctly?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/277163?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 13:59:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1e26f4d-e44f-4631-8aca-c15502a5e6b7</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello ,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You need to use nrfx_saadc in continous mode to sample on an interval:&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;Continuous mode&lt;/em&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;p&gt;&lt;em&gt;Continuous sampling can be achieved by using the internal timer in the ADC, or triggering the SAMPLE task from one of the general purpose timers through the PPI system.&lt;/em&gt;&lt;/p&gt;
&lt;div&gt;&lt;em&gt;Care shall be taken to ensure that the sample rate fulfils the following criteria, depending on how many channels are active:&lt;/em&gt;
&lt;pre&gt;&lt;em&gt;&lt;code&gt;f&lt;sub&gt;SAMPLE &lt;/sub&gt;&amp;lt; 1/(t&lt;sub&gt;ACQ&lt;/sub&gt; + t&lt;sub&gt;conv&lt;/sub&gt;)&lt;/code&gt;&lt;/em&gt;&lt;/pre&gt;
&lt;em&gt;The SAMPLERATE register can be used as a local timer instead of triggering individual SAMPLE tasks. When SAMPLERATE.MODE is set to Timers, it is sufficient to trigger SAMPLE task only once in order to start the SAADC and triggering the STOP task will stop sampling. The SAMPLERATE.CC field controls the sample rate.&lt;/em&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;The SAMPLERATE timer mode cannot be combined with SCAN mode, and only one channel can be enabled in this mode.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A DONE event signals that one sample has been taken.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In this mode, the RESULTDONE event has the same meaning as DONE when no oversampling takes place. Note that both events may occur before the actual value has been transferred into RAM by EasyDMA.&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**
 * @brief Function for setting the SAADC driver in the advanced mode.
 *
 * The advanced mode allows performing double-buffered conversions of arbitrary length.
 * The conversions can be done in a blocking or non-blocking manner. When performing conversions
 * in the non-blocking manner and @ref nrfx_saadc_adv_config_t.internal_timer_cc is set to 0,
 * sampling needs to be done by triggering @ref NRF_SAADC_TASK_SAMPLE externally
 * (for example by using the TIMER and/or the PPI/DPPI).
 * When performing conversions in the non-blocking manner and @ref nrfx_saadc_adv_config_t.start_on_end
 * is false, the @ref NRF_SAADC_TASK_START needs to be triggered on @ref NRF_SAADC_EVENT_END
 * externally (for example by using the PPI/DPPI).
 * Sampling is initiated by calling @ref nrfx_saadc_mode_trigger(). In case of performing
 * conversions in the blocking manner, @ref nrfx_saadc_mode_trigger() may need to be called several
 * times as each call sample each requested channel once.
 *
 * @note The internal timer can only be used when a single input channel is enabled.
 * @note The internal timer can only be used in the non-blocking mode.
 *
 * @param[in] channel_mask  Bitmask of channels to be used in the advanced mode.
 * @param[in] resolution    Resolution configuration.
 * @param[in] p_config      Pointer to the structure with the advanced mode configuration.
 * @param[in] event_handler Event handler provided by the user. In case of providing NULL,
 *                          the conversion will be performed in the blocking manner.
 *
 * @retval NRFX_SUCCESS             Initialization was successful.
 * @retval NRFX_ERROR_BUSY          There is a conversion or calibration ongoing.
 * @retval NRFX_ERROR_INVALID_PARAM Attempt to activate channel that is not configured.
 * @retval NRFX_ERROR_NOT_SUPPORTED Attempt to activate internal timer or oversampling without burst
 *                                  with multiple channels enabled.
 */
nrfx_err_t nrfx_saadc_advanced_mode_set(uint32_t                        channel_mask,
                                        nrf_saadc_resolution_t          resolution,
                                        nrfx_saadc_adv_config_t const * p_config,
                                        nrfx_saadc_event_handler_t      event_handler);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Tjaz"]It would be nice, as I have asked before, to get a working example of at lease each element on its own - so rtc configuration, adc configuration and dppi configuration to link them together[/quote]
&lt;p&gt;Yes, unfortunately, there are very few samples available for this. Zephyr does have some samples available, e.g. &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v2.3.0-rc1-ncs3/samples/boards/nrf/nrfx"&gt;nRF91 nrfx sample&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Øyvind&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/277040?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 08:27:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd792d62-fb2d-4229-9673-4e317287ec5a</guid><dc:creator>Tjaz</dc:creator><description>&lt;p&gt;Before configuring this &amp;quot;link&amp;quot; via DPPI, I have to get the rtc to work first tho...&lt;/p&gt;
&lt;p&gt;Using nrfx_rtc.h and writing code as such:&lt;/p&gt;
&lt;p&gt;prj.conf&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NRFX_RTC0=y
CONFIG_NRFX_DPPI=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
#include &amp;lt;nrfx_saadc.h&amp;gt;
#include &amp;lt;nrfx_rtc.h&amp;gt;

#include &amp;lt;logging/log.h&amp;gt;
LOG_MODULE_REGISTER(main);

void rtc_handler(nrfx_rtc_int_type_t int_type)
{
    LOG_INF(&amp;quot;RTC HANDLER&amp;quot;);
}


void main(void)
{ 
    LOG_INF(&amp;quot;INIT NRFX RTC&amp;quot;);
    nrfx_rtc_t rtc_dev = NRFX_RTC_INSTANCE(0);
    // copy of default config
    nrfx_rtc_config_t rtc_conf = {
        .prescaler = RTC_FREQ_TO_PRESCALER(32768),
        .interrupt_priority = NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY,
        .tick_latency = NRFX_RTC_US_TO_TICKS(2000, 32768),
        .reliable = false,
    };
    nrfx_err_t nerr = nrfx_rtc_init(&amp;amp;rtc_dev, &amp;amp;rtc_conf, rtc_handler);
    if (nerr != NRFX_SUCCESS)
    {
        LOG_ERR(&amp;quot;err: %d&amp;quot;, nerr);
    }

    nrfx_rtc_cc_set(&amp;amp;rtc_dev,
                    0,
                    1000000,
                    true);

    nrfx_rtc_enable(&amp;amp;rtc_dev);
    
    LOG_INF(&amp;quot;AFTER INIT NRFX RTC&amp;quot;);

    // main goes to sleep;
    while (1)
    {
        k_sleep(K_SECONDS(3600));
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I get the following runtime error when the interrupt&amp;nbsp;should happen (there are no compile errors or warnings):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 1: Unhandled interrupt on CPU 0
&amp;lt;err&amp;gt; os: Current thread: 0x200238c8 (unknown)
&amp;lt;err&amp;gt; os: Halting system
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How do I make zephyr aware of my interupt?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the final set up, i will probably have to pass&amp;nbsp;&lt;em&gt;false&amp;nbsp;&lt;/em&gt;as the last param to&amp;nbsp;&lt;em&gt;nrfx_rtc_cc_set&lt;/em&gt;&lt;em&gt;,&amp;nbsp;&lt;/em&gt;since I only want ADC to trigger an interupt. But If the adc interupt is configured only using the nrfx layer, wont a similar error occur?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Finaly, lets say I add this to the code, as you suggested, to set up DPPI:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
    NRF_RTC0-&amp;gt;PUBLISH_COMPARE[0] = (DPPI_PUB_CHIDX_Ch0) |
                                   (DPPI_PUB_EN_Msk);
    NRF_SAADC-&amp;gt;SUBSCRIBE_START = (DPPI_SUB_CHIDX_Ch0) |
                                 (DPPI_SUB_EN_Msk);

    NRF_DPPIC-&amp;gt;CHENSET = (DPPI_CHENSET_CH0_Set &amp;lt;&amp;lt; DPPI_CHENSET_CH0_Pos);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This does not compile, with the following errors:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;../src/main.c: In function &amp;#39;main&amp;#39;:
../src/main.c:311:37: error: &amp;#39;DPPI_PUB_CHIDX_Ch0&amp;#39; undeclared (first use in this function)
     NRF_RTC0-&amp;gt;PUBLISH_COMPARE[0] = (DPPI_PUB_CHIDX_Ch0) |
                                     ^~~~~~~~~~~~~~~~~~
../src/main.c:311:37: note: each undeclared identifier is reported only once for each function it appears in
../src/main.c:312:37: error: &amp;#39;DPPI_PUB_EN_Msk&amp;#39; undeclared (first use in this function); did you mean &amp;#39;DPPIC_CHG_CH2_Msk&amp;#39;?
                                    (DPPI_PUB_EN_Msk);
                                     ^~~~~~~~~~~~~~~
                                     DPPIC_CHG_CH2_Msk
../src/main.c:313:35: error: &amp;#39;DPPI_SUB_CHIDX_Ch0&amp;#39; undeclared (first use in this function); did you mean &amp;#39;DPPI_PUB_CHIDX_Ch0&amp;#39;?
     NRF_SAADC-&amp;gt;SUBSCRIBE_START = (DPPI_SUB_CHIDX_Ch0) |
                                   ^~~~~~~~~~~~~~~~~~
                                   DPPI_PUB_CHIDX_Ch0
../src/main.c:314:35: error: &amp;#39;DPPI_SUB_EN_Msk&amp;#39; undeclared (first use in this function); did you mean &amp;#39;DPPI_PUB_EN_Msk&amp;#39;?
                                  (DPPI_SUB_EN_Msk);
                                   ^~~~~~~~~~~~~~~
                                   DPPI_PUB_EN_Msk
../src/main.c:316:27: error: &amp;#39;DPPI_CHENSET_CH0_Set&amp;#39; undeclared (first use in this function); did you mean &amp;#39;DPPIC_CHENSET_CH0_Set&amp;#39;?
     NRF_DPPIC-&amp;gt;CHENSET = (DPPI_CHENSET_CH0_Set &amp;lt;&amp;lt; DPPI_CHENSET_CH0_Pos);
                           ^~~~~~~~~~~~~~~~~~~~
                           DPPIC_CHENSET_CH0_Set
../src/main.c:316:51: error: &amp;#39;DPPI_CHENSET_CH0_Pos&amp;#39; undeclared (first use in this function); did you mean &amp;#39;DPPIC_CHENSET_CH0_Pos&amp;#39;?
     NRF_DPPIC-&amp;gt;CHENSET = (DPPI_CHENSET_CH0_Set &amp;lt;&amp;lt; DPPI_CHENSET_CH0_Pos);
                                                   ^~~~~~~~~~~~~~~~~~~~
                                                   DPPIC_CHENSET_CH0_Pos
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /home/comemaster/.local/bin/cmake --build /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/ncs_v1.3.0/nrf/applications/saadc-test/build
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Looking at&amp;nbsp;&lt;em&gt;nrf9160_bitfields.h&amp;nbsp;&lt;/em&gt;I can see that some of these identifiers have changed (like&amp;nbsp; DPPI_CHENSET_CH0_Set -&amp;gt;&amp;nbsp;DPPIC_CHENSET_CH0_Set), while others I can not find at all (like&amp;nbsp;DPPI_PUB_CHIDX_Ch0 or&amp;nbsp;DPPI_PUB_EN_Msk).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It would be nice, as I have asked before, to get a working example of at lease each element on its own - so rtc configuration, adc configuration and dppi configuration to link them together&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Tjaž&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/275936?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 12:58:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed840bb6-1f3e-48c6-806d-12edc3f1f821</guid><dc:creator>&amp;#216;yvind</dc:creator><description>[quote user="Tjaz"]1. Is there a driver for setting RTC to trigger SAADC sampling on an interval?[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Yes, I believe the DPPI can be used for this purpose. &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/dppi.html?cp=2_0_0_5_1_1"&gt;Have a look here&lt;/a&gt;. Just change TIMER0 to RTC.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;One-to-one connection&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;This example shows how to create a one-to-one connection between TIMER compare register and SAADC start task.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The channel configuration is set up first. TIMER0 will publish its COMPARE0 event on channel 0, and SAADC will subscribe its START task to events on the same channel. After that, the channel is enabled through the DPPIC.&lt;/em&gt;&lt;/p&gt;
&lt;pre&gt;&lt;em&gt;&lt;code&gt;
NRF_TIMER0-&amp;gt;PUBLISH_COMPARE0 = (DPPI_PUB_CHIDX_Ch0) | 
                               (DPPI_PUB_EN_Msk);
NRF_SAADC-&amp;gt;SUBSCRIBE_START   = (DPPI_SUB_CHIDX_Ch0) | 
                               (DPPI_SUB_EN_Msk);
  
NRF_DPPIC-&amp;gt;CHENSET = (DPPI_CHENSET_CH0_Set &amp;lt;&amp;lt; DPPI_CHENSET_CH0_Pos);&lt;/code&gt;&lt;/em&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Tjaz"]2. Can I use this driver you linked in addition to my existing code, that uses zephyrs driver (&lt;em&gt;#include &amp;lt;drivers/adc.h&amp;gt;&lt;/em&gt;)? Or will using&amp;nbsp;&lt;em&gt;nrfx_saadc.h&lt;/em&gt; directly mess up things that I configure with&amp;nbsp;&lt;em&gt;adc.h&lt;/em&gt;?[/quote]
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;The Zephyr ADC (zephyr\include\drivers\adc.h--&amp;gt;zephyr\drivers\adc\adc_nrfx_saadc.c) uses the functions from hal/nrf_saadc.h. If you configure stuff on the lowest level first (nrf_saadc.h.) the Zephyr layer will not know about it. I would recommend sticking to one layer. But if you know what you&amp;#39;re doing, I think it should be possible to mix them&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/275543?ContentTypeID=1</link><pubDate>Mon, 19 Oct 2020 09:26:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1825304d-3873-4458-a068-6317cd87f346</guid><dc:creator>Tjaz</dc:creator><description>&lt;p&gt;Thank you for the link.&lt;/p&gt;
&lt;p&gt;I have some further questions:&lt;/p&gt;
&lt;p&gt;1. Is there a driver for setting RTC to trigger SAADC sampling on an interval?&lt;/p&gt;
&lt;p&gt;2. Can I use this driver you linked in addition to my existing code, that uses zephyrs driver (&lt;em&gt;#include &amp;lt;drivers/adc.h&amp;gt;&lt;/em&gt;)? Or will using&amp;nbsp;&lt;em&gt;nrfx_saadc.h&lt;/em&gt; directly mess up things that I configure with&amp;nbsp;&lt;em&gt;adc.h&lt;/em&gt;?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Tjaž&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/274348?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 13:31:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03800be0-0768-46c8-aa95-7512120d011a</guid><dc:creator>&amp;#216;yvind</dc:creator><description>[quote user=""]Reading this thread:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/20895/saadc-low-power-scan-mode"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/20895/saadc-low-power-scan-mode&lt;/a&gt;[/quote]
&lt;p&gt;&amp;nbsp;Note that this is a 4 year old answer which is not related to nRF Connect SDK.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Tjaz"]Regardless of the wrong links, the question remains the same: how to register a handler to run&amp;nbsp;when adc sample is &amp;quot;out of range&amp;quot;, and to consume as little power as possible?[/quote]
&lt;p&gt;&amp;nbsp;There is currently no API for this in Zephyr, but you can use the nrfx saadc driver directly (modules\hal\nordic\nrfx\drivers\include\nrfx_saadc.h)&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief Function for setting the SAADC channel limits.
 *
 * When limits are enabled and the conversion result exceeds the defined bounds,
 * the handler function is called with the corresponding event as parameter.
 *
 * @note Before the limits are set, the driver operation mode (simple or advanced) has
 *       to be configured. Only non-blocking conversions can be monitored.
 *
 * @note Changing of the driver operation mode disables all configured limits.
 *
 * @param[in] channel    Channel index.
 * @param[in] limit_low  Limit low value to generate interrupt. Use @c INT16_MIN
 *                       to disable interrupt generation.
 * @param[in] limit_high Limit high value to generate interrupt. Use @c INT16_MAX
 *                       to disable interrupt generation.
 *
 * @retval NRFX_SUCCESS             Requested channel limits were set.
 * @retval NRFX_ERROR_INVALID_PARAM Attempt to activate the limits on disabled channel.
 * @retval NRFX_ERROR_FORBIDDEN     Attempt to activate the limits for blocking conversions.
 * @retval NRFX_ERROR_INVALID_STATE Attempt to activate the limits without configured mode.
 */
nrfx_err_t nrfx_saadc_limits_set(uint8_t channel, int16_t limit_low, int16_t limit_high);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/273487?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 12:19:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b20ea15c-83ab-46cc-98ba-a92cd9d1a803</guid><dc:creator>Tjaz</dc:creator><description>&lt;p&gt;Yes, sorry.&lt;/p&gt;
&lt;p&gt;We are trying to do this using nrf9160.&lt;/p&gt;
&lt;p&gt;The docs are these:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf9160%2Fsaadc.html&amp;amp;cp=2_0_0_5_11_8&amp;amp;anchor=saadc_limits"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf9160%2Fsaadc.html&amp;amp;cp=2_0_0_5_11_8&amp;amp;anchor=saadc_limits&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Regardless of the wrong links, the question remains the same: how to register a handler to run&amp;nbsp;when adc sample is &amp;quot;out of range&amp;quot;, and to consume as little power as possible?&lt;/p&gt;
&lt;p&gt;If this can not be done through zephyrs APIs, is it possible in some other way?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC interupt based on SAADC limit monitoring or LPCOMP</title><link>https://devzone.nordicsemi.com/thread/273484?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 12:15:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ab41cfb-b675-4c27-80c4-2fc972b5023c</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There are some ADC samples in Zephyr e.g. &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.1/zephyr/samples/boards/nrf/battery/README.html#battery-voltage-measurement"&gt;Battery Voltage Measurement&lt;/a&gt;. Unfortunately, there are very few for ADC.&lt;br /&gt;&lt;br /&gt;You are referring to nRF52840 documentation, while the DevZone tags show nRF9160. Can you please elaborate?&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>