<?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>nRF52 SAADC Continuous sampling</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59281/nrf52-saadc-continuous-sampling</link><description>Hello Dev Zone. 
 thanks for watching mt ask. 
 
 I need help. 
 I have 2 question. 
 
 1. I need use saadc continuous sampling 
 in SDK example, is it continuous Mode? 
 it looks like simple tesk Mode call by timer int every time. 
 
 if i set saadc</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Mar 2020 06:24:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59281/nrf52-saadc-continuous-sampling" /><item><title>RE: nRF52 SAADC Continuous sampling</title><link>https://devzone.nordicsemi.com/thread/241261?ContentTypeID=1</link><pubDate>Tue, 24 Mar 2020 06:24:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78cbee35-2ee4-4d1f-ba8d-689dd7f81531</guid><dc:creator>Empe</dc:creator><description>&lt;p&gt;Hello, Karl.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks very much.&lt;/p&gt;
&lt;p&gt;now i&amp;#39;m solve all problem and working well.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/59281/nrf52-saadc-continuous-sampling/241207"]Is there a specific reason for why you would like to manipulate the registers directly, instead of using the SAADC driver?[/quote]
&lt;p&gt;this is why now i&amp;#39;m try to porting the function to another platform,&lt;/p&gt;
&lt;p&gt;however&amp;nbsp;SDK example is not working well in there.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;that&amp;#39;s why need to understand register and working process.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Empe.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SAADC Continuous sampling</title><link>https://devzone.nordicsemi.com/thread/241207?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 15:49:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b94d013f-2c5e-42ef-b93c-ce09234704c2</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Empe,&lt;/p&gt;
[quote user="Empe"]Thanks for kind reply.[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
&lt;p&gt;[quote user="Empe"][/quote]&lt;/p&gt;
&lt;p&gt;That&amp;#39;s why my code is not work well.&lt;/p&gt;
&lt;p&gt;I need study more about &amp;quot;PPI&amp;quot;. Thanks.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, that might be the reason. Let me know if this resolves your issue!&lt;br /&gt;If you want to read more about PPI, &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fppi.html"&gt;you could do so here&lt;/a&gt;. PPI is really just a way to connect two peripherals so that they may function together, without requiring CPU intervention at every sample. What you would like to do is to connect a timer to your SAADC, using PPI. That way, the SAADC will continuously work in the background.&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/nrf_dev_saadc_example.html"&gt;The SAADC example&lt;/a&gt; demonstrates how you can connect a timer to your SAADC using PPI.&lt;/p&gt;
[quote user="Empe"]if i don&amp;#39;t pointed next buffer, DMA will overwrite&amp;nbsp;data&amp;nbsp;automatic to buffer that before pointed? or Stop to converting?[/quote]
&lt;p&gt;If the buffer is filled up, then the&amp;nbsp;&lt;em&gt;NRF_SAADC_EVENT_END&amp;nbsp;&lt;/em&gt;event is triggered and you will stop converting, since there is no more space to store samples in.&lt;br /&gt;The pointer will NOT reset to the start of the buffer by itself, you will have to do this yourself if you want this to happen.&lt;br /&gt;However, if you are concerned with possibly loosing samples during processing of the buffer, you might be interested in using the double buffering functionality.&lt;br /&gt;This will set up two equal buffers, and when the first one fill up it will immediately start filling into the second buffer - without missing samples.&lt;br /&gt;This functionality is also demonstrated in the SAADC example I linked earlier, as seen in the&amp;nbsp;&lt;em&gt;saadc_init()&lt;/em&gt; functions double call to &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrfx__saadc.html&amp;amp;anchor=ga94a7376973f1726b22a5debc090763eb"&gt;nrf_saadc_buffer_convert&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;[quote user="Empe"][/quote]&lt;/p&gt;
&lt;p&gt;Why do I ask this ... because of i have one more question.&lt;/p&gt;
&lt;p&gt;assume that i make my model like that,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;RESULT.MAXCNT is the size of the buffer provided to store samples in, so if you only set it to 1,&amp;nbsp;the SAADC will only do 1 conversion before the&amp;nbsp;&lt;em&gt;NRF_SAADC_EVENT_END&amp;nbsp;&lt;/em&gt;is triggered and conversion is stopped. You would have to restart the SAADC again for each sample, if you were to do it like this.&lt;br /&gt;Instead, I would recommend that you iterate over or directly access the result buffer with an offset equal to the number of channels you have, to retrieve the conversions.&lt;br /&gt;&lt;br /&gt;Is there a specific reason for why you would like to manipulate the registers directly, instead of using the SAADC driver?&lt;/p&gt;
[quote user="Empe"]oh, That is another reason why data can not read well. Thanks@[/quote]
&lt;p&gt;Yes, this might very well be a reason for incorrect readouts. Let me know if you are able to get proper readings using memory map.&lt;/p&gt;
[quote user="Empe"]Thanks for help. : )[/quote]
&lt;p&gt;No problem at all!&lt;br /&gt;Thank you for formatting your code with the insert code option, and having edited it into your original question - it is highly appreciated! :)&lt;br /&gt;Best of luck with your development, and let me know if you should have any other questions or issues!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SAADC Continuous sampling</title><link>https://devzone.nordicsemi.com/thread/241015?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 00:51:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76650853-0567-417a-b62f-b89361fe2304</guid><dc:creator>Empe</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
&lt;p&gt;Thanks for kind reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/59281/nrf52-saadc-continuous-sampling/240941"]you posted it seems you would like to have multiple inputs, which means you must use the PPI for continuous mode. [/quote]
&lt;p&gt;That&amp;#39;s why my code is not work well.&lt;/p&gt;
&lt;p&gt;I need study more about &amp;quot;PPI&amp;quot;. Thanks.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/59281/nrf52-saadc-continuous-sampling/240941"]you are going to use the RESULT.PTR value directly, you will have to increment it according to the memory usage described in that section.[/quote]
&lt;p&gt;oh, That is another reason why data can not read well. Thanks@&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then, Karl i have&amp;nbsp;another question.&lt;/p&gt;
&lt;p&gt;In&amp;nbsp;timing chart, After &amp;quot;STARTED&amp;quot; event generated, need to set next buffer to &amp;quot;RESULT.PTR&amp;quot;&lt;/p&gt;
&lt;p&gt;When using &amp;quot;PPI&amp;quot; function&amp;nbsp;for continuous mode of &amp;quot;SAADC&amp;quot;,&lt;/p&gt;
&lt;p&gt;if i don&amp;#39;t pointed next buffer, DMA will overwrite&amp;nbsp;data&amp;nbsp;automatic to buffer that before pointed? or Stop to converting?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Why do I ask this ... because of i have one more question.&lt;/p&gt;
&lt;p&gt;assume that i make my model like that,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    // Init channel 1 SAADC
    // Configure SAADC singled-ended channel, Internal reference (0.6V) and 1/6 gain.
    ...
    
    // Configure the SAADC resolution. (12Bit)
    ...
    
    // Configure result to be put in RAM at the location of &amp;quot;result&amp;quot; variable.
    NRF_SAADC-&amp;gt;RESULT.MAXCNT = 1;
    NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t)&amp;amp;adc_CH1_sample;
    
    // Init channel 2 SAADC
        // Configure SAADC singled-ended channel, Internal reference (0.6V) and 1/4 gain.
    ...
    
    // Configure the SAADC resolution. (10Bit)
    ...
    
    // Configure result to be put in RAM at the location of &amp;quot;result&amp;quot; variable.
    NRF_SAADC-&amp;gt;RESULT.MAXCNT = 1;
    NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t)&amp;amp;adc_CH2_sample;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;can I allocate a different storage buffer address and different resolution set for each channel?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for help. : )&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Empe.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SAADC Continuous sampling</title><link>https://devzone.nordicsemi.com/thread/240941?ContentTypeID=1</link><pubDate>Fri, 20 Mar 2020 17:05:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e62cbcab-95a2-4633-9a5d-9db577ad4758</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Empe,&lt;/p&gt;
&lt;p&gt;[quote user="Empe"][/quote]&lt;/p&gt;
&lt;p&gt;so, when making &amp;quot;saadc&amp;quot; continuous mode we don&amp;#39;t need &amp;quot;PPI&amp;quot; must&lt;/p&gt;
&lt;p&gt;is it right? i will re-check Reference again&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, you can either use SAADC in continuous mode with its own internal timer, or you could use PPI.&lt;br /&gt;Note that using the internal timer is only available for a single channel. From the initial code snippet you posted it seems you would like to have multiple inputs, which means you must use the PPI for continuous mode. Setting up the SAADC to work with PPI is demonstrated in the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/nrf_dev_saadc_example.html"&gt;SAADC example&lt;/a&gt; in the SDK.&lt;br /&gt;Have you seen &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fsaadc.html&amp;amp;anchor=concept_continuous"&gt;this section&lt;/a&gt; about the continuous mode for the SAADC?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="Empe"]in +add code Part, i want to check is it right to save &amp;amp; call data&amp;nbsp;&amp;nbsp;[/quote]
&lt;p&gt;Not quite, it depends on the configuration of your SAADC. The samples are stored using 16 bits, so you may not just increment a 32 bit pointer.&lt;br /&gt;Please see &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fsaadc.html&amp;amp;anchor=saadc_easydma"&gt;this section&lt;/a&gt; about how the SAADC results are stored for different SAADC configurations. If you are going to use the RESULT.PTR value directly, you will have to increment it according to the memory usage described in that section.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="Empe"]next time i will try to use &amp;quot;insert code&amp;quot; option[/quote]
&lt;p&gt;Thank you for formatting your code, it is much easier to read and much appreciated! :)&lt;/p&gt;
[quote user="Empe"]thanks for information.[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SAADC Continuous sampling</title><link>https://devzone.nordicsemi.com/thread/240732?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2020 23:15:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64dd7b9a-1ce1-42b5-8873-b69caf4018d9</guid><dc:creator>Empe</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;Thanks for reply Karl&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;so, when making &amp;quot;saadc&amp;quot; continuous mode we don&amp;#39;t need &amp;quot;PPI&amp;quot; must&lt;/p&gt;
&lt;p&gt;is it right? i will re-check Reference again&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;in +add code Part, i want to check is it right to save &amp;amp; call data&amp;nbsp;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Configure result to be put in RAM at the location of &amp;quot;result&amp;quot; variable.
// adc_sample is array type value, int16_t, adc_sample[8]

        NRF_SAADC-&amp;gt;RESULT.MAXCNT = 8;
        NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t)&amp;amp;adc_sample;
        
// when we need to read saadc value 0,1,4,5 to check IR 

        temp = adc_sample[0];
        temp = adc_sample[1];
        ...
        ...
&lt;/pre&gt;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;next time i will try to use &amp;quot;insert code&amp;quot; option&lt;/p&gt;
&lt;p&gt;thanks for information.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Empe.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SAADC Continuous sampling</title><link>https://devzone.nordicsemi.com/thread/240722?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2020 18:11:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39e14cdc-efa6-4771-add9-eb236dd433fc</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;[quote user=""][/quote]&lt;/p&gt;
&lt;p&gt;in SDK example, is it&amp;nbsp;&lt;span&gt;continuous&amp;nbsp;Mode?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;it looks like simple tesk Mode call by timer int every time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, the SAADC example uses the SAADC with PPI, set up to trigger every 400 ms.&lt;/p&gt;
[quote user=""]if i set saadc register like this[/quote]
&lt;p&gt;Have you seen the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__saadc__hal.html"&gt;SAADC API Reference&lt;/a&gt;? I recommend making use of the functions in the API reference.&lt;br /&gt;Of special interest to you is probably the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrfx__saadc.html&amp;amp;anchor=ga94a7376973f1726b22a5debc090763eb"&gt;nrfx_saadc_buffer_convert&lt;/a&gt;&amp;nbsp;or the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrf__saadc__hal.html&amp;amp;anchor=gad2c5858013f5a20e3c4d8f874a67117c"&gt;nrf_saadc_continuous_mode_enable&lt;/a&gt;.&lt;/p&gt;
[quote user=""]+add This is my full init Code for SAADC 0 - 7 Channel&amp;nbsp;[/quote]
&lt;p&gt;Is there anything in particular you would like me to look at in this code snippet?&lt;br /&gt;For future reference, please format code with the &amp;quot;insert code&amp;quot; option to drastically increase readability.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>