<?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 with</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50555/saadc-with</link><description>I need to measure with SAADC two channels in the same time (NRF_SAADC_INPUT_AIN6 and NRF_SAADC_INPUT_AIN4). 
 Is possible ? 
 Have you an code example? 
 Thanks 
 Marco</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Mar 2020 09:31:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50555/saadc-with" /><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/238744?ContentTypeID=1</link><pubDate>Mon, 09 Mar 2020 09:31:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58e39613-324d-4de9-b6ac-49ccd277cae8</guid><dc:creator>John Smith</dc:creator><description>&lt;p&gt;The solution I proposed is different than your code in that it keeps the same channel_config, but alters the positive pin when init second channel. It&amp;#39;s very possible that this doesn&amp;#39;t solve your issue, but it solved mine.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for sending the code segment with your solution&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/238742?ContentTypeID=1</link><pubDate>Mon, 09 Mar 2020 09:24:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:132c6d5f-50e6-4cb3-8a1c-427132023d62</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;Your code seem same at my old inizialization. When did not work. The problem is connected to the interrupt.&lt;/p&gt;
&lt;p&gt;Now I&amp;#39;m on new project and is difficult to come back on this.&lt;/p&gt;
&lt;p&gt;But to resolve the problem I used the ADC without interupt. Waiting the end of conversion for each cannel. The time lost between the 2 conversion is abot 30 uS.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    err_code = nrf_drv_saadc_channel_uninit(0);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config_PULSE);
    APP_ERROR_CHECK(err_code);
    nrfx_saadc_sample_convert(0, &amp;amp;value_1);
    adc_value_pulse = ADC_RESULT_IN_MILLI_VOLTS(value_1);      //
    if (adc_value_pulse&amp;gt;35000) adc_value_pulse=0;
    
    err_code = nrf_drv_saadc_channel_uninit(0);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config_INEX);
    APP_ERROR_CHECK(err_code);
    nrfx_saadc_sample_convert(0, &amp;amp;value_2);
    adc_value_inex = ADC_RESULT_IN_MILLI_VOLTS(value_2);      //
    if (adc_value_inex&amp;gt;35000) adc_value_inex=0;
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/238739?ContentTypeID=1</link><pubDate>Mon, 09 Mar 2020 09:07:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:441d03b5-e716-4b9c-ba21-6594dddc8e3e</guid><dc:creator>John Smith</dc:creator><description>&lt;p&gt;I&amp;#39;ve been playing around with this issue a bit today and I may have found a solution, but I have no clue why or how. I&amp;#39;d be interested to find out if it fixes your problem as well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My solution:&lt;/p&gt;
&lt;p&gt;Change saadc_init() to the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void saadc_init(unsigned char type)
{
    ret_code_t err_code;
    
    nrf_saadc_channel_config_t channel_config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN6);

    err_code = nrf_drv_saadc_init(NULL, saadc_PULSE_INEX_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config);
    APP_ERROR_CHECK(err_code);
    
    channel_config.pin_p = NRF_SAADC_INPUT_AIN4;
    err_code = nrf_drv_saadc_channel_init(1, &amp;amp;channel_config);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool_scann[0], SAMPLES_IN_BUFFER_SCANN);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool_scann[1], SAMPLES_IN_BUFFER_SCANN);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Can you try it and let me know if it fixes the issue? Or you are done with this project?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/238736?ContentTypeID=1</link><pubDate>Mon, 09 Mar 2020 08:51:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:745268ce-27a9-4b7a-ab99-5b41992aa38b</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;hi, John.&lt;/p&gt;
&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;Unfortunately I never found a solution&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The frequency of my saples are 2 mS. Each 2 mS I need to sample 2 channels.&lt;/p&gt;
&lt;p&gt;For now I set the ADC in order to make 2 different samples with one channel for time&lt;/p&gt;
&lt;p&gt;Marco&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/238733?ContentTypeID=1</link><pubDate>Mon, 09 Mar 2020 08:37:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:691d9853-2eab-4262-b5c7-872bcb18cf6f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ok. I assume you will be followed up in your new ticket. The engineer who is assigned to that case will probably be interested in knowing how you trigger the sampling of the ADC, and about what frequency you do that.&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: SAADC with</title><link>https://devzone.nordicsemi.com/thread/238729?ContentTypeID=1</link><pubDate>Mon, 09 Mar 2020 08:25:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84ebb20e-34e7-4f13-bee9-d9f8362164e6</guid><dc:creator>John Smith</dc:creator><description>&lt;p&gt;&amp;quot;&lt;span&gt;seem work but sametime in the buffer&amp;nbsp;&lt;/span&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;I find the values exchanged between channels&lt;/span&gt;&lt;/span&gt;&lt;span&gt;. WHY ?&lt;/span&gt;&amp;quot;.&lt;/p&gt;
&lt;p&gt;I seem to have this issue as well when I have more than 1 channel getting saadc values. I explain more thoroughly in my question:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/58861/saadc-multiple-channel-buffer-inconsistencies"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/58861/saadc-multiple-channel-buffer-inconsistencies&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/238719?ContentTypeID=1</link><pubDate>Mon, 09 Mar 2020 08:02:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:124463e8-26dd-4275-b7cc-a66a7bad8d6d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Can you elaborate? What exactly is your issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/238684?ContentTypeID=1</link><pubDate>Sun, 08 Mar 2020 22:57:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbcbe6b0-dabe-44df-856b-8166bdd96c8d</guid><dc:creator>John Smith</dc:creator><description>&lt;p&gt;Anyone find a solution to this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203958?ContentTypeID=1</link><pubDate>Wed, 14 Aug 2019 07:23:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76d7bfa2-89e6-4eac-bbc9-e647d1cf74ad</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;Thank Edvin ! D&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;ifficult to find help in mid-August&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Yes I need to measure both channels at the same time (AIN4 and AIN6)&lt;/p&gt;
&lt;p&gt;If I enable only one channel all is perfect, if I anable 2 channel sometimes I have the swap.&lt;/p&gt;
&lt;div class="text-wrap tlid-copy-target"&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;I completely agree with you that the problem is that the micro is too busy&lt;/span&gt;&lt;/span&gt;&lt;span class="tlid-translation-gender-indicator translation-gender-indicator"&gt;&lt;/span&gt; (Soft device enabled, the micro send the data via BT, LPCOMP enabled, ADC enabled). &lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;I dont use PPI.&amp;nbsp; Into the LPCMP event I ask one conversion and wait the evet done. SO I ask, in one LPCOMP event, one value from AIN4 and one value from AIN6 (in the same time).&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;The maximum frequency of LPCOMP event is 800 uS (0,8 mS).&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;But the problem appear also at low frequency (20 mS).&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;For now I heve resolve the problem with 2 single conversion with about 20 uS of delay between the two conversions.&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;Thank very mutch for your help&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;Marco&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;&lt;/div&gt;
&lt;div class="result-shield-container tlid-copy-target"&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203950?ContentTypeID=1</link><pubDate>Wed, 14 Aug 2019 06:51:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a0bc0b9-8f51-4f9d-b205-14add2d3fff0</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Marco,&lt;/p&gt;
&lt;p&gt;Ok. I think I understand. Does this happen when you disable and enable the different channels? I am sorry to ask the same questions over and over, but I try to think of why this may happen. I still don&amp;#39;t think it is exactly the same as in the ticket that you link to, and I hope that it isn&amp;#39;t, because there is really no good solution to that issue.&lt;/p&gt;
&lt;p&gt;So the reason why you disable and enable the channels is that you want to measure on different times, is that correct? Or do you intend to measure them at the same time?&lt;/p&gt;
&lt;p&gt;Because when you have two ADC channels, and you trigger the scan, it will scan both channels one after the other (because there is only one physical ADC on the chip).&lt;/p&gt;
&lt;p&gt;What I suspect is happening is that you are triggering the scan via CPU interrupts, the interrupts are too fast for the CPU to handle all, so some of them are skipped. What I suggest is that you try to use the PPI to trigger the interrupts, which is more efficient, and you may not miss any of the events.&lt;/p&gt;
&lt;p&gt;Now, the reason that the positions swap is that the buffer isn&amp;#39;t aware of how many channels, or which channel the interrupts are coming from. This is not a problem if you only use one channel, but it is if you have more. If one sample is interrupted, it may happen that it scans twice on one channel, and then they will be swapped.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So: Do you disable/enable the channels? And have you tried triggering them via PPI? And do you need to measure at different points in time, or can you measure both channels at the same time?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203621?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2019 13:48:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:517e7a5a-5163-4f25-af7e-bdc5951b2196</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;maybe I can&amp;#39;t explain myself well&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The event of LPCOM is only on 1 signal.&lt;/p&gt;
&lt;p&gt;When this event start I need to scan both signals in the same time.&lt;/p&gt;
&lt;p&gt;In the buffer:&amp;nbsp; static nrf_saadc_value_t m_buffer_pool_scann[2][2];&lt;/p&gt;
&lt;p&gt;Normally I found in position 0 the first signal and in position 1 the second signal. And this is OK, all seem to work good.&lt;/p&gt;
&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;Sometimes during the acquisition of the signals I find the values exchanged&lt;/span&gt;&lt;/span&gt;, so in position 0 the second signal and in position 1 the first signal. &lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;This situation continues and then every once in a while it is reversed&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t understand. &lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;Other people on the web complain about this problem&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Marco&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203616?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2019 13:35:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e48555a-f750-47cf-88ce-89506aa81431</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry. I forgot to mention that if you have two channels that are enabled, the scan function will scan both channels. I wasn&amp;#39;t aware that you wanted to scan on different times based on two different input pulses.&lt;/p&gt;
&lt;p&gt;The ticket that you link to is not entirely the same. We have seen similar cases when they use the internal SAADC timer to trigger samples, when they are sampling very fast, and have several channels.&lt;/p&gt;
&lt;p&gt;If you want to measure on different times, you need to disable one channel at the time, like you do here.&lt;/p&gt;
&lt;p&gt;How does that behave? I am still a bit confused about your description.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Marco Pennacchietti"]&lt;span lang="en"&gt;&lt;span title=""&gt;I had forgotten to say&lt;/span&gt;&lt;/span&gt; that the correct value (thai is 0 in this buffer) is located with same offset in the other buffer (of the other signal)[/quote]
&lt;p&gt;&amp;nbsp;So how is your channels mixed up? Could you clarify?&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: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203567?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2019 11:58:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98aa2423-b52a-431c-bfa0-be4256195b24</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;Dear Edvin,&lt;/p&gt;
&lt;p&gt;the interrup is triggered on all fall edge. The LPCOM work perfectly and follow all edge.&lt;/p&gt;
&lt;p&gt;The ADC in scann mod, on 2 channels, work but some times the data are swapped into the doubble buffer.&lt;/p&gt;
&lt;p&gt;I have found other with my problem, see: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/16885/saadc-scan-mode-sample-order-is-not-always-consistent"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/16885/saadc-scan-mode-sample-order-is-not-always-consistent &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For now I have resolved using two call, each with only one channel ON.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config_PULSE);
    APP_ERROR_CHECK(err_code);
    nrfx_saadc_sample_convert(0, &amp;amp;value_1);
    adc_value_pulse = ADC_RESULT_IN_MILLI_VOLTS(value_1);      //
    if (adc_value_pulse&amp;gt;35000) adc_value_pulse=0;
    err_code = nrf_drv_saadc_channel_uninit(0);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config_INEX);
    APP_ERROR_CHECK(err_code);
    nrfx_saadc_sample_convert(0, &amp;amp;value_2);
    adc_value_inex = ADC_RESULT_IN_MILLI_VOLTS(value_2);      //
    if (adc_value_inex&amp;gt;35000) adc_value_inex=0;
    err_code = nrf_drv_saadc_channel_uninit(0);
    APP_ERROR_CHECK(err_code);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In this configuration all work good, also using 1 mS between two fall edge.&lt;/p&gt;
&lt;p&gt;the above code use 55uS for both channels.&lt;/p&gt;
&lt;p&gt;But this is not the correct solution. I hope to found the error in the scann mode configurations&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Marco&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203320?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 12:58:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1314f904-324a-44f9-bb61-89399d46c88f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;ok. so the issue is that the adc is not triggered on every fall on the input pulse, is that maybe the case?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The issue may be that you don&amp;#39;t have time for all interrupts. Either, they are too fast on it&amp;#39;s own, or there is a possibility that you don&amp;#39;t get the lpcomp interrupts (lpcomp_event_handler) in time, because the CPU is busy doing something else, such as handling one of the ADC events.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I suggest that you try to use PPI, like it is done in the example. It sets up a timer, and then uses the ppi to trigger the sampling on this event, rather than handling the timer interrupt using the CPU.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203310?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 12:40:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a7c13aa-cec9-4866-a476-cd43e3a92d1d</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;I have discovered now that when the data from ADC is swapped, t&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;his situation continues until I reset the system.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;In previus immage I stopped the debug at the first 0. The other values after the 0 are old values on the buffer&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203302?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 12:17:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cba86303-f75a-4b9d-8344-c983f50208fa</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;I had forgotten to say&lt;/span&gt;&lt;/span&gt; that the correct value (thai is 0 in this buffer) is located with same offset in the other buffer (of the other signal)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203299?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 12:12:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25269649-7d16-448a-9c93-a099e3f3e8ae</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;No, is impossible for me now.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void lpcomp_event_handler(nrf_lpcomp_event_t event)
{
  if (event == NRF_LPCOMP_EVENT_DOWN)
  {
      nrf_gpio_pin_set(PIN_P0_20_TP6);
          
      u_STATO10.STATO10_bit.mm_EOC = 0;
      nrf_drv_saadc_sample();
      while(!u_STATO10.STATO10_bit.mm_EOC);

      buff_I[puntIP]=adc_value_inex;
      buff_P[puntIP]=adc_value_pulse;
      puntIP++;
      if (puntIP&amp;gt;99)puntIP=0;

      nrf_gpio_pin_clear(PIN_P0_20_TP6);

    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I working on my target and I don&amp;#39; start a conversion with a timer but when a pulse arrive on AIN5.&lt;/p&gt;
&lt;p&gt;I trigger this event with a LPCOMP event DOWN on AIN5.&lt;/p&gt;
&lt;p&gt;I have tested it with the PO_20 test point and t&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;his event is perfectly synchronized with the AIN5.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;I have discovered that if the time between 2 conversion is more then 10 mS the error do not appear&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Report_2D002D00_00038.pdf"&gt;devzone.nordicsemi.com/.../Report_2D002D00_00038.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have send you my situation.&lt;/p&gt;
&lt;p&gt;In the report the signal RED is connected to AIN5 in order to generate an event on LPCOMP&lt;/p&gt;
&lt;p&gt;In BLU one of the 2 signal that I need to measure with the SAADC&lt;/p&gt;
&lt;p&gt;In yellow the signal PO_20 (test point) this signal go up when the evend LPCOMP down arrive and go down after the conversion (see my code above).&lt;/p&gt;
&lt;p&gt;In the buffer buff_I and buff_P I store my conversion and sometime I read a zero value instead the correct value. see file in attach.&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/3324.error.png" /&gt;&lt;/p&gt;
&lt;p&gt;Note that on the oscilloscope the signal BLU is always UP when the YELLOW signal arrive.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203287?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 11:41:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b96053fb-5939-4042-ab2b-86135d326979</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Can you test this one?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-4458410f6a404aa7b6850e988872735e/new_5F00_main.c"&gt;devzone.nordicsemi.com/.../new_5F00_main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t see that the values are swapped. Are they if you run the project with this main.c file?&lt;/p&gt;
&lt;p&gt;In your case, how do you determine that the values/channels are swapped?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203274?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 10:59:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50a49c7e-1987-4626-bee5-050670c0b087</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;Thank, but your file is exatly same at my code.&lt;/p&gt;
&lt;p&gt;I ask a conversion each 1 mS but sometime the vale are swapped.&lt;/p&gt;
&lt;p&gt;Marco&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203268?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 10:52:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f267cc5a-bfbb-4d65-9852-0b59f76122e6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Sorry. I meant the SAMPLES_IN_BUFFER define should be N * the numbers of channels you use.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know what chip or SDK version you use, but this is written in SDK15.3.0, and tested with nRF52832:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-4458410f6a404aa7b6850e988872735e/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203263?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 10:45:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eefad083-3aad-4c0b-b424-e31d5003c3c9</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;Then ?&lt;/span&gt; &lt;span title=""&gt;how to set it ?.&lt;/span&gt; &lt;span title=""&gt;I don&amp;#39;t understand&lt;/span&gt;&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;static nrf_saadc_value_t m_buffer_pool_scann[2][2]; This is NOT correct ?&lt;/p&gt;
&lt;p&gt;I use 2 channels. Could you tell me how ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203261?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 10:40:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e95bd70-0c2b-47a6-8cd5-51240acc0999</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Yes. The buffer isn&amp;#39;t aware of how many channels you use, so you should set the buffer equal to N * number of channels, N=0,1,2,3,... in order to always have the same channel on the same place in your buffer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203247?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 09:21:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc5d64a0-2ecc-47d0-8053-695f22baff43</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;&lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;I had forgotten to say&lt;/span&gt;&lt;/span&gt;:&lt;/p&gt;
&lt;p&gt;#define SAMPLES_IN_BUFFER_SCANN 2&lt;/p&gt;
&lt;p&gt;static nrf_saadc_value_t m_buffer_pool_scann[2][SAMPLES_IN_BUFFER_SCANN];&lt;/p&gt;
&lt;p&gt;Marco&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/203242?ContentTypeID=1</link><pubDate>Fri, 09 Aug 2019 09:18:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:908663a2-afd4-42f4-bec8-5ede3d38f547</guid><dc:creator>Marco Pennacchietti</dc:creator><description>&lt;p&gt;Dear, all.&lt;/p&gt;
&lt;p&gt;I have activated the second channel:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define NRFX_SAADC_PULSE_CHANNEL_CONFIG_SE(PIN_P) \
{                                                   \
    .resistor_p = NRF_SAADC_RESISTOR_DISABLED,      \
    .resistor_n = NRF_SAADC_RESISTOR_DISABLED,      \
    .gain       = NRF_SAADC_GAIN1_6,                \
    .reference  = NRF_SAADC_REFERENCE_INTERNAL,     \
    .acq_time   = NRF_SAADC_ACQTIME_3US,           \
    .mode       = NRF_SAADC_MODE_SINGLE_ENDED,      \
    .burst      = NRF_SAADC_BURST_DISABLED,         \
    .pin_p      = (nrf_saadc_input_t)(PIN_P),       \
    .pin_n      = NRF_SAADC_INPUT_DISABLED          \
}


#define NRFX_SAADC_INEX_CHANNEL_CONFIG_SE(PIN_P) \
{                                                   \
    .resistor_p = NRF_SAADC_RESISTOR_DISABLED,      \
    .resistor_n = NRF_SAADC_RESISTOR_DISABLED,      \
    .gain       = NRF_SAADC_GAIN1_6,                \
    .reference  = NRF_SAADC_REFERENCE_INTERNAL,     \
    .acq_time   = NRF_SAADC_ACQTIME_3US,           \
    .mode       = NRF_SAADC_MODE_SINGLE_ENDED,      \
    .burst      = NRF_SAADC_BURST_DISABLED,         \
    .pin_p      = (nrf_saadc_input_t)(PIN_P),       \
    .pin_n      = NRF_SAADC_INPUT_DISABLED          \
}

nrf_saadc_channel_config_t channel_config_INEX  = NRFX_SAADC_INEX_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN6);
nrf_saadc_channel_config_t channel_config_PULSE = NRFX_SAADC_PULSE_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN4);



void saadc_init(unsigned char type)
{
    ret_code_t err_code;

    err_code = nrf_drv_saadc_init(NULL, saadc_PULSE_INEX_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config_INEX);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_saadc_channel_init(1, &amp;amp;channel_config_PULSE);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool_scann[0], SAMPLES_IN_BUFFER_SCANN);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool_scann[1], SAMPLES_IN_BUFFER_SCANN);
    APP_ERROR_CHECK(err_code);
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;seem work but sametime in the buffer &lt;span class="tlid-translation translation" lang="en"&gt;&lt;span class="" title=""&gt;I find the values exchanged between channels&lt;/span&gt;&lt;/span&gt;. WHY ?&lt;/p&gt;
&lt;p&gt;this is my callback function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void saadc_PULSE_INEX_callback(nrf_drv_saadc_evt_t const * p_event)
{
  nrf_saadc_value_t adc_result;
  uint16_t value_mV_local;
  uint16_t value_mV_acc;
  int i;
 
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;
	
        err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAMPLES_IN_BUFFER_SCANN);
        APP_ERROR_CHECK(err_code);
                
        adc_result = p_event-&amp;gt;data.done.p_buffer[0];
        adc_value_inex = ADC_RESULT_IN_MILLI_VOLTS(adc_result);//+ DIODE_FWD_VOLT_DROP_MILLIVOLTS;
    
        adc_result = p_event-&amp;gt;data.done.p_buffer[1];
        adc_value_pulse = ADC_RESULT_IN_MILLI_VOLTS(adc_result);//+ DIODE_FWD_VOLT_DROP_MILLIVOLTS;
   }
 }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;with this code I ask a start of new conversion&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_drv_saadc_sample();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!u_STATO10.STATO10_bit.mm_EOC);&lt;/p&gt;
&lt;p&gt;the bit mm_EOC is for waiting the end of conversion. This is set in the callback with the event DONE.&lt;/p&gt;
&lt;p&gt;Marco&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC with</title><link>https://devzone.nordicsemi.com/thread/202140?ContentTypeID=1</link><pubDate>Fri, 02 Aug 2019 12:20:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51466500-fdef-452b-a746-37f8e4cd8b48</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;As &lt;a href="https://devzone.nordicsemi.com/members/awneil"&gt;awneil&lt;/a&gt; says, there is an example in the SDK which you can find in SDK\examples\peripheral\saadc.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This example only uses one pin, and one channel, but if you initialize another channel on a different pin, it will do sampling on both channels.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>