<?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 SAADC channels at different rate</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20858/sampling-saadc-channels-at-different-rate</link><description>There have been a couple of questions asked that are similar to my question but in the interest of getting more clarity I am asking a new one as others have had accepted answers. 
 The relevant questions are here and here 
 Essentially, using the scan</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Mar 2017 18:56:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20858/sampling-saadc-channels-at-different-rate" /><item><title>RE: Sampling SAADC channels at different rate</title><link>https://devzone.nordicsemi.com/thread/81452?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 18:56:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59ca3098-8d21-468b-8962-209a61721f41</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;As you see in the code, the buffer size is set to the 502 (addition of the two sample rates). The buffer will then be filled every second and you do not need to change it when enabling/disabling the second channel.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sampling SAADC channels at different rate</title><link>https://devzone.nordicsemi.com/thread/81454?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 13:44:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3435cab4-7679-4e32-b623-e1f39947a21c</guid><dc:creator>anasimtiaz</dc:creator><description>&lt;p&gt;Does the ADC buffer size needs to be changed when modifying PSELP in the rtc0_handler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sampling SAADC channels at different rate</title><link>https://devzone.nordicsemi.com/thread/81453?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 13:14:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f2f31ba-8de2-424f-8c59-3d9f5fdea3e0</guid><dc:creator>anasimtiaz</dc:creator><description>&lt;p&gt;Thanks for this. I am going to try and integrate this in my existing code and report back soon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sampling SAADC channels at different rate</title><link>https://devzone.nordicsemi.com/thread/81455?ContentTypeID=1</link><pubDate>Wed, 29 Mar 2017 12:21:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f9179a9-ce14-48a3-8c6d-1cc0f10933ff</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I will see if I can throw together an example. The below preudocode should show the concept and how it can be implemented:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define CHANNEL_0_SAMPLE_FREQUENCY 500
#define CHANNEL_1_SAMPLE_FREQUENCY 2

#define SAMPLES_IN_BUFFER CHANNEL_0_SAMPLE_FREQUENCY + CHANNEL_1_SAMPLE_FREQUENCY

uint32_t sample_count = 0;

void saadc_sample(){

    NRF_SAADC-&amp;gt;TASKS_START = 1;
    while (NRF_SAADC-&amp;gt;EVENTS_STARTED == 0);
    NRF_SAADC-&amp;gt;EVENTS_STARTED = 0;

    NRF_SAADC-&amp;gt;TASKS_SAMPLE = 1;
    while (NRF_SAADC-&amp;gt;EVENTS_END == 0);
    NRF_SAADC-&amp;gt;EVENTS_END = 0;
}

rtc0_handler()
{
	saadc_sample();
	
	if (sample_count == max(CHANNEL_0_SAMPLE_FREQUENCY,CHANNEL_1_SAMPLE_FREQUENCY)/min(CHANNEL_0_SAMPLE_FREQUENCY,CHANNEL_1_SAMPLE_FREQUENCY)-1)
	{
		NRF_SAADC-&amp;gt;CH[1].PSELP = SAADC_CH_PSELP_PSELP_AnalogInput1 &amp;lt;&amp;lt; SAADC_CH_PSELP_PSELP_Pos;
	}
	
	if(sample_count == max(CHANNEL_0_SAMPLE_FREQUENCY,CHANNEL_1_SAMPLE_FREQUENCY)/min(CHANNEL_0_SAMPLE_FREQUENCY,CHANNEL_1_SAMPLE_FREQUENCY))
	{
		NRF_SAADC-&amp;gt;CH[1].PSELP = SAADC_CH_PSELN_PSELN_NC &amp;lt;&amp;lt; SAADC_CH_PSELP_PSELP_Pos;
		sample_count = 0;
	}
	
	sample_count++;
}

saadc_init()
{

	// Configure SAADC channel 0 
	
	NRF_SAADC-&amp;gt;CH[0].CONFIG = (
		SAADC_CH_CONFIG_BURST_Enabled &amp;lt;&amp;lt; SAADC_CH_CONFIG_BURST_Pos |
		SAADC_CH_CONFIG_MODE_SE &amp;lt;&amp;lt; SAADC_CH_CONFIG_MODE_Pos |
		SAADC_CH_CONFIG_TACQ_10us &amp;lt;&amp;lt; SAADC_CH_CONFIG_TACQ_Pos |
		SAADC_CH_CONFIG_REFSEL_Internal &amp;lt;&amp;lt; SAADC_CH_CONFIG_TACQ_Pos |
		SAADC_CH_CONFIG_GAIN_Gain1_4 &amp;lt;&amp;lt; SAADC_CH_CONFIG_GAIN_Pos |
		SAADC_CH_CONFIG_RESN_Bypass &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESN_Pos |
		SAADC_CH_CONFIG_RESP_Bypass &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESP_Pos );

	NRF_SAADC-&amp;gt;CH[0].PSELP = SAADC_CH_PSELP_PSELP_AnalogInput0 &amp;lt;&amp;lt; SAADC_CH_PSELP_PSELP_Pos;
	NRF_SAADC-&amp;gt;CH[0].PSELN = SAADC_CH_PSELN_PSELN_NC &amp;lt;&amp;lt; SAADC_CH_PSELN_PSELN_Pos;
	
	// Configure SAADC channel 1, but leave it not connected
	
	NRF_SAADC-&amp;gt;CH[1].CONFIG = (
		SAADC_CH_CONFIG_BURST_Enabled &amp;lt;&amp;lt; SAADC_CH_CONFIG_BURST_Pos |
		SAADC_CH_CONFIG_MODE_SE &amp;lt;&amp;lt; SAADC_CH_CONFIG_MODE_Pos |
		SAADC_CH_CONFIG_TACQ_10us &amp;lt;&amp;lt; SAADC_CH_CONFIG_TACQ_Pos |
		SAADC_CH_CONFIG_REFSEL_Internal &amp;lt;&amp;lt; SAADC_CH_CONFIG_TACQ_Pos |
		SAADC_CH_CONFIG_GAIN_Gain1_4 &amp;lt;&amp;lt; SAADC_CH_CONFIG_GAIN_Pos |
		SAADC_CH_CONFIG_RESN_Bypass &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESN_Pos |
		SAADC_CH_CONFIG_RESP_Bypass &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESP_Pos );

	
	NRF_SAADC-&amp;gt;CH[1].PSELP = SAADC_CH_PSELP_PSELP_NC &amp;lt;&amp;lt; SAADC_CH_PSELP_PSELP_Pos;
	NRF_SAADC-&amp;gt;CH[1].PSELN = SAADC_CH_PSELN_PSELN_NC &amp;lt;&amp;lt; SAADC_CH_PSELN_PSELN_Pos;
	
	/* Number of Sample Count*/
    NRF_SAADC-&amp;gt;RESULT.MAXCNT = SAMPLES_IN_BUFFER;
}

rtc_init()
{
	// Configure RTC to run at sample rate of fastest SAADC channel 
}


main () 
{
	saadc_init();
	rtc_init();
	
	while(1)
	{
		// Make sure any pending events are cleared
		__SEV();
		__WFE();
		// Enter System ON sleep mode
		__WFE();  
	}
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>