<?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>Race condition with ADC driver</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60385/race-condition-with-adc-driver</link><description>There is a race condition in the SAADC driver when using buffer convert. 
 I am trying to drive ADC at maximum rate to sample 3 ADC channels, and so I call the following in the interrupt routine when it returns from completing an ADC and filling the first</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Apr 2020 12:03:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60385/race-condition-with-adc-driver" /><item><title>RE: Race condition with ADC driver</title><link>https://devzone.nordicsemi.com/thread/245518?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 12:03:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a32b7f8e-b4ce-4f71-a4ca-7e0383e0d053</guid><dc:creator>Malcolm</dc:creator><description>&lt;p&gt;Thank you for your response.&lt;/p&gt;
&lt;p&gt;I actually set up 3 separate channels to be sampled, and then I must process this data before sampling the same 3 channels again. I had a problem with Calibrate which was creating bogus samples, but this is fixed using the workaround in the errata sheet.&lt;/p&gt;
&lt;p&gt;The way the device works is to perform one sample on each channel and then give an interrupt. This is fine for my application, except the Calibrate was messing up the buffer and I went to one sample and tried to change the channel, which was the problem I reported her.&lt;/p&gt;
&lt;p&gt;Now I have fixed Calibrate, and realised I can use 3us and my application is acceptable.&lt;/p&gt;
&lt;p&gt;I could interleave sampling with double buffering but there is a feature in the SAADC driver that set SAADC status to idle after checking a STOP condition, which is required as the workaround for calibrate.&lt;/p&gt;
&lt;p&gt;As the application now works reasonably well, I am happy to leave as is.&lt;/p&gt;
&lt;p&gt;Malcolm&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Race condition with ADC driver</title><link>https://devzone.nordicsemi.com/thread/245499?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 11:23:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe77f728-7ab5-4ffc-b9d3-0854c4d05504</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;There are two issues here:&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You say you want the maximum sample rate, but you use a buffer that only holds a single sample for each adc channel, you need to increase to a more suitable number, otherwise, you will have a massive CPU overhead between each sample.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Why do you not use a TIMER and PPI to control the sample rate instead of triggering each sample manually via the CPU?&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Do you mind sharing more information on what you want to achieve with the adc?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>