<?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>SAADC callback</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20928/saadc-callback</link><description>I have this working and producing good and accurate results, but I&amp;#39;m still puzzled by some of the examples in the SDK and the documentation. 
 I am using the processor to call for the saadc sample (i.e, not ppi) and I set the nrf_drv_saadc_buffer_converts</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Jun 2017 07:16:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20928/saadc-callback" /><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81750?ContentTypeID=1</link><pubDate>Mon, 19 Jun 2017 07:16:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89ec9974-a5dd-4fc9-9a1f-5d473842fa93</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, you are correct.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81751?ContentTypeID=1</link><pubDate>Sat, 17 Jun 2017 13:18:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db50ba03-34f3-4106-8097-9fc9033fd86f</guid><dc:creator>JisongXie</dc:creator><description>&lt;p&gt;Hi, Jorgen, I want to ask whether you mean that&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;read samples and fill in the buffer[0] ---&amp;gt; 2. buffer[0] is full and callback, but the sample is not stop and it fill in the buffer[1]  ---&amp;gt; 3. the callback has been done, while maybe the buffer[1] hasn&amp;#39;t been full ----&amp;gt; 4. the buffer[1] is full and callback, but the sample is not stop and it fill in the buffer[0] ---&amp;gt;&amp;gt;
Am I right?? Thank you very much!&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81755?ContentTypeID=1</link><pubDate>Tue, 02 May 2017 09:35:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8391fe19-7905-4fce-9849-f21d101e1ef0</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;Yess, when B and C are floating and a tension in channel A, I have unstable reading in the channel B when I set a tension in the channel A, when I set a tension in channel B, I have unstable reading in channel C, when I set tension in the channel C, I dont have instable reading o_O.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81754?ContentTypeID=1</link><pubDate>Tue, 02 May 2017 09:31:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19e7eedd-623c-4d0b-bff2-211d85c9756e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If you have not connected channel B it will be floating, giving you unstable reading. What are you trying to achieve with this? Are you getting wrong reading if you connect the channel before measurement?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81757?ContentTypeID=1</link><pubDate>Tue, 02 May 2017 09:30:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:440b42ac-0947-4b41-b0b8-b9fdffc61583</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;there is my callback :&lt;/p&gt;
&lt;p&gt;void adcHandler(nrf_drv_saadc_evt_t const *p_event)
{
if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
{
nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAMPLES_IN_BUFFER);&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;            adc_result = p_event-&amp;gt;data.done.p_buffer[0];
            ptrFcnArray[0](adc_result); // Function which handles result in channel 0.
        
            adc_result = p_event-&amp;gt;data.done.p_buffer[1];
            ptrFcnArray[1](adc_result); // Function which handles result in channel 1.           

            adc_result = p_event-&amp;gt;data.done.p_buffer[2];
            ptrFcnArray[2](adc_result); // Function which handles result in channel 2.
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81756?ContentTypeID=1</link><pubDate>Tue, 02 May 2017 09:27:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dfb5e12-cfad-4fe7-9872-45b90f2c86a1</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;That&amp;#39;s what I&amp;#39;m testing actually, the problem that I have a static error in one or ther channel, if I set for example 3.3 V in channel A, I have about 1.2V in the channel B, i the time the B channel is not connected :/&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81753?ContentTypeID=1</link><pubDate>Tue, 02 May 2017 09:25:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d127509-d8dc-4c7b-91fa-f73a9f5e340b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, this is correct.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81752?ContentTypeID=1</link><pubDate>Tue, 02 May 2017 09:20:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44ae68c2-6e1a-4745-bdf7-8c00cfdf4312</guid><dc:creator>acha</dc:creator><description>&lt;p&gt;Hello all,
I have question about buffer filling, if there is multiple channels initialized for conversion, that&amp;#39;s means that p_event-&amp;gt;data.done.p_buffer[0] contains the converted value for first channel enabled, p_event-&amp;gt;data.done.p_buffer[1] for the second one, and p_event-&amp;gt;data.done.p_buffer[2] for the third one?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81749?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 12:36:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e4bdec6-2598-4dde-b04d-77c1c445ff39</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;In this example if should not matter, as there is only one channel active, space for 5 samples in each buffer, and a sampling rate of once every 400ms. Due to the double buffering, the second buffer will be used for sampling when the first buffer is full. The data in the buffer will not be erased, as it only use a pointer to the memory location, and it will neither be overwritte until the second buffer is full, meaning 2 seconds after you get the callback, leaving you plenty time to read the buffer. In a more high-speed sample application, I would suggest reading the buffer before setting it up for conversion again to avoid loss of samples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81748?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 10:26:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ef4e574-8837-4461-afd2-4ac89cc09fbd</guid><dc:creator>RichieJH</dc:creator><description>&lt;p&gt;Ok, thanks.  So am I correct in thinking that the reason it is fine to set up that buffer again before reading the data in the buffer is that it won&amp;#39;t be overridden until a sample is triggered once more?  So setting up the buffer could be done either before or after reading the data in the buffer?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC callback</title><link>https://devzone.nordicsemi.com/thread/81747?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 09:37:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1234e96a-f12b-4acd-addc-7711ae05cdb6</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The SAADC of nRF52 &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/hardware_driver_saadc.html?cp=4_0_0_2_11_1_1#saadc_nonblocking"&gt;support double buffering&lt;/a&gt;, meaning you can have two buffers setup for conversion where one is processed while the other is used for sampling.&lt;/p&gt;
&lt;p&gt;When you call&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you setup two buffers.&lt;/p&gt;
&lt;p&gt;When one of the buffers is full, you will get a callback. You now have to setup the buffer for sampling again, if not, your application will not have a buffer available for sampling.&lt;/p&gt;
&lt;p&gt;The reason the first argument is &lt;code&gt;p_event-&amp;gt;data.done.p_buffer&lt;/code&gt; is that this is a pointer to the buffer that is full and caused the callback. By using this as the argument, the same buffer will be setup for conversion.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>