<?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 double buffering not working</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50974/saadc-double-buffering-not-working</link><description>Hi, 
 I&amp;#39;m setting up SAADC as explained in the examples: First start conversions with buffer 0, then with buffer 1. On the SAADC callback I queue the current buffer for conversions again. 
 I&amp;#39;m working on an NRF52832 using SDK15.2. 
 
 
 When I start</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 16 Jan 2022 08:10:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50974/saadc-double-buffering-not-working" /><item><title>RE: SAADC double buffering not working</title><link>https://devzone.nordicsemi.com/thread/347877?ContentTypeID=1</link><pubDate>Sun, 16 Jan 2022 08:10:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee8c7d8d-c500-4416-ad2a-e7a799c23796</guid><dc:creator>juulee</dc:creator><description>&lt;p&gt;Hello, I&amp;#39;m on the same problem now...&lt;/p&gt;
&lt;p&gt;Double buffering doesn&amp;#39;t work except the initial state.&lt;/p&gt;
&lt;p&gt;How did you fix the problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC double buffering not working</title><link>https://devzone.nordicsemi.com/thread/204038?ContentTypeID=1</link><pubDate>Wed, 14 Aug 2019 11:17:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a7fd30e-15c0-4692-ad2f-1063b03adea4</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;Ok, the problem was that I was triggering the calibration task directly without using the driver and that was bringing the driver into an unwanted state.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC double buffering not working</title><link>https://devzone.nordicsemi.com/thread/204027?ContentTypeID=1</link><pubDate>Wed, 14 Aug 2019 10:40:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fcbc71a-ea2f-4d63-9996-ea27db1e4d44</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;Ok, I tracked the issue down and I found a bug in the NRFX SAADC module. The issue happens when you setup everything for double buffering, but the ADC actually finishes the queued conversion before queueing the new conversion in the callback. See the logs below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ADC samples[0] pointer = 0x20005EE4
ADC samples[1] pointer = 0x2000613C

Channel initialized: 0.

// First call
Function: nrfx_saadc_buffer_convert, p_buffer: 0x20005EE4
Function: nrfx_saadc_buffer_convert, buffer length: 5, active channels: 1.
Function: nrfx_saadc_buffer_convert, error code: NRF_SUCCESS.

// Second call
Function: nrfx_saadc_buffer_convert, p_secondary_buffer: 0x2000613C
Function: nrfx_saadc_buffer_convert, error code: NRF_SUCCESS.

// NRFX SAADC IRQ handler end of conversion in buffer at 0x20005EE4
Event: NRF_SAADC_EVENT_END.
Copied p_secondary_buffer into p_buffer = 0x2000613C
Triggering START task from IRQ handler - p_buffer = 0x2000613C

// Pointer returned to my user callback
Current buffer pointer = 0x20005EE4

// Convert call from my user callback - properly setting up the secondary buffer
Function: nrfx_saadc_buffer_convert, p_secondary_buffer: 0x20005EE4
Function: nrfx_saadc_buffer_convert, error code: NRF_SUCCESS.

// NRFX SAADC IRQ handler end of conversion in buffer at 0x2000613C
Event: NRF_SAADC_EVENT_END.
Copied p_secondary_buffer into p_buffer = 0x20005EE4
Triggering START task from IRQ handler - p_buffer = 0x20005EE4

// Pointer returned to my user callback
Current buffer pointer = 0x2000613C

// Convert call from my user callback - no longer setting up the secondary buffer
Function: nrfx_saadc_buffer_convert, p_buffer: 0x2000613C
Function: nrfx_saadc_buffer_convert, buffer length: 5, active channels: 1.
Function: nrfx_saadc_buffer_convert, error code: NRF_SUCCESS.

// NRFX SAADC IRQ handler end of conversion in buffer at 0x20005EE4
Event: NRF_SAADC_EVENT_END.
IRQ handler - Secondary buffer NULL

//----------
// BUG HERE
//----------
// Pointer returned to my user callback - wrong pointer, should be 0x20005EE4
Current buffer pointer = 0x2000613C

// Convert call from my user callback - starting conversion on the wrong buffer, because a wrong pointer was returned
Function: nrfx_saadc_buffer_convert, p_buffer: 0x2000613C
Function: nrfx_saadc_buffer_convert, buffer length: 5, active channels: 1.
Function: nrfx_saadc_buffer_convert, error code: NRF_SUCCESS.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll post the fix as soon as I figure out how to fix it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>