<?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 pins switch</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16358/saadc-pins-switch</link><description>Hi, 
 I use the SAADC to sample 2 pins. I use the nrf_drv_saadc, and a timer to call the sample task. 
 I was trying out several gains for SAADC and I noticed that for gains 1 and 2 (4 not tested), the output buffer switched around the results of the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Feb 2017 10:37:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16358/saadc-pins-switch" /><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62591?ContentTypeID=1</link><pubDate>Mon, 20 Feb 2017 10:37:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45be813d-3ee8-4728-955b-bc7c50279864</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;So you sample 200 values and if you print them in main&amp;#39;s context then you see the channel order switching  from sample to sample but sometimes only every 10th sample? Or are you  sampling while you print the samples?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62587?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2017 14:31:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57455f09-5dcd-4df8-93ae-b620adccbdca</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Btw: the more values i print on uart, the more often it switches (testing without pan28 workaround now). Printing on the mainthread, not in the interrupt fyi. Currently i print the first 5 values (of 200) and then it toggles every 1 to 10 batches.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62574?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2017 14:02:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2a66877-a4a2-4478-b3ec-b98149f392a4</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Without the pan28 workaround, it switches (most of the times) right at boot, and then it switches sporadically. This switch, however, is persistent. As in, it switches the pins around permanently until another switch happens.
With the pan28 workaround, it only now and then switches 1 or 2 samples, mostly after connect.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62586?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2017 13:33:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72e64b19-257e-47c8-84e1-5a8ca95222a4</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;The SAADC uses EasyDMA to store the sampled values in RAM so SoftDevice activity should not affect the measurements. When do you see the issue when the PAN 28 workaround is disabled? Just sporadically?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62576?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2017 13:01:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c4d9e13-cf1d-47e7-bea0-ed237fc2a611</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;That&amp;#39;s what i read too =] That&amp;#39;s why i&amp;#39;m puzzled by this behaviour. Maybe because the softdevice is busy with higher priority interrupts? With the pan28 workaround enabled, i saw it happening mostly after connects.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62590?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2017 12:42:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5168eb4d-c5bf-4fab-9754-7aeb0fe3e3e5</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;The maximum sampling frequency of the SAADC is 200kHz, i.e. one sample per 5us, so you should be fine at 200us.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62589?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2017 12:01:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78cfcc28-18ca-479d-961a-df04a170ce86</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Yes, as in &lt;a href="https://github.com/crownstone/bluenet/blob/master/src/drivers/cs_ADC.cpp"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62588?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2017 11:54:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a761fdc-5783-4380-ade6-ae933f8d3d29</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;That might be an issue. How are you calling the sample task? Are you using PPI or one of the TIMER peripherals?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62585?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2017 08:25:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5f4038a-e2d3-42d6-8804-dd706a0a44d6</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Btw: can it be that the SAMPLE task is called before the previous sample was done? I&amp;#39;m sampling with an interval of 200μs, and since it&amp;#39;s pretty much random when it happens, i suspect a timing issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62575?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 15:25:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce831165-90b5-4eda-8f1d-b0f0f61059d3</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;The PANs are defined &lt;a href="https://github.com/crownstone/bluenet/blob/master/arm.toolchain.cmake"&gt;here&lt;/a&gt; and the ADC_IRQHandler was indeed never renamed, but that&amp;#39;s done by nrf51_to_nrf52.h. I don&amp;#39;t know of anything that implements all workarounds, currently we only implemented the PAN 12 workaround and the PAN 28 workaround is implemented in the nrf_drv_saadc.c.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62573?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 15:07:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65adc716-b5ef-4708-a16e-3d4d61e283ce</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Yes, something like that file, where all the workarounds for PANs are implemented and ran during startup. However, the file you linked to appears to be for the nRF51 as it refers to the ADC and not the SAADC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62577?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 14:33:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3de77856-5b3e-4d4a-8da3-d3ce123504ab</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;With the PAN define removed, it switched around the pins in the whole batch after a few batches.&lt;/p&gt;
&lt;p&gt;Regarding the family pack, I think we&amp;#39;re not using those files at all. Our build setup is rather different. Maybe &lt;a href="https://github.com/crownstone/bluenet/blob/master/src/cs_sysNrf51.c"&gt;this file&lt;/a&gt; contains what you&amp;#39;re looking for?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62581?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 14:15:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8c07a00-b309-4e81-b256-ca838bd58e81</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;QFAAB0 is a revision 1 chip and should not have Anomaly 28. If you remove the NRF52_PAN_28 define from your preprocessor symbols, does the issue happen more often? Could you also check which version of the nRF_NordicDeviceFamilyPack you are using ( i.e.e arm_startup.s and system_nrf52.c )?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62584?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 13:54:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25cbd2b8-04ef-4d38-a0a4-d0bbab1a345d</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Btw, pin switching now still seems to happen, but less often (every few minutes or so) and not the whole buffer. Either two samples are switched around, or one pin is sampled 3 times in a row.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62583?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 13:44:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e9110ca-9cdd-48d8-8e33-0660bf106096</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Sorry, the board i&amp;#39;m testing it on is: PCA10040 V1.1.0 2016.16. Chip: QFAAB0 1608AF.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62582?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 13:40:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3900270-53ea-4485-83f5-3a88aab03838</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Board: PCA10040 V1.1.0 2016.17. Chip: QFAAB0 1611AN&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62580?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 13:32:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d4878f8-5806-4a72-a263-a4b157d0b8e4</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Bart, which version of the PCA10040 are you using? Can you also provide the chip marking of the nRF52832 IC on the PCA10040?  You are correct that the PCA10040 should not have this issue as the different versions use the Engineering B (PCA10040 v0.9.0), Engineering C(PCA10040 v1.0.0) and revision 1(PCA10040 v1.1.x). &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.EngA.errata/anomaly_832_28.html?cp=2_2_1_3_1_19"&gt;Anomaly 28&lt;/a&gt; (aka [28] SAADC: Scan mode is not functional for some analog inputs) was only present in Engineering A versions and was fixed in Eng. B.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62579?ContentTypeID=1</link><pubDate>Tue, 14 Feb 2017 12:53:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a11d021e-a285-48cc-a590-d7d1be7495db</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;See updated answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62578?ContentTypeID=1</link><pubDate>Mon, 13 Feb 2017 15:19:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94f06e68-9360-4b84-9107-3cc5fa27337a</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;So i&amp;#39;m still getting the same error. What i see now: it switches right after start, and then every now and then, it switches back for 1 batch of samples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62572?ContentTypeID=1</link><pubDate>Mon, 12 Dec 2016 09:25:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89f860d6-ba57-4b0b-8bae-10de7ab36e61</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Yeah, that would explain the strange behavior :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62571?ContentTypeID=1</link><pubDate>Fri, 09 Dec 2016 16:37:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2663423-c83e-43bf-b91a-e2878e480bb2</guid><dc:creator>bart</dc:creator><description>&lt;h3&gt;Update&lt;/h3&gt;
&lt;p&gt;Answered &lt;a href="https://devzone.nordicsemi.com/question/119588/offset-in-saadc-samples-with-easy-dma-and-ble/?answer=166673#post-id-166673"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Update&lt;/h3&gt;
&lt;p&gt;Looks like it&amp;#39;s fixed by defining NRF52_PAN_28, even though i&amp;#39;m on a PCA10040, which doesn&amp;#39;t have that PAN listed in the docs as far as i know.&lt;/p&gt;
&lt;p&gt;Note: The first sample in the batch is sometimes still incorrect.&lt;/p&gt;
&lt;h3&gt;Old answer&lt;/h3&gt;
&lt;p&gt;I may have found the bug: I used the pin number also as channel number, so in my case i initialized channel 1 and 2. So it was probably luck that it worked at all.
&lt;code&gt;nrf_drv_saadc_channel_init(pinNum, &amp;amp;channelConfig);&lt;/code&gt; should&amp;#39;ve been &lt;code&gt;nrf_drv_saadc_channel_init(channelNum, &amp;amp;channelConfig);&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62570?ContentTypeID=1</link><pubDate>Fri, 09 Dec 2016 16:19:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7f7f516-7fa0-47ce-aad1-2886c7ae4865</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Hm, now it suddenly happened while i made a small edit to some other part of the code.. Maybe it&amp;#39;s something completely different?
Edit: after reflashing the same code, the channels were switched back to normal again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62569?ContentTypeID=1</link><pubDate>Wed, 07 Dec 2016 12:56:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:090b56b4-5a08-4042-a582-73050d208d91</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Yep, now the channels are as expected for gains 1 and 1_2, while 1_4 and 1_6 invert them. Which is again different than what i had in the first post, might be because i now have a different piece of hardware.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62568?ContentTypeID=1</link><pubDate>Thu, 01 Dec 2016 15:29:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ce21d6c-c5a0-40d0-a72b-f259db90da53</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Yes, please do that. Let me know if you&amp;#39;re still seeing this issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC pins switch</title><link>https://devzone.nordicsemi.com/thread/62566?ContentTypeID=1</link><pubDate>Wed, 30 Nov 2016 15:25:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7bd054af-d0ae-43b6-bb9d-7072230f716a</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Hmm, i&amp;#39;m guessing the link was wrong, as we moved the repo to another account and this branch now doesn&amp;#39;t exist anymore :) Here&amp;#39;s a more permanent link: &lt;a href="https://github.com/crownstone/bluenet/blob/724cb24cf10b6d9eba8671101a4195ddd0d85865/src/drivers/cs_ADC.cpp"&gt;github.com/.../cs_ADC.cpp&lt;/a&gt;
I will test out this code later and let you know if it still happens.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>