<?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>Sampling ADC with two sampling frequency alternately....</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16630/sampling-adc-with-two-sampling-frequency-alternately</link><description>Hi, 
 I am working in one application in which I need SAADC to sample two channels at 1ksps and 500 samples per seconds. 
 I am sending 1 and 2 to switch the sampling rate i.e. if I send 1 then SAADC should sample at 1ksps and for 2 it should sample</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Sep 2016 11:30:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16630/sampling-adc-with-two-sampling-frequency-alternately" /><item><title>RE: Sampling ADC with two sampling frequency alternately....</title><link>https://devzone.nordicsemi.com/thread/63596?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2016 11:30:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1428650-ba7f-4281-85f6-1352a6ff6fa2</guid><dc:creator>Ankush</dc:creator><description>&lt;p&gt;Ok Ole. Thanks for your support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sampling ADC with two sampling frequency alternately....</title><link>https://devzone.nordicsemi.com/thread/63595?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2016 11:22:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4bf0ee6-e47c-46d0-a56d-6ccb84627358</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;My colleague Stefan is working on this case so he will assist you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sampling ADC with two sampling frequency alternately....</title><link>https://devzone.nordicsemi.com/thread/63594?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2016 11:12:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbab4dc7-f82c-495a-a5af-670ebe534b18</guid><dc:creator>Ankush</dc:creator><description>&lt;p&gt;Yes Sure I will test it. Thanks.&lt;/p&gt;
&lt;p&gt;Can you help to resolve one more issue written in following thread?
&lt;a href="https://devzone.nordicsemi.com/question/95105/nus-uart-data-handler-issue/."&gt;devzone.nordicsemi.com/.../.&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sampling ADC with two sampling frequency alternately....</title><link>https://devzone.nordicsemi.com/thread/63593?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2016 10:28:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fa63408-19ec-49e1-b7be-5827f991d946</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;The uninit looks fine to me, but be sure to test it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sampling ADC with two sampling frequency alternately....</title><link>https://devzone.nordicsemi.com/thread/63592?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2016 10:00:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27253b7d-4c2e-44b2-81ff-b383a8ee10b7</guid><dc:creator>Ankush</dc:creator><description>&lt;p&gt;Hi Ole,&lt;/p&gt;
&lt;p&gt;Thanks for your reply. This what I wanted. Right now I am trying to use following uninitialized function, which giving me the desired results. This is the function that I am using--&amp;gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    void saadc_sampling_event_uninit(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_ppi_channel_free(m_ppi_channel);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_disable(&amp;amp;m_timer);

    nrf_drv_timer_uninit(&amp;amp;m_timer);

    nrf_drv_ppi_uninit();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this wright?&lt;/p&gt;
&lt;p&gt;But I will try to use new approach specified by you. Thanks once again for your answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sampling ADC with two sampling frequency alternately....</title><link>https://devzone.nordicsemi.com/thread/63591?ContentTypeID=1</link><pubDate>Mon, 26 Sep 2016 08:52:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8b52c9c-ae91-4602-bf72-137d5b5ec310</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Calling &lt;code&gt;saadc_sampling_event_init()&lt;/code&gt; multiple times will not work. Every time you call &lt;code&gt;saadc_sampling_event_init()&lt;/code&gt; you will try to initialize ppi and timer module again which will return an error code, which will make the application stop because of &lt;code&gt;APP_ERROR_CHECK(err_code)&lt;/code&gt;. Even if you fix this you will also allocate new PPI channel every time, and eventually you will run out of PPI channels. &lt;strong&gt;So don&amp;#39;t call &lt;code&gt;saadc_sampling_event_init()&lt;/code&gt; multiple times&lt;/strong&gt; (unless you implement a proper uninit function).&lt;/p&gt;
&lt;p&gt;What you can do is to change the compare value of the timer with the &lt;code&gt;nrf_drv_timer_extended_compare(..)&lt;/code&gt; function. Be aware though that if you don&amp;#39;t stop and clear the timer first, the timer may miss the compare event (the current value of the timer may be larger than the new compare value) and count until it overflows. You can avoid this by updating with stop, clear and resume like this (sets the compare value to 400ms or 2.5Hz):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_timer_pause(&amp;amp;timer);
nrf_drv_timer_extended_compare(&amp;amp;timer, (nrf_timer_cc_channel_t)0, 400 * 1000UL, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
nrf_drv_timer_clear(&amp;amp;timer);
nrf_drv_timer_resume(&amp;amp;timer);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or you can do it with disable and enable:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_timer_disable(&amp;amp;timer);
nrf_drv_timer_extended_compare(&amp;amp;timer, (nrf_timer_cc_channel_t)0, 400 * 1000UL, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
nrf_drv_timer_enable(&amp;amp;timer);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>