<?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>Read ADC based on particular delay</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37395/read-adc-based-on-particular-delay</link><description>Hi all, 
 I am using SDK version 15, SES IDE. 
 I am working on Dust sensor, for that i am using SAAADC example code, I want to read the ADC value from the pin, like this: 
 nrf_gpio_pin_write(17,1); 
 ADC_read_pin from channel1 within this delay(below</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Aug 2018 10:34:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37395/read-adc-based-on-particular-delay" /><item><title>RE: Read ADC based on particular delay</title><link>https://devzone.nordicsemi.com/thread/144132?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 10:34:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:681adf2f-1186-4015-9df6-9c76da8ab150</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Yes.&lt;/p&gt;
&lt;p&gt;But you still need to get familiar with how the ADC works. Setting the pin is not too difficult. You can see the pin_int_change example on how to change pins easily.&lt;/p&gt;
&lt;p&gt;I attached a project which reads the ADC pin on a buttonpress on Button1 on the DK. Note that you have to press the button 5 times to get the sample&amp;nbsp;done event. This is because the SAADC buffer has 5 elements. If you reduce the size of this to 1, you should get the event on every buttonpress. You can see how you can call nrfx_saadc_sample(). The button handler also toggles a pin. If you change it to set the pin to high in the button handler, and low in the saadc callback, you are almost there.&lt;/p&gt;
&lt;p&gt;The example is made in Keil, SDK15.0.0. You should be able to run it in SES as well, but you might need to include the saadc files in your IDE (segger embedded studio).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-0bf966e8a1d84b35a8d207345f1d7417/saadc_5F00_pin_5F00_int_5F00_change.zip"&gt;devzone.nordicsemi.com/.../saadc_5F00_pin_5F00_int_5F00_change.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What you need to do is to use a timer to get your delay. nrf_delay_us() is not recommended, as it keeps the CPU awake. Look into the app_timer library. You probably also need to store the value from the saadc callback function, if you want to use it at a later point in time. Just store it in a variable in your main.c file.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read ADC based on particular delay</title><link>https://devzone.nordicsemi.com/thread/144124?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 10:01:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:381e4ae0-5223-488b-992f-e67ba60b2a56</guid><dc:creator>Kashinath</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think u didn&amp;#39;t get my question, actually that 17th pin write is necessary for my application,&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_gpio_pin_write(17,1);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_delay_us(320); ---------&amp;gt;within this delay time only have to read ADC pin then only will get sensor data&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_gpio_pin_write(17,0);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;First thing i have to write 17th pin as 1, then 320us delay(within this delay time have to read ADC pin) and finally 17th pin have to make 0, this has to be in loop for continuous monitor.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kashinath&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read ADC based on particular delay</title><link>https://devzone.nordicsemi.com/thread/144116?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 09:27:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c62ccd6-f022-4341-9bd7-e84f19d07577</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Things are a bit different when you use the SDK. I suggest that you take a look at the SAADC example in SDK15 (which you can find &lt;a href="http://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/" target="_blank" rel="noopener noreferrer"&gt;here&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read ADC based on particular delay</title><link>https://devzone.nordicsemi.com/thread/144091?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 08:05:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c85418e-397e-444a-bb5f-7b72ed1ae623</guid><dc:creator>Kashinath</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;I am not using any Arduino board, just i am referring this code, so i want to write code according to attached&amp;nbsp; file, so just keep it for reference, so suggest for the same.I have to write the same code for Nordic nrf52810, in SAADC example SDKv15&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Kashinath&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read ADC based on particular delay</title><link>https://devzone.nordicsemi.com/thread/144071?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 07:08:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:577f6093-82f5-4254-ade4-7ed6b622be59</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t know you were using Arduino. What kind of board do you have? Do you have a site where you find your projects? I am not sure whether you can use the regular SDK. That depends on what programming chip that is on the board (if any).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read ADC based on particular delay</title><link>https://devzone.nordicsemi.com/thread/144045?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 05:29:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c9dcb68-700b-4fd7-affc-58b8464a274f</guid><dc:creator>Kashinath</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Thank you for your suggestion.Here i am attaching the application code for Dust sensor, actually i have to do like this:&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/dustSensor.ino"&gt;devzone.nordicsemi.com/.../dustSensor.ino&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kindly suggest me for this, till then i will also try with your suggestion.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Kashinath&amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Read ADC based on particular delay</title><link>https://devzone.nordicsemi.com/thread/143974?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 13:08:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47d3a14a-e40d-4f98-8b0d-85de5f2ee8d8</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Kashinath,&lt;/p&gt;
&lt;p&gt;The SAADC example, which I assume you have seen, uses a timer to trigger the samples.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to trigger a sample after 320µs, you can change the line in the saadc_sampling_event_init():&lt;/p&gt;
&lt;p&gt;uint32_t ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer, 400);&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;uint32_t ticks = nrf_drv_timer_us_to_ticks(&amp;amp;m_timer, 320);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then it will do one sample every 320µs.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is the pin toggle needed in your application, or is it only to see that it is happening?&lt;/p&gt;
&lt;p&gt;The reason I ask is because there is not application interrupt when the example trigger a sample. It uses the PPI to link the task_sample() function call to the timeout event. If you want the timeout event, you must call nrf_drv_timer_extended_compare() with &amp;quot;true&amp;quot; as the last parameter.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You will get the&amp;nbsp;saadc_callback every time the sample call has been called (and finished) N times, where N is the size of your SAADC buffer (=SAMPLES_IN_BUFFER).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>