<?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 nrfx very slow with SDK 17.1.0 on nRF52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/95555/saadc-nrfx-very-slow-with-sdk-17-1-0-on-nrf52832</link><description>My hardware platform uses NRF52832 with SDK 17.1.0. The design uses two SAADC channels input in SE mode. 
 I see that the examples folder includes an example usage of the SAADC but it uses NRF_DRV drivers to interact with the SAADC. 
 My understanding</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Jan 2023 08:59:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/95555/saadc-nrfx-very-slow-with-sdk-17-1-0-on-nrf52832" /><item><title>RE: SAADC nrfx very slow with SDK 17.1.0 on nRF52832</title><link>https://devzone.nordicsemi.com/thread/404487?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2023 08:59:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c693ceea-dfc5-4f19-b897-2cd09d4fb24d</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello RVM,&lt;/p&gt;
[quote user="RMV"]Thanks for your responses.[/quote]
&lt;p&gt;No problem at all, I am happy to help! :)&amp;nbsp;&lt;/p&gt;
[quote user="RMV"]What should be the value of the &amp;#39;size&amp;#39; parameter passed in to nrfx_saadc_buffer_convert()?[/quote]
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrfx__saadc.html#ga94a7376973f1726b22a5debc090763eb"&gt;The size parameter should be the size of the buffer that you are providing in the first argument&lt;/a&gt;. A larger buffer will let the SAADC sample longer before needing the CPU to process the buffer. I.e if you have a buffer size of 2 then the CPU will have to wake up and process the buffer every time you perform a single sample of 2 channels, while if your buffer size if 100 it will only need to wake up every 50th sampling to process the buffer.&lt;/p&gt;
[quote user="RMV"]In other words do I need to use a large enough buffer that maps ALL 8 CHANNELS to unique indexes in the buffer array?[/quote]
&lt;p&gt;No, only the enabled channels will provide an output. The samples &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html#saadc_operationmodes_scan"&gt;will be stored like described in this figure&lt;/a&gt;.&lt;/p&gt;
[quote user="RMV"]My initial observation was with the BLE broadcasting continuously. When I disabled the BLE broadcast (I still needed to enable the BLE SD because without it the RTC did not advance) I did not see any noticeable changes in the time required to complete the capture.[/quote]
&lt;p&gt;That sounds reasonable - if it was BLE activity keeping the CPU from capturing the RTC count it would be nowhere 500-700 ms in length, so there is likely something else playing into this.&lt;br /&gt;Is this the only other thing happening in your application?&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: SAADC nrfx very slow with SDK 17.1.0 on nRF52832</title><link>https://devzone.nordicsemi.com/thread/404412?ContentTypeID=1</link><pubDate>Wed, 11 Jan 2023 18:39:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d007f1b8-4e91-47b1-8236-30ec0798e93b</guid><dc:creator>RVM</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Thanks for your responses. I am definitely inclined to get the PPI based solution to work for us.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What should be the value of the &amp;#39;size&amp;#39; parameter passed in to nrfx_saadc_buffer_convert()? &lt;br /&gt;I am sampling channels 0 and 1 (in either 10-bit or 12-bit range -- will chose at a later date). &lt;br /&gt;And what exactly is the correlation between the buffer address (i.e. array index) and the channel I am trying to sample?&lt;br /&gt;Does the index depend on the actual channel number itself (i.e. does channel 0 map to index 0, etc.)?&lt;br /&gt;In other words do I need to use a large enough buffer that maps ALL 8 CHANNELS to unique indexes in the buffer array?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regarding your question about what else is going on:&amp;nbsp; My initial observation was with the BLE broadcasting continuously. When I disabled the BLE broadcast (I still needed to enable the BLE SD because without it the RTC did not advance) I did not see any noticeable changes in the time required to complete the capture.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;RVM&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC nrfx very slow with SDK 17.1.0 on nRF52832</title><link>https://devzone.nordicsemi.com/thread/404229?ContentTypeID=1</link><pubDate>Wed, 11 Jan 2023 07:33:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fc86978-075a-4b56-8f76-1ebc25f53b58</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello RMV,&lt;/p&gt;
[quote user=""]I am using software triggered task to sample the two channels in scan mode.&amp;nbsp;[/quote]
&lt;p&gt;When you say&amp;nbsp;&lt;em&gt;software triggered&lt;/em&gt; do you mean that the sampling is triggered by the CPU, such as through a call to &lt;em&gt;nrfx_saadc_sample&lt;/em&gt;?&lt;br /&gt;If so, the sampling could be delayed in the case that the CPU is busy processing a higher level interrupt when the sampling should have been triggered.&lt;br /&gt;&lt;br /&gt;If your application requires that the samples are collected periodically with high accuracy you should instead use the PPI + easyDMA approach that you mention, to trigger the samplings, but connecting the SAADC SAMPLE task to your periodic TIMER CAPTURE event, so that the sampling will be triggered immediately when the TIMER CAPTURE event is generated, completely without CPU intervention.&lt;br /&gt;This could also reduce your power consumption in the case that you are sampling at a high frequency and have to wake the CPU up to trigger these samples.&lt;br /&gt;If you are to switch to the PPI based sample triggering you could &lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples/blob/master/ble_app_uart__saadc_timer_driven__scan_mode/main.c"&gt;take a look at this example&lt;/a&gt;&amp;nbsp;as a reference, to see how it could be done.&lt;/p&gt;
[quote user=""]I am observing the value returned by app_timer_cnt() before and after the sample task but I am observing that inspite of configuring an acquisition time of around 3uS, the task takes about 500 mS (yes, 500 milli-seconds) to complete. Increasing the acquisition time to around 10 uS results in the task completion time fo around 700 mS.[/quote]
&lt;p&gt;Using the app_timer_cnt to measure things in the µs is not the best approach, both due to the resolution of the RTC but also due to the fact that the app_timer_cnt needs CPU intervention to do a capture, which could be delayed if the CPU is pulled away to a higher priority task - making it look like the operation you are trying to measure took much longer than expected.&lt;br /&gt;Nevertheless, 500 ms is still an incredibly long time. Could you share the snippet of code in which this measurement was taken? Could you also detail what else is going on in your application at the time of sampling?&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>