<?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>nRF52832 ADC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42749/nrf52832-adc</link><description>I try to combine SPI master and ADC sample code, I add below code to my spi master example, the saadc_init() is called in the main function. However I found that the saadc_callback is not called after a while. Please comment! 
 I am using nRF5_15.2.0</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 31 Jan 2019 12:19:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42749/nrf52832-adc" /><item><title>RE: nRF52832 ADC</title><link>https://devzone.nordicsemi.com/thread/168860?ContentTypeID=1</link><pubDate>Thu, 31 Jan 2019 12:19:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa6fe962-7f1c-4485-98a3-2b487b74f06f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;yes. But you should trigger this using a timer rather than in the callback event.&lt;/p&gt;
&lt;p&gt;With your implementation below you risk that nrfx_saadc_sample() does not return NRF_SUCCESS for some reason. In this case, adc_complete is false, and you have not triggered a new sample, and you will not get a new callback, and never trigger the new sample.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Therefore you should at least not set adc_complete to false without checking that nrfx_saadc_sample() returned true.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 ADC</title><link>https://devzone.nordicsemi.com/thread/168818?ContentTypeID=1</link><pubDate>Thu, 31 Jan 2019 09:27:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b71d187-6706-43bd-a2ff-86f462cb0e62</guid><dc:creator>Fiske</dc:creator><description>&lt;p&gt;I have tried the saadc example. It work. All my pcb boards are sent to customer, I have no boards to try now. I will try to set the SAMPLES_IN_BUFFER to 1 for next batch. The callback will be triggered every time I call&amp;nbsp;nrfx_saadc_sample() if I set&amp;nbsp;&lt;span style="background-color:transparent;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:21px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt; SAMPLES_IN_BUFFER to 1. Right?&lt;/span&gt;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/42749/nrf52832-adc/168798"]SAMPLES[/quote]&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 ADC</title><link>https://devzone.nordicsemi.com/thread/168798?ContentTypeID=1</link><pubDate>Thu, 31 Jan 2019 08:38:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7383c32-a183-400e-8552-cf385b0d8227</guid><dc:creator>Edvin</dc:creator><description>[quote user="Edvin Holmseth"]Each time a sample is trigged, one sample is taken (one sample per channel, if several saadc_channels are enabled, but it looks like you only have one). Note that you have to do&amp;nbsp;n&lt;span&gt;&amp;nbsp;&lt;/span&gt;samples before the saadc callback is called, where n = SAMPLES_IN_BUFFER.[/quote]
&lt;p&gt;&amp;nbsp;You need to do several samples to trigger the event. As of now, you start with&amp;nbsp;adc_complete=true, and you trigger one sample, and then you wait for the event before setting adc_complete to true again. But this will not happen before you do 4 more samples, because your SAMPLES_IN_BUFFER = 5, and you need to fill this buffer with samples before you get the saadc callback event.&lt;/p&gt;
&lt;p&gt;Also, you don&amp;#39;t process your logging, so even if you would get the ADC events, you wouldn&amp;#39;t see it in your log, because NRF_LOG_FLUSH() is commented out.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Have you tried the saadc example from SDK\examples\peripheral\saadc ?&lt;/p&gt;
&lt;p&gt;Try to copy all of the functions from this example. saadc_init(), saadc_sampling_event_init() and saadc_sampling_event_enable(), and for good measure, include NRF_LOG_FLUSH() and nrf_pwr_mgmt_run() as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 ADC</title><link>https://devzone.nordicsemi.com/thread/168601?ContentTypeID=1</link><pubDate>Wed, 30 Jan 2019 06:36:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b17207c6-35c1-40fe-96b3-198b6c0e6d0a</guid><dc:creator>Fiske</dc:creator><description>&lt;p&gt;I have followed your instruction. However, the&amp;nbsp;saadc_callback still cannot be triggered. attached please find my main.c and sdk_config.h file&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/4405.sdk_5F00_config.h"&gt;devzone.nordicsemi.com/.../4405.sdk_5F00_config.h&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/047883.main.c"&gt;devzone.nordicsemi.com/.../047883.main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 ADC</title><link>https://devzone.nordicsemi.com/thread/168179?ContentTypeID=1</link><pubDate>Mon, 28 Jan 2019 10:04:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56151ec5-d752-40e9-8f90-6e2789458d19</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;No. the buffer_convert will not trigger the sampling task for the saadc.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you look in the saadc example there are two functions, saadc_sampling_event_init() and saadc_sampling_event_enable(). It is not trivial, but what these functions do is to connect the sampling function to a timeout callback of a timer using the PPI (which is done in saadc_sampling_event_enable()) and then enable this link (which is done in saadc_sampling_event_enable()).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can either use this approach to trigger the samples. Each time a sample is trigged, one sample is taken (one sample per channel, if several saadc_channels are enabled, but it looks like you only have one). Note that you have to do&amp;nbsp;n&lt;span&gt;&amp;nbsp;&lt;/span&gt;samples before the saadc callback is called, where n = SAMPLES_IN_BUFFER.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To play around with the sampling event, I made a project that triggers one sample by a button press. The main.c and sdk_config.h file for this project is included here. It should work if you replace main.c and sdk_config.h from the saadc example from SDK15.2.0 with these. Note that it does not use saadc_sampling_event_enable() and saadc_sampling_event_enable(), but the button_handler to trigger the saadc_sampling.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-bb6b385aa2204f5d981076068adcf3f2/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-bb6b385aa2204f5d981076068adcf3f2/sdk_5F00_config.h"&gt;devzone.nordicsemi.com/.../sdk_5F00_config.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&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: nRF52832 ADC</title><link>https://devzone.nordicsemi.com/thread/167507?ContentTypeID=1</link><pubDate>Thu, 24 Jan 2019 02:13:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:866c12ac-9273-4063-9165-017ad5d53072</guid><dc:creator>Fiske</dc:creator><description>&lt;div&gt;Dear Edvin,&lt;br /&gt;Below is my code. nrf_drv_saadc_buffer_convert() is called at saadc_init(). Therefore, I expect that&amp;nbsp; saadc_callback will be called after the conversion is completed. Right?&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;void saadc_callback(nrf_drv_saadc_evt_t const * p_event)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret_code_t err_code;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAMPLES_IN_BUFFER);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;/div&gt;
&lt;div&gt;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;br /&gt;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_LOG_INFO(&amp;quot;ADC event number: %d&amp;quot;, (int)m_adc_evt_counter);&lt;br /&gt;/*&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 0; i &amp;lt; SAMPLES_IN_BUFFER; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_LOG_INFO(&amp;quot;%d&amp;quot;, p_event-&amp;gt;data.done.p_buffer[i]);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_adc_evt_counter++;&lt;br /&gt;*/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;void saadc_init(void)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret_code_t err_code;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_saadc_channel_config_t channel_config =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_init(NULL, saadc_callback);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;/div&gt;
&lt;div&gt;}&lt;/div&gt;
&lt;div&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;//&amp;nbsp;&amp;nbsp; signed int temperature;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bsp_board_init(BSP_INIT_LEDS);&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(NRF_LOG_INIT(NULL));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_LOG_DEFAULT_BACKENDS_INIT();&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; saadc_init();&lt;/div&gt;
&lt;div&gt;//&amp;hellip;&amp;hellip;&amp;hellip;&amp;nbsp; followed by the SPI code&lt;br /&gt;&amp;nbsp;}&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 ADC</title><link>https://devzone.nordicsemi.com/thread/167426?ContentTypeID=1</link><pubDate>Wed, 23 Jan 2019 14:59:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78d48b98-6313-4402-85de-1f4b07d60a01</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Where do you trigger your saadc samples from? Where is nrf_drv_saadc_sample() called? Can I see your entire main.c file?&lt;/p&gt;
&lt;p&gt;&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></channel></rss>