<?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 never writes result to buffer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77608/nrf52-saadc-never-writes-result-to-buffer</link><description>Hi. 
 My first attempt to get SAADC to work was: 
 NRF_SAADC-&amp;gt;INTENSET = (SAADC_INTEN_RESULTDONE_Enabled &amp;lt;&amp;lt; SAADC_INTEN_RESULTDONE_Pos) | //A result is ready to get transferred to RAM. (SAADC_INTEN_DONE_Enabled &amp;lt;&amp;lt;SAADC_INTEN_DONE_Pos) | //A conversion</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Jul 2021 12:51:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77608/nrf52-saadc-never-writes-result-to-buffer" /><item><title>RE: NRF52 SAADC never writes result to buffer</title><link>https://devzone.nordicsemi.com/thread/320695?ContentTypeID=1</link><pubDate>Mon, 19 Jul 2021 12:51:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:639fd3c4-25ff-456e-82df-517cb12f9f00</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;What SDK version, and if relevant SoftDevice version are you using in this application? Have you already gotten it to work on a DK or similar, and are now struggling to get the project running on your custom board?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 SAADC never writes result to buffer</title><link>https://devzone.nordicsemi.com/thread/320576?ContentTypeID=1</link><pubDate>Sun, 18 Jul 2021 21:07:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c29463e6-0101-4faf-bb67-d577cff54f5f</guid><dc:creator>khorght</dc:creator><description>&lt;p&gt;nRF52832-QFAA-R7&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 SAADC never writes result to buffer</title><link>https://devzone.nordicsemi.com/thread/320572?ContentTypeID=1</link><pubDate>Sun, 18 Jul 2021 19:27:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1082145-1341-4c9e-8e01-622ac4eed60c</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Umm, cannot say anything helpful..&amp;nbsp;What chip do you have? Your code works on my 52840 DK (without interrupts for simplicity, but it shouldn&amp;#39;t matter), adc_result is filled with VDD:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint16_t adc_result= 0xaaaa;

//NRF_SAADC-&amp;gt;CH[0].PSELP = SAADC_CH_PSELP_PSELP_AnalogInput0 &amp;lt;&amp;lt; SAADC_CH_PSELP_PSELP_Pos;
NRF_SAADC-&amp;gt;CH[0].PSELP = SAADC_CH_PSELP_PSELP_VDD &amp;lt;&amp;lt; SAADC_CH_PSELP_PSELP_Pos;
// AIN0 as Negative for differential channel
NRF_SAADC-&amp;gt;CH[0].PSELN = SAADC_CH_PSELN_PSELN_NC &amp;lt;&amp;lt; SAADC_CH_PSELN_PSELN_Pos;
//ADC range = 0.6V/(1/6) = 3.6V
NRF_SAADC-&amp;gt;CH[0].CONFIG = (SAADC_CH_CONFIG_GAIN_Gain1_6 &amp;lt;&amp;lt; SAADC_CH_CONFIG_GAIN_Pos) |
(SAADC_CH_CONFIG_REFSEL_Internal &amp;lt;&amp;lt; SAADC_CH_CONFIG_REFSEL_Pos) |
(SAADC_CH_CONFIG_MODE_SE &amp;lt;&amp;lt; SAADC_CH_CONFIG_MODE_Pos) |
(SAADC_CH_CONFIG_RESN_Bypass &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESN_Pos) |
(SAADC_CH_CONFIG_RESP_Bypass &amp;lt;&amp;lt; SAADC_CH_CONFIG_RESP_Pos) |
(SAADC_CH_CONFIG_TACQ_3us &amp;lt;&amp;lt; SAADC_CH_CONFIG_TACQ_Pos);
while (NRF_SAADC-&amp;gt;STATUS &amp;amp; 0x01); // Wait while ADC busy
NRF_SAADC-&amp;gt;SAMPLERATE = SAADC_SAMPLERATE_MODE_Task &amp;lt;&amp;lt; SAADC_SAMPLERATE_MODE_Pos;
NRF_SAADC-&amp;gt;RESOLUTION = SAADC_RESOLUTION_VAL_14bit &amp;lt;&amp;lt; SAADC_RESOLUTION_VAL_Pos;
NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t) &amp;amp;adc_result; // Pointer to result variable
NRF_SAADC-&amp;gt;RESULT.MAXCNT = 1;

NRF_SAADC-&amp;gt;ENABLE = 0x01;

NRF_SAADC-&amp;gt;EVENTS_STARTED = 0;
NRF_SAADC-&amp;gt;TASKS_START = 1;
while (! NRF_SAADC-&amp;gt;EVENTS_STARTED) {}

NRF_SAADC-&amp;gt;EVENTS_END = 0;
NRF_SAADC-&amp;gt;TASKS_SAMPLE = 1;
while (! NRF_SAADC-&amp;gt;EVENTS_END) {}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 SAADC never writes result to buffer</title><link>https://devzone.nordicsemi.com/thread/320565?ContentTypeID=1</link><pubDate>Sun, 18 Jul 2021 18:09:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5f4ac2e-17ef-47b6-97cf-83d565f8bf5f</guid><dc:creator>khorght</dc:creator><description>&lt;p&gt;Thanx for the advice, Dmitry. This isn&amp;#39;t working too. i&amp;#39;ve already tryed:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;uint32_t adc_result;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t ) &amp;amp;adc_result;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;then&amp;nbsp;&lt;/span&gt;&lt;span&gt;volatile uint32_t&amp;nbsp;adc_result;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;then&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;int&amp;nbsp;adc_result;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and&amp;nbsp;&amp;nbsp;volatile int&amp;nbsp;adc_result;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;then&amp;nbsp;&lt;/span&gt;&lt;span&gt;uint16_t&amp;nbsp;adc_result;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and&amp;nbsp;&amp;nbsp;volatile uint16_t&amp;nbsp;adc_result;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and&amp;nbsp; tryed to use SDK with&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;static nrf_saadc_value_t&amp;nbsp; &amp;nbsp; &amp;nbsp;m_buffer_pool[2][2];&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;if my code based on just reading datasheet and poor programming knowledge may be incorrect, then with SDK&amp;nbsp;it should work flawlessly, because my intrusion is as minimal as possible, i&amp;#39;ve just copied lines from example and SDK&amp;nbsp;should do all the magic with buffering/double buffering but it gives me the very same result - nothing written to buffer when (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The biggest question is - why i can&amp;#39;t just get the result from some sort of ADCRESULT register as i&amp;nbsp;did with&amp;nbsp;STM32, LPC,&amp;nbsp; MKL03Z,&amp;nbsp; MSP432, EFM32 if i don&amp;#39;t need/want/can&amp;nbsp;using DMA.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 SAADC never writes result to buffer</title><link>https://devzone.nordicsemi.com/thread/320556?ContentTypeID=1</link><pubDate>Sun, 18 Jul 2021 15:17:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5f9575b-5701-4318-a683-cf4a2ef8aaca</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="106295" url="~/f/nordic-q-a/77608/nrf52-saadc-never-writes-result-to-buffer"]i&amp;#39;ve tryed to use&amp;nbsp;adc_result as uint32_t, as int, as volatile [/quote]
&lt;p&gt;Is it a plain variable, not an array? then you should write&amp;nbsp;&lt;span&gt;NRF_SAADC-&amp;gt;RESULT.PTR = (uint32_t ) &amp;amp;adc_result;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;A sample is a signed 16-bit value, so adc_result should be &amp;quot;short&amp;quot; or &amp;quot;int16_t&amp;quot;.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>