<?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>Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36443/glitches-in-adc-sampling</link><description>I am sampling 3 sensors using the ADC peripheral, clocking it once every 15us to sample the 3 sensors (3us acquisition time + 2us processing = 5us per channel). 
 I use the easy DMA in double buffer to sample 402 samples and interrupt me so i can process</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 28 Aug 2018 12:54:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36443/glitches-in-adc-sampling" /><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/146121?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 12:54:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7af5024d-a14a-40d8-bc39-aa282097eb4f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Ususally, we don&amp;#39;t recommend disabling softdevice interrupts. If the softdevice misses a timing critical interrupt it may cause an application reset. I know that 3 µs is a very short amount of time, and it may not cause any harm, but I can&amp;#39;t say that &amp;quot;it&amp;#39;s fine&amp;quot;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You will&amp;nbsp; have to do some testing. If it works for your application, and you don&amp;#39;t run into any softdevice issues, then it will probably be fine.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/146033?ContentTypeID=1</link><pubDate>Tue, 28 Aug 2018 06:49:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12b5df42-7eb2-42a9-8f9f-f261049dd9a7</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;Hi Edvin, I gave up on trying to make this work and switched to another approach where i need to sample just one ADC channel instead of 3 and this seems to work for me.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, in order to do that i need to disable all interrupts for a duration of 3us once every 500us on average. Will that cause any problem to the soft device proper functionality?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/145417?ContentTypeID=1</link><pubDate>Thu, 23 Aug 2018 07:29:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdfdc83f-42cf-464a-8d75-53a1f65c8585</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Moving the typedef uint32_t ret_code_t somehow solved the issue. I was able to compile after changing&amp;nbsp;ble_advertising_start_with_map() ble_advertising_start() on line 765 in ble.c. where did you declare ble_advertising_start_with_map()? I could not find it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was never able to compile in IAR. I am sorry, but I have had some bad experience with IAR before, so I ported the project to Keil. However, after programming the slightly modified project to Keil, and programming it, I can&amp;#39;t see any logging. I used the preprocessor defines from IAR, but with no luck.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you try to unzip the project in a fresh unmodified version of the SDK and see whether you can make it run (in IAR)? If not, please try to find out what files you have to modify to make it run, and let me know.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/145206?ContentTypeID=1</link><pubDate>Wed, 22 Aug 2018 05:08:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f821677-92ba-4804-b7a7-c8e21404583e</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;Hן Edvin&lt;/p&gt;
&lt;p&gt;In file&amp;nbsp;components\libraries\util\sdk_errors.h i justed moved the &amp;#39;typedef uint32_t ret_code_t;&amp;#39; line to the top of the file above the &amp;#39;#include&amp;#39; lines:&lt;/p&gt;
&lt;p&gt;typedef uint32_t ret_code_t;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;#include &amp;quot;nrf_error.h&amp;quot;&lt;br /&gt;#include &amp;quot;sdk_config.h&amp;quot;&lt;/p&gt;
&lt;p&gt;#ifdef __cplusplus&lt;br /&gt;extern &amp;quot;C&amp;quot; {&lt;br /&gt;#endif&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/145114?ContentTypeID=1</link><pubDate>Tue, 21 Aug 2018 12:01:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f77c3a8c-5e9e-457b-810f-5791bf955c28</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. I have tried a couple of times to compile your project, but for some reason, which I can&amp;#39;t figure out, I get a problem that ret_code_t is not defined. I just want to check with you whether you have done something that you can think of to cause that compiler error with any of the files in the &amp;quot;tj&amp;quot; folder?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/144519?ContentTypeID=1</link><pubDate>Thu, 16 Aug 2018 11:47:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c206c9a-0d07-4b0e-8bc3-f39e04b7e0f1</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;In the above code that works for me there is one thing that is very timing sensitive.&lt;/p&gt;
&lt;p&gt;This is the end of my above code::&lt;/p&gt;
&lt;p&gt;NRF_PPI-&amp;gt;CHENCLR = PPI_CHENCLR_CH1_Clear &amp;lt;&amp;lt; PPI_CHENCLR_CH1_Pos;&lt;br /&gt;NRF_PPI-&amp;gt;CH[1].EEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;EVENTS_END;&lt;br /&gt;NRF_PPI-&amp;gt;CH[1].TEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;TASKS_STOP;&lt;br /&gt;NRF_PPI-&amp;gt;CHENSET = PPI_CHENSET_CH1_Enabled &amp;lt;&amp;lt; PPI_CHENSET_CH1_Pos;&lt;br /&gt;while ( NRF_SAADC-&amp;gt;EVENTS_STOPPED==0 );&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_delay_us(2); // problem !!!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_SAADC-&amp;gt;ENABLE = (SAADC_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SAADC_ENABLE_ENABLE_Pos);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If i add the 2us delay i get stuck in the 1.2mA excessive power consumption.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This delay is the exact latency of the ADC interrupt, when i try to implement it using an interrupt.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you know why is that?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/144173?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 12:40:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57ddbff8-b928-4603-98e0-ab526a6b65fe</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/pump_5F00_ble-for-nordic-devzone.zip"&gt;devzone.nordicsemi.com/.../pump_5F00_ble-for-nordic-devzone.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The attached project runs on IAR 8.20.1.xxx&lt;/p&gt;
&lt;p&gt;It runs as is on our target board and on Nordic EVAL board.&lt;/p&gt;
&lt;p&gt;Every 4 seconds it performs SAADC sampling of 90 samples and shuts down the SAADC.&lt;/p&gt;
&lt;p&gt;When&amp;nbsp;ADC_TEST is defined 1 the test runs fine (polling mode).&lt;/p&gt;
&lt;p&gt;When ADC_TEST is defined 2 the test runs fine for the first few times and then it stuck consuming 1.2mA forever (even though all seems to keep on running as before - sampling every 4 seconds).&lt;/p&gt;
&lt;p&gt;The test is triggered by calling &amp;quot;void a2d_test(void)&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/144139?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 10:56:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:337e36ab-174d-4e8b-aceb-6fe3a226f56f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;When you are writing here, you should see a button near the top called &amp;quot;Insert&amp;quot;. Press Insert-&amp;gt;Insert image/video/file-&amp;gt;From: File upload-&amp;gt;Browse, and you can browse to the zip folder that you want to send.&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: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/144137?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 10:55:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc0687b6-506e-41ab-b1e4-c96cc90eae38</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;How do i send the ZIP file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/144069?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 07:03:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:908a6216-605b-4a58-9672-90b6df8be281</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I realize I forgot to tell you how to upload a project:&lt;/p&gt;
&lt;p&gt;If you have not modified any files outside the project folder, then you can zip the project folder.&lt;/p&gt;
&lt;p&gt;E.g. if I wanted to send you my ble_app_uart folder located in the folder: SDK\examples\&lt;strong&gt;ble_app_uart.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To check if you have modified any files outside this folder, try to unzip the folder in a fresh unzip of the SDK. If the project runs fine, it is ok. If you get any errors, then you have probably changed some files outside the project folder. Please include these files as well (add them inside the project folder, and I can include them in the project).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/144051?ContentTypeID=1</link><pubDate>Tue, 14 Aug 2018 06:06:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fcae031-9301-47ef-88b3-e72507feb446</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;That seems like a reasonable solution. I believe that the problem when doing SAADC sampling fast is that the events are showing up in the wrong order, and the difficult part is to stop the sampling at the correct time, so that you don&amp;#39;t do an extra sample, causing a shift in the buffer.&lt;/p&gt;
&lt;p&gt;Imagine that you are sampling channels: 1,2,3,1,2,3,1,2,3, ...You want to stop after channel 3, but a delayed stop may cause it to stop on channel 1, that is one more than you intended.&lt;/p&gt;
&lt;p&gt;Another approach you can test is to disable the CHEN, which I see that you do:&lt;/p&gt;
&lt;p&gt;NRF_PPI-&amp;gt;CHENCLR = PPI_CHENCLR_CH1_Clear &amp;lt;&amp;lt; PPI_CHENCLR_CH1_Pos; which should stop the &amp;quot;ADC train&amp;quot;.&lt;/p&gt;
&lt;p&gt;I will talk to someone in the ADC group. Please keep me updated if you find anything new.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/143989?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 13:48:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1aa3896-d585-4e68-8f56-b11bad6cb17f</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;Thanks for all the effort. I appreciate it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have already connected EVENTS_END to TASKS_START and this is the way i am working ever since.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem is that when i STOP the ADC i do it manually (not through PPI) and get excessive 1.2mA power consupmption.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the last hour i may have a breakthrough by using PPI to connect&amp;nbsp;&lt;span&gt;EVENTS_END to TASKS_START&amp;nbsp;as you suggested, but on the last SAADC buffer i sample, i overwrite this PPI channel such that EVENTS_END will do TASKS_STOP instead.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This approach seems to work.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I will try to use it in my real code (now i am using jut a side SAADC test) and see if it works.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you consult with the SAADC expert to see if my solution makes sense?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I will send you the project later on (how d oi do that?).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is what i do at init with PPI:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;// connect the timer to adc sampling &lt;br /&gt; NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t) &amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];&lt;br /&gt; NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;TASKS_SAMPLE;&lt;/p&gt;
&lt;p&gt;// connect end to start &lt;br /&gt; NRF_PPI-&amp;gt;CH[1].EEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;EVENTS_END;&lt;br /&gt; NRF_PPI-&amp;gt;CH[1].TEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;TASKS_START;&lt;/p&gt;
&lt;p&gt;And this is what i do at run time after the last buffer&amp;nbsp;EVENTS_STARTED is set:&lt;/p&gt;
&lt;p&gt;NRF_PPI-&amp;gt;CHENCLR = PPI_CHENCLR_CH1_Clear &amp;lt;&amp;lt; PPI_CHENCLR_CH1_Pos;&lt;br /&gt; NRF_PPI-&amp;gt;CH[1].EEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;EVENTS_END;&lt;br /&gt; NRF_PPI-&amp;gt;CH[1].TEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;TASKS_STOP;&lt;br /&gt; NRF_PPI-&amp;gt;CHENSET = PPI_CHENSET_CH1_Enabled &amp;lt;&amp;lt; PPI_CHENSET_CH1_Pos;&lt;br /&gt; while ( NRF_SAADC-&amp;gt;EVENTS_STOPPED==0 );&lt;/p&gt;
&lt;p&gt;&lt;span&gt; NRF_SAADC-&amp;gt;ENABLE = (SAADC_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SAADC_ENABLE_ENABLE_Pos);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/143984?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 13:33:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:048a69a8-14da-4180-af44-c55d2589cca2</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am sorry that this is taking a while. Trust me, if I knew exactly what to do to fix this, I would have told you at once. I have also consulted with our SAADC guys, and they only point to Jørgens answer in the ticket that I linked to in an earlier post:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Use PPI to trigger START task on an END event. This will avoid the delayed triggering og the START task due to a queued interrupt generated by the END event, but in the case of high sample frequency and long delays, it can cause your buffer to be overwritten before you are able to process the buffer. In case of using this solution, it is neccessary to use double buffering and large enough buffers to avoid data loss.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I am sorry. I meant that you should connect EVENTS_END with TASKS_START.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then you only need to start the SAADC by calling the first sample call.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is it possible to send the project, and I can look at it, or maybe get the SAADC experts to do it. Is it possible to reproduce on a regular DK, or do you have a custom board?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/143888?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 09:31:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3b9ac21-d264-48a7-a873-64b1d53c80c8</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;Nothing happens when i do that. No sampling at all.&lt;/p&gt;
&lt;p&gt;Nothing also happens when i do:&lt;/p&gt;
&lt;p&gt;NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t) &amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];&lt;br /&gt; NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;TASKS_SAMPLE;&lt;br /&gt; NRF_PPI-&amp;gt;FORK[0].TEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;TASKS_START;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/143868?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 08:27:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7c908ec-9bd7-432c-b0f6-4d4caa51072c</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Did you try to change the TASKS_SAMPLE to TASKS_START (now at NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_SAADC-&amp;gt;TASKS_START;&lt;/p&gt;
&lt;p&gt;Like I suggested in the previous reply?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/143863?ContentTypeID=1</link><pubDate>Mon, 13 Aug 2018 08:11:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10490c8e-96eb-4c9e-93d3-d61cb5830af4</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;I still haven&amp;#39;t solved the excessive power consumption issue.&lt;/p&gt;
&lt;p&gt;In order to isolate the problem i have this code here that i use to test:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void a2d_test(void)
{
  // timer that clocks the adc once every 18us 
  NRF_TIMER1-&amp;gt;MODE = (TIMER_MODE_MODE_Timer &amp;lt;&amp;lt; TIMER_MODE_MODE_Pos); 
  NRF_TIMER1-&amp;gt;PRESCALER = 4; // 1mhz --&amp;gt; 1us 
  NRF_TIMER1-&amp;gt;CC[0] = 18; 
  NRF_TIMER1-&amp;gt;SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk;

  // connect the timer to adc sampling 
  NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t) &amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];
  NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t) &amp;amp;NRF_SAADC-&amp;gt;TASKS_SAMPLE;

  // enable ppi 
  NRF_PPI-&amp;gt;CHENSET = PPI_CHENSET_CH0_Enabled &amp;lt;&amp;lt; PPI_CHENSET_CH0_Pos;

  // configure the adc to sample 3 channels 111 samples per channel (total 333 samples)
  NRF_SAADC-&amp;gt;ENABLE = (SAADC_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; SAADC_ENABLE_ENABLE_Pos);
  NRF_SAADC-&amp;gt;RESOLUTION = NRF_SAADC_RESOLUTION_12BIT;
  NRF_SAADC-&amp;gt;OVERSAMPLE = NRF_SAADC_OVERSAMPLE_DISABLED;
  NRF_SAADC_EVENTS_CLEAR(EVENTS_END)
  NRF_SAADC_EVENTS_CLEAR(EVENTS_STARTED)
  for ( int i=0; i&amp;lt;3; i++ )
  {
    NRF_SAADC-&amp;gt;CH[i].PSELN = NRF_SAADC_INPUT_DISABLED;
    NRF_SAADC-&amp;gt;CH[i].CONFIG =
            ((NRF_SAADC_RESISTOR_DISABLED   &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESP_Pos)   &amp;amp; SAADC_CH_CONFIG_RESP_Msk)
            | ((NRF_SAADC_RESISTOR_DISABLED &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESN_Pos)   &amp;amp; SAADC_CH_CONFIG_RESN_Msk)
            | ((NRF_SAADC_GAIN1_4           &amp;lt;&amp;lt; SAADC_CH_CONFIG_GAIN_Pos)   &amp;amp; SAADC_CH_CONFIG_GAIN_Msk)
            | ((NRF_SAADC_REFERENCE_VDD4    &amp;lt;&amp;lt; SAADC_CH_CONFIG_REFSEL_Pos) &amp;amp; SAADC_CH_CONFIG_REFSEL_Msk)
            | ((NRF_SAADC_ACQTIME_3US       &amp;lt;&amp;lt; SAADC_CH_CONFIG_TACQ_Pos)   &amp;amp; SAADC_CH_CONFIG_TACQ_Msk)
            | ((NRF_SAADC_MODE_SINGLE_ENDED &amp;lt;&amp;lt; SAADC_CH_CONFIG_MODE_Pos)   &amp;amp; SAADC_CH_CONFIG_MODE_Msk)
            | ((NRF_SAADC_BURST_DISABLED    &amp;lt;&amp;lt; SAADC_CH_CONFIG_BURST_Pos)  &amp;amp; SAADC_CH_CONFIG_BURST_Msk);
  }
  NRF_SAADC-&amp;gt;CH[0].PSELP = NRF_SAADC_INPUT_AIN1;
  NRF_SAADC-&amp;gt;CH[1].PSELP = NRF_SAADC_INPUT_AIN2;
  NRF_SAADC-&amp;gt;CH[2].PSELP = NRF_SAADC_INPUT_AIN3;
  NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t)train_adc_buffer[0];
  NRF_SAADC-&amp;gt;RESULT.MAXCNT = 333;
  NRF_SAADC_EVENTS_CLEAR(EVENTS_STARTED)
  
  // trigger the timer that clocks the adc 
  NRF_TIMER1-&amp;gt;TASKS_START = 1; // 

  // repeat 10 times 
  for ( int i=0; i&amp;lt;10; i++ )
  {
    // trigger the adc 
    NRF_SAADC-&amp;gt;TASKS_START = 1;
    
    // wait until adc ends its sampling (not stopped)  
    NRF_SAADC_EVENTS_CLEAR(EVENTS_END)
    while (NRF_SAADC-&amp;gt;EVENTS_END==0);

    // set its pointer to the desired location 
    NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t)train_adc_buffer[0];
  }

  // stop the ADC 
  // problem - any delay i add here or any interruption between EVENTS_END and STOP casues permaenent 1.2ma consumtion nrf_delay_us(3);
  NRF_SAADC_EVENTS_CLEAR(EVENTS_STOPPED)
  NRF_SAADC-&amp;gt;TASKS_STOP = 1;
  while (NRF_SAADC-&amp;gt;EVENTS_STOPPED==0);
  
  // disable the adc 
  NRF_SAADC-&amp;gt;ENABLE = (SAADC_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SAADC_ENABLE_ENABLE_Pos);
  NRF_SAADC-&amp;gt;CH[0].PSELP = NRF_SAADC_INPUT_DISABLED;
  NRF_SAADC-&amp;gt;CH[1].PSELP = NRF_SAADC_INPUT_DISABLED;
  NRF_SAADC-&amp;gt;CH[2].PSELP = NRF_SAADC_INPUT_DISABLED;

  // disaple the ppi   
  NRF_PPI-&amp;gt;CHENCLR = (PPI_CHENCLR_CH0_Clear &amp;lt;&amp;lt; PPI_CHENCLR_CH0_Pos); 

  // disable the timer   
  NRF_TIMER1-&amp;gt;TASKS_STOP = 1;
  NRF_TIMER1-&amp;gt;SHORTS = 0;
  NRF_TIMER1-&amp;gt;TASKS_SHUTDOWN = 1;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please look at the comment where i say &amp;quot;problem&amp;quot; right when stopping the ADC.&lt;/p&gt;
&lt;p&gt;Whenever i have a delay between EVENTS_END and&amp;nbsp;&amp;nbsp;NRF_SAADC-&amp;gt;TASKS_STOP=1; i get excessive permanent power consumption of ~1.2mA.&lt;/p&gt;
&lt;p&gt;From this point on there is no way to reduce the power unless i RESET the chip.&lt;/p&gt;
&lt;p&gt;If i&amp;nbsp;use PPI to STOP the ADC, the problem is gone since EVENTS_END and TASK_STOP occur at the same time. But in my system i cannot do this.&lt;/p&gt;
&lt;p&gt;Do you now about this issue and why it occurs?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/142211?ContentTypeID=1</link><pubDate>Tue, 31 Jul 2018 14:03:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:421f5c61-23ac-4558-8951-1d26f89d39ab</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t worked with the workaround in that post, but I see that you trigger TASKS_SAMPLE from the&amp;nbsp;&amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0]; in PPI, so it might very well be the issue.&lt;/p&gt;
&lt;p&gt;What happens if you try to change TASKS_SAMPLE with TASKS_START in NRF_PPI-&amp;gt;CH[5].TEP ?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/140890?ContentTypeID=1</link><pubDate>Sat, 21 Jul 2018 12:08:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d224ffe-2685-45ed-8823-35e74f611519</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;Thanks, Edvin. I have already seen the link you have provided and also posted my question over there as well few days ago.&lt;/p&gt;
&lt;p&gt;I believe my situation is different since i have used PPI to chain END event to START task of the SAADC sampling (one of the solution suggested in the link you have provided), and this works fine. i do not have any channels swaps during an on-going continuous sampling.&lt;/p&gt;
&lt;p&gt;My problem is that the channels swap occurs when restarting SAADC sampling some time after i aborted a previous sampling. When doing that i have a constant channels swap.&lt;/p&gt;
&lt;p&gt;To overcome this i need to add 10us delay in the SAADC abort routine (as i already explained above in the last provided code example).&lt;/p&gt;
&lt;p&gt;All i need is for you to confirm that that my SAADC abort patch with the 10us delay makes sense.&lt;/p&gt;
&lt;p&gt;I have added 10us delay here:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;NRF_SAADC-&amp;gt;TASKS_STOP = 0x1UL;&lt;br /&gt; uint32_t timeout = 10000;&lt;br /&gt; while (NRF_SAADC-&amp;gt;EVENTS_STOPPED==0 &amp;amp;&amp;amp; timeout &amp;gt; 0)&lt;br /&gt; {&lt;br /&gt; --timeout;&lt;br /&gt; }&lt;br /&gt; ASSERT(timeout &amp;gt; 0);&lt;br /&gt; &lt;strong&gt;nrf_delay_us(10);&lt;/strong&gt; // new - delay equal to two samples (3us sampling rate + 2us convert)&lt;br /&gt; NRF_SAADC-&amp;gt;ENABLE = (SAADC_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SAADC_ENABLE_ENABLE_Pos);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/140830?ContentTypeID=1</link><pubDate>Fri, 20 Jul 2018 12:23:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d36edaf3-fe5a-4042-bdef-ca0cd74c5644</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have spoken with some of out ADC engineers. They say that this is most likely related to a bug.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you please check Jørgen&amp;#39;s answer marked in green on this page:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/20291/offset-in-saadc-samples-with-easy-dma-and-ble"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/20291/offset-in-saadc-samples-with-easy-dma-and-ble&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/140610?ContentTypeID=1</link><pubDate>Thu, 19 Jul 2018 08:01:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6faf92b-319b-4822-91d7-4ab93abfd679</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;yes. readings are ok, they just appear in the wrong location in the RAM buffer. As if the EasyDMA starts from the 2nd sample and thus a constant offset occurs -&amp;nbsp;&lt;span&gt;{ch1,ch2,ch0,ch1,ch2...} instead of&amp;nbsp;{ch0,ch1,ch2,ch0,ch1,ch2...}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I did registers dump before i start the SAADC each time, and when i disable the SAADC before i start it again (the &amp;quot;if 0&amp;quot; code), i see some leftover value in the RESULT.AMOUNT register that its value is somewhere in between 0x00000000 and 0x00000192 (0x192 is the buffer size - 402). I also see&amp;nbsp;EVENTS_STOPPED=1.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;how can i clear down&amp;nbsp;RESULT.AMOUNT before i start SAADC samling?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I modified the code used to shut down the ADC and added delay and it seems to work,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is the code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  uint8_t val;
  sd_nvic_critical_region_enter(&amp;amp;val); // new - prevent interruption 
  NRF_SAADC-&amp;gt;INTENCLR = NRF_SAADC_INT_ALL; 
  NVIC_DisableIRQ(SAADC_IRQn);
  while ( NRF_SAADC-&amp;gt;EVENTS_END==0x0UL ); // new - ensure end alignmnet 
  NRF_SAADC-&amp;gt;EVENTS_STOPPED = 0x0UL;
  volatile uint32_t dummy = NRF_SAADC-&amp;gt;EVENTS_STOPPED;
  (void)dummy;
  NRF_SAADC-&amp;gt;TASKS_STOP = 0x1UL;
  uint32_t timeout = 10000;
  while (NRF_SAADC-&amp;gt;EVENTS_STOPPED==0 &amp;amp;&amp;amp; timeout &amp;gt; 0)
  {
    --timeout;
  }
  ASSERT(timeout &amp;gt; 0);
  nrf_delay_us(10); // new - delay equal to two samples (3us sampling rate + 2us convert)
  NRF_SAADC-&amp;gt;ENABLE = (SAADC_ENABLE_ENABLE_Disabled &amp;lt;&amp;lt; SAADC_ENABLE_ENABLE_Pos);
  sd_nvic_critical_region_exit(val); // new 
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;Look at &amp;quot;new&amp;quot; comments to see what i have added.&lt;/p&gt;
&lt;p&gt;Seems like the proper sampling of SAADC is directly affected by the timing i use to shut down the SAADC.&lt;/p&gt;
&lt;p&gt;I must understand why is that and what am i doing wrong?&lt;/p&gt;
&lt;p&gt;I also saw this issue that seems relevant:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/16885/saadc-scan-mode-sample-order-is-not-always-consistent/134614#134614"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/16885/saadc-scan-mode-sample-order-is-not-always-consistent/134614#134614&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/140605?ContentTypeID=1</link><pubDate>Thu, 19 Jul 2018 07:37:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4c2eafb-3e14-4205-8877-a365d4a8b2f4</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Does this mean that the readings, other from that the channels are swapped, are ok? They are not suppose to have the same pattern as before the brake in the readings?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I.e. in the graph from your original post, only the colors are wrong after X = 4561?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/140502?ContentTypeID=1</link><pubDate>Wed, 18 Jul 2018 10:05:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a6e4143-c290-457c-b744-c65ccbd4e334</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;1. Yes - shutting down the SAADC (the &amp;quot;#if 0&amp;quot; code) causes the problem to occur in most of the times.&lt;/p&gt;
&lt;p&gt;2. I did check the 3&amp;nbsp;&lt;span&gt;PSELP registers and they all contain correct values when the problem occur, so this is not the root cause. You can also see that my code has very simple in that respect:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NRF_SAADC-&amp;gt;CH[0].PSELP = NRF_SAADC_INPUT_AIN1;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NRF_SAADC-&amp;gt;CH[1].PSELP = NRF_SAADC_INPUT_AIN2;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NRF_SAADC-&amp;gt;CH[2].PSELP = NRF_SAADC_INPUT_AIN3;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3. My guess is that when re enabling the SAADC the ADC samples one channel, but not to the EasyDMA and when it starts filling up the DMA buffer the entire sampling shifts one sample causing me to see the 2nd channel where the 1st channel is expected. Instead of {ch0,ch1,ch2,ch0,ch1,ch2...} i see&amp;nbsp;&amp;nbsp;{ch1,ch2,ch0,ch1,ch2...}.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/140494?ContentTypeID=1</link><pubDate>Wed, 18 Jul 2018 09:18:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c066498b-b9cf-4eac-a80a-7102ead7aecb</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I understand. If you replace &amp;quot;#if 0&amp;quot; with &amp;quot;#if 1&amp;quot;, the problem occurs.&lt;br /&gt;I assume that you have set flag_stop_sampling to false before start_adc_sampling, right?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Can you try to break in the handler when the issue occurs, and try to read the registers:&lt;br /&gt;NRF_SAADC-&amp;gt;CH[0].PSELP,&lt;br /&gt;NRF_SAADC-&amp;gt;CH[1].PSELP,&lt;br /&gt;NRF_SAADC-&amp;gt;CH[2].PSELP,&lt;/p&gt;
&lt;p&gt;And see whether they are still configured to the right pins, or if any of them are disabled?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/140476?ContentTypeID=1</link><pubDate>Wed, 18 Jul 2018 05:14:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:565bce47-3c4d-4c76-8a9b-975754eb3ece</guid><dc:creator>Omri Friedman</dc:creator><description>&lt;p&gt;I start the sampling again at least few seconds later from stopping it. It is done from main() by calling&amp;nbsp;start_adc_sampling()&lt;/p&gt;
&lt;p&gt;What i think i am looking is to understand why the initial call to&amp;nbsp;start_adc_sampling works, while a call after stopping the sampling does not work (it only work if i do NOT do the code the is commented out by &amp;#39;#if 0 ... #endif&amp;#39;).&lt;/p&gt;
&lt;p&gt;By the way - the attached code is just part of a bigger chunk of code involving 9 PPI channels, all 4 timers and 4 GPIOTE. It deals with rotating a stepper motor and sampling input from 2 encoder channels + another sensor (these are shown in the picture i placed)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Glitches in adc sampling</title><link>https://devzone.nordicsemi.com/thread/140418?ContentTypeID=1</link><pubDate>Tue, 17 Jul 2018 14:57:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23ae5dda-5304-4fed-8d57-d468fb5e4fbf</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Where do you re-enable the SAADC? That is, if&amp;nbsp;flag_stop_sampling was set to 1, and then you start the sampling again?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&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></channel></rss>