<?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>configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71639/configuring-multiple-saadc-channels</link><description>Hi, 
 I want to configure 2 channels of saadc in differential mode as follows: 
 
 But when I received data, it seems that only the channel that its channel index is zero is enabled. may you help me to find the issue and configure this 2 channel in scan</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 May 2021 08:25:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71639/configuring-multiple-saadc-channels" /><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/308887?ContentTypeID=1</link><pubDate>Mon, 10 May 2021 08:25:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ba83840-0118-4cc9-bc6f-a489bcb2f905</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;No, the SAADC have 12 bit resolution. The output from the SAADC is a 16-bit &lt;span&gt;2’s complement values. Normally, the output in single-ended mode with 12 bit resolution configuration will be 0 to 4095. However,&amp;nbsp;since the SAADC architecture is differential with two inputs, the output value can also be slightly negative when the input it close to GND (due to&amp;nbsp;noise levels).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/307740?ContentTypeID=1</link><pubDate>Sat, 01 May 2021 08:26:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15323165-d7fc-463f-a6c8-b0887d65a48d</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;According to what you said it means that the ADC technically has 13 bits resolution? if no, just out of curiosity, So what is the state of 12 bits that came from ADC? What is their format?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/307329?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 19:35:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3738a67a-8c4f-4ca6-884e-410d9e120460</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, you would need at least 13 bits to be able to know the sign as well. The sample is sign-extended to fill the 16 bit variable. As you can see from my example above, the 13th bit is used to indicate negative (1) or positive (0). The last 3 bits will have the same value as the first sign bit, and can be ignored if you need to compress the samples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/307307?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 15:57:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb7219d2-7fba-4baa-b375-ab85d2da00ba</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;I get what you said but I have a question. How does sign-extended to 16 bit happen? can you say an example? Also, I think if we have 12 bits of data we have to be able to regenerate the analog sample from just 12 bits and 4 bits are redundant. or at least we will have one bit for the sign? for example in here for a 16-bit data all 4 bits of the stored data have 2 options: 1111 or 0000. Am I wrong?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/307179?ContentTypeID=1</link><pubDate>Wed, 28 Apr 2021 09:10:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:341e9d21-e686-4f98-8167-4c0bc5a4864a</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Thanks, it helped.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/306865?ContentTypeID=1</link><pubDate>Mon, 26 Apr 2021 15:21:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83f434dc-3a35-4323-a7ce-085f1ed97f2b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As mentioned in the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html#saadc_frontpage"&gt;SAADC peripheral documentation&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&amp;quot;Samples stored as 16-bit 2’s complement values for differential and single-ended sampling&amp;quot;&lt;/p&gt;
&lt;p&gt;and:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;Results are stored in little-endian byte order in Data RAM. Every sample will be sign extended to 16 bit before stored in the Result buffer.&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You may face issues if you use 12 bit resolution only send the lower 12 bits of the sample, for instance will the samples &amp;quot;-1&amp;quot; and &amp;quot;4095&amp;quot; have the same binary value (0b1111&lt;strong&gt;111111111111&lt;/strong&gt; -&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;0b0000&lt;strong&gt;111111111111&lt;/strong&gt;).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Jørgen&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/306639?ContentTypeID=1</link><pubDate>Sat, 24 Apr 2021 20:02:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9734ab8d-7fff-4a6e-9b18-2caa2344f669</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Hi, I still have this problem. I wanted to ask that how do samples save in buffers of ADC? I put every 12 bit of my data in 1.5 bytes and put all data together in a buffer and send it by ble(Line 154 to 172 ).&amp;nbsp; I wanna see if I understand the concept of adc savind format .&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/298375?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 12:59:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13dc3030-816f-470c-a283-83717301a181</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I linked to the documentation on the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__esb.html#ga4fc7d57ca9aa231677535e7beeddb72d"&gt;NRF_ESB_CREATE_PAYLOAD&lt;/a&gt;&amp;nbsp;macro (&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__esb.html#ga4fc7d57ca9aa231677535e7beeddb72d"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__esb.html#ga4fc7d57ca9aa231677535e7beeddb72d&lt;/a&gt;).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/298374?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 12:58:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9295d815-a14a-4043-9bba-a5728a443d04</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Thanks. where can I find the API documentation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/298371?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 12:55:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63765973-fd41-4cc5-9c1e-81511478f712</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;As mentioned in API documentation for&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__esb.html#ga4fc7d57ca9aa231677535e7beeddb72d"&gt;NRF_ESB_CREATE_PAYLOAD&lt;/a&gt;, it can only support 1 to 63 values. This may be a limitation of supported elements in&amp;nbsp;&lt;span&gt;__VA_ARGS__ list used in the macro. You can set the parameters in the struct yourself according to the code shown in the API documentation if you need longer payloads.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/298222?ContentTypeID=1</link><pubDate>Sun, 07 Mar 2021 12:04:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38a11ff2-cc31-4581-8f59-24e04e49c04e</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;I want to send data in 98 bytes length (payload length =98), but the nrf_esb_create_payload shows errors when I put more than 64 bytes in it. what is the problem?&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1615118614912v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1615118637253v2.png" alt=" " /&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/297766?ContentTypeID=1</link><pubDate>Thu, 04 Mar 2021 11:33:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe2cfdce-b68b-4b1f-8aca-4c64763d3e9a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The switching between LDO and DCDC is handled automatically by the chip depending on the load:&amp;nbsp;&lt;em&gt;&amp;quot;Automatic switching between LDO and DC/DC regulator based on load to maximize efficiency&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The DCDC switching itself happens at 8MHz, as mentioned in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/69674/nrf52840-dcdc-mode-dcdc-switching-frequency/285815#285815"&gt;this post&lt;/a&gt;. It is possible that it could be harmonics to this, but I would need to verify that with our developers. Have you verified that the harmonics disappear if you do not enable the DCDC regulator?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/296828?ContentTypeID=1</link><pubDate>Mon, 01 Mar 2021 12:09:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c436d5c2-d726-4dad-ae65-809731ae1b83</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Yes, I convert them to voltage but the program is ok, I tested it. I reduce the SR but the problem is still there. Also my acquisition time is 10us. the interesting thing is that, when I imply an sin input to the second channel, its function is ok and I will have the correct answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Another problem I have is that I have some kind of noise on my signal which includes some harmonic in 2k,4k,6k,..... I think it comes from the power switching between LDO and DCDC. Do you know how often do MCU switch between them? or what is the frequency of this task?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1614600575723v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/296375?ContentTypeID=1</link><pubDate>Thu, 25 Feb 2021 17:58:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:674801ca-56b9-44b5-9717-b629475c3dec</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="Masoumeh"]Can we configure multiple differential channels with a common ANI?[/quote]
&lt;p&gt;Since the SAADC input muxes needs to be reconfigured between each channel anyway, I do not see any technical reasons that this should not work.&lt;/p&gt;
[quote user="Masoumeh"]I want to measure the input noise of my analog system, so I shorted the input signals. I saw that the second channel of ADC data is some how incorrect and quantized.[/quote]
&lt;p&gt;Are the samples somehow processed before plotted in the graphs? What does the raw SAADC samples look like?&lt;/p&gt;
&lt;p&gt;Have you tested with a slower sample rate, to make sure that the previous sampling is completed on both channels before starting the next? By default, the acquisition time per channel should be 10us, so unless you have not modified the drivers, you should have plenty of time for 2 channels in 50 us.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/295547?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2021 11:20:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e557cd0-87ed-4e30-9c77-027dba8754b7</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Also I have another Problem. I want to measure the input noise of my analog system, so I shorted the input signals. I saw that the second channel of ADC data is some how incorrect and quantized. the data from ch1 and 2 are like below:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1613992734360v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1613992770417v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the code that I am using for this is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;sdk_common.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_esb.h&amp;quot;
#include &amp;quot;nrf_error.h&amp;quot;
#include &amp;quot;nrf_esb_error_codes.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_clock.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;app_util.h&amp;quot;

/** user&amp;#39;s code begins 1. 
*/
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;nrf_drv_saadc.h&amp;quot;
#include &amp;quot;nrf_drv_ppi.h&amp;quot;
#include &amp;quot;nrf_drv_timer.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;nrf_pwr_mgmt.h&amp;quot;
/** user&amp;#39;s code ends 1. 
*/

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

/** user&amp;#39;s code begins 2. 
*/

#define SAMPLES_IN_BUFFER 20
volatile uint8_t state = 1;

static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(0);
static nrf_saadc_value_t     m_buffer_pool[2][SAMPLES_IN_BUFFER];
static nrf_ppi_channel_t     m_ppi_channel;
static uint32_t              m_adc_evt_counter;

static nrf_esb_payload_t        tx_payload = NRF_ESB_CREATE_PAYLOAD(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);


static nrf_esb_payload_t        rx_payload;
uint8_t flag=0;

static uint32_t              Sending_packet_passed;
static uint32_t              Sending_packet_failed;

bool buf_flag=false;

void timer_handler(nrf_timer_event_t event_type, void * p_context)
{

}

void saadc_sampling_event_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.bit_width = NRF_TIMER_BIT_WIDTH_32;
    err_code = nrf_drv_timer_init(&amp;amp;m_timer, &amp;amp;timer_cfg, timer_handler);
    APP_ERROR_CHECK(err_code);

    /* setup m_timer for compare event every 50us */
    uint32_t ticks = nrf_drv_timer_us_to_ticks(&amp;amp;m_timer, 50);
    nrf_drv_timer_extended_compare(&amp;amp;m_timer,
                                   NRF_TIMER_CC_CHANNEL0,
                                   ticks,
                                   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
                                   false);
    nrf_drv_timer_enable(&amp;amp;m_timer);

    uint32_t timer_compare_event_addr = nrf_drv_timer_compare_event_address_get(&amp;amp;m_timer,
                                                                                NRF_TIMER_CC_CHANNEL0);
    uint32_t saadc_sample_task_addr   = nrf_drv_saadc_sample_task_get();

    /* setup ppi channel so that timer compare event is triggering sample task in SAADC */
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(m_ppi_channel,
                                          timer_compare_event_addr,
                                          saadc_sample_task_addr);
    APP_ERROR_CHECK(err_code);
}


void saadc_sampling_event_enable(void)
{
    ret_code_t err_code = nrf_drv_ppi_channel_enable(m_ppi_channel);

    APP_ERROR_CHECK(err_code);
}


void saadc_callback(nrf_drv_saadc_evt_t const * p_event) //ok
{
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;
				if (!buf_flag)
					err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
				else
					err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);

        int i;
				int k=1;
				for (i = 0; i &amp;lt; SAMPLES_IN_BUFFER; i+=2)
			  {
					tx_payload.data[k] =   (uint8_t)(p_event-&amp;gt;data.done.p_buffer[i]);
					tx_payload.data[k+1] = (uint8_t)(p_event-&amp;gt;data.done.p_buffer[i] &amp;gt;&amp;gt; 8) | (uint8_t)(p_event-&amp;gt;data.done.p_buffer[i+1] &amp;lt;&amp;lt; 4);
					tx_payload.data[k+2] = (uint8_t)(p_event-&amp;gt;data.done.p_buffer[i+1] &amp;gt;&amp;gt; 4);
					k+=3;
			  }
				tx_payload.data[0]=m_adc_evt_counter++;
				tx_payload.data[31]=tx_payload.data[0];
				if (nrf_esb_write_payload(&amp;amp;tx_payload) ==NRF_SUCCESS)
				{
					Sending_packet_passed++;
				}
				else
				{
					Sending_packet_failed++;
				}
				buf_flag = !buf_flag;
    }
}


void saadc_init(void) //ok
{
    ret_code_t err_code;

	nrf_saadc_channel_config_t channel_config1 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN4,NRF_SAADC_INPUT_AIN6);
	nrf_saadc_channel_config_t channel_config2 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN5,NRF_SAADC_INPUT_AIN7);

    err_code = nrf_drv_saadc_init(NULL, saadc_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config1);
    APP_ERROR_CHECK(err_code);
		err_code = nrf_drv_saadc_channel_init(1, &amp;amp;channel_config2);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
		
//		nrf_saadc_continuous_mode_enable(800);

}

/** user&amp;#39;s code ends 2. 
*/


void nrf_esb_event_handler(nrf_esb_evt_t const * p_event)
{
    switch (p_event-&amp;gt;evt_id)
    {
        case NRF_ESB_EVENT_TX_SUCCESS:
            NRF_LOG_DEBUG(&amp;quot;TX SUCCESS EVENT&amp;quot;);
            break;
        case NRF_ESB_EVENT_TX_FAILED:
            NRF_LOG_DEBUG(&amp;quot;TX FAILED EVENT&amp;quot;);
            (void) nrf_esb_flush_tx();
            (void) nrf_esb_start_tx();
            break;
        case NRF_ESB_EVENT_RX_RECEIVED:
            NRF_LOG_DEBUG(&amp;quot;RX RECEIVED EVENT&amp;quot;);
            while (nrf_esb_read_rx_payload(&amp;amp;rx_payload) == NRF_SUCCESS)
            {
                if (rx_payload.length &amp;gt; 0)
                {
                    NRF_LOG_DEBUG(&amp;quot;RX RECEIVED PAYLOAD&amp;quot;);
                }
            }
            break;
    }
}


void clocks_start( void )
{
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;

    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);
}


void gpio_init( void )
{
    nrf_gpio_range_cfg_output(8, 15);
    bsp_board_init(BSP_INIT_LEDS);
}


uint32_t esb_init( void )
{
    uint32_t err_code;
    uint8_t base_addr_0[4] = {0xE7, 0xE7, 0xE7, 0xE7};
    uint8_t base_addr_1[4] = {0xC2, 0xC2, 0xC2, 0xC2};
    uint8_t addr_prefix[8] = {0xE7, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8 };

    nrf_esb_config_t nrf_esb_config         = NRF_ESB_DEFAULT_CONFIG;
    nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
    nrf_esb_config.retransmit_delay         = 600;
    nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_2MBPS_BLE;
    nrf_esb_config.event_handler            = nrf_esb_event_handler;
    nrf_esb_config.mode                     = NRF_ESB_MODE_PTX;
    nrf_esb_config.selective_auto_ack       = false;

    err_code = nrf_esb_init(&amp;amp;nrf_esb_config);

    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_base_address_0(base_addr_0);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_base_address_1(base_addr_1);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_prefixes(addr_prefix, NRF_ESB_PIPE_COUNT);
    VERIFY_SUCCESS(err_code);

    return err_code;
}


int main(void)
{
	
    ret_code_t err_code;
    gpio_init();
  	nrf_gpio_pin_clear(10);

    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
	
  	nrf_gpio_cfg_output(27);
		nrf_gpio_pin_clear(27);
	
	
		clocks_start();
	
    err_code = esb_init();
    APP_ERROR_CHECK(err_code);
		
		/** user&amp;#39;s code begins 3. 
		*/
		ret_code_t ret_code = nrf_pwr_mgmt_init();
    APP_ERROR_CHECK(ret_code);

    saadc_init();
    saadc_sampling_event_init();
    saadc_sampling_event_enable();
		
		/** usr&amp;#39;s code ends 3. 
		*/ 
    while (true)
    { 
				nrf_pwr_mgmt_run();
    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/295465?ContentTypeID=1</link><pubDate>Sun, 21 Feb 2021 17:33:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d5249b3-d72f-4a44-9b3b-70744896a174</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Thanks it helped. I have another question. Can we configure multiple differential channels with a common ANI? for example like :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_saadc_channel_config_t channel_config1 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN4,NRF_SAADC_INPUT_AIN0);
nrf_saadc_channel_config_t channel_config2 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN5,NRF_SAADC_INPUT_AIN0);
nrf_saadc_channel_config_t channel_config3 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN6,NRF_SAADC_INPUT_AIN0);
nrf_saadc_channel_config_t channel_config4 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN7,NRF_SAADC_INPUT_AIN0);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/294480?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 18:58:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72508e3b-f9fa-4bde-b39f-1058d731d596</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;There is a &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/nrf_dev_saadc_example.html"&gt;SAADC example in the SDK&lt;/a&gt; that shows how to use a TIMER to sample the SAADC at a regular interval. This can easily be extended with multiple channels.&lt;/p&gt;
&lt;p&gt;If you want low-power SAADC, there are some examples available in &lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples"&gt;this GitHub repository&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you want to use the legacy SAADC driver API with low power and multiple channels, see the example in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/23867/nrf52-best-practise-for-ultra-low-power-saadc-4-channel-conversion/177265#177265"&gt;this post&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/294405?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 13:46:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37616460-0b68-4f72-b175-21e7a2bbab37</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Thanks, can you help me how to do so ? Is there any example for that?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: configuring multiple saadc channels</title><link>https://devzone.nordicsemi.com/thread/294395?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 13:31:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04500048-ced4-461e-ab48-4e8749fbdf43</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It looks like you are using the internal timer to enable continuous sample mode, by calling the nrf_saadc_continuous_mode_enable() function. As written in the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html#saadc_operationmodes_continuous"&gt;SAADC peripheral documentation&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;quot;The SAMPLERATE timer mode cannot be combined with SCAN mode, and only one channel can be enabled in this mode.&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You need to use an external TIMER/RTC to trigger the sampling when using SCAN mode.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>