<?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>Why channel corresponding to the array is changed？</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21880/why-channel-corresponding-to-the-array-is-changed</link><description>#define SAMPLES_IN_BUFFER 4
static nrf_saadc_value_t m_buffer_pool[1][SAMPLES_IN_BUFFER];

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
 if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
 {
 ret_code_t err_code;

 err_code = nrf_drv_saadc_buffer_convert</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 11 May 2017 17:34:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21880/why-channel-corresponding-to-the-array-is-changed" /><item><title>RE: Why channel corresponding to the array is changed？</title><link>https://devzone.nordicsemi.com/thread/85900?ContentTypeID=1</link><pubDate>Thu, 11 May 2017 17:34:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f33f473-1c04-43c1-8955-94d60f1940f2</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I don&amp;#39;t understand your last comment. Did you try the change I suggested in my answer above?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why channel corresponding to the array is changed？</title><link>https://devzone.nordicsemi.com/thread/85899?ContentTypeID=1</link><pubDate>Tue, 09 May 2017 01:43:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17cd8b91-7b5a-40a7-804f-b778c618da92</guid><dc:creator>creator</dc:creator><description>&lt;p&gt;1.Don&amp;#39;t use the BLE&lt;/p&gt;
&lt;p&gt;2.E:\nordic\nRF5_SDK_12.2.0_f012efa\examples\peripheral\saadc&lt;/p&gt;
&lt;ol start="3"&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;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 400ms */
    uint32_t ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer, 400);
    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);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;4.Tried you provide the callback processing, or not&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Why channel corresponding to the array is changed？</title><link>https://devzone.nordicsemi.com/thread/85898?ContentTypeID=1</link><pubDate>Mon, 08 May 2017 11:05:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df84bf8f-58f5-48aa-a110-a63a14a4c27f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;When are the samples shifted? Are you using BLE in your application? What is the sample rate, and how do you trigger sampling? First thing you should try is to move the setup of the buffer in the callback, until after you read the buffer:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;

        int i;
        NRF_LOG_INFO(&amp;quot;ADC event number: %d\r\n&amp;quot;, (int)m_adc_evt_counter);

        for (i = 0; i &amp;lt; SAMPLES_IN_BUFFER; i++)
        {
            NRF_LOG_INFO(&amp;quot;%d\r\n&amp;quot;, p_event-&amp;gt;data.done.p_buffer[i]);
        }
        m_adc_evt_counter++;
		
	    err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>