<?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_event_handler not being called</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54064/saadc_event_handler-not-being-called</link><description>Hello ... 
 New to Nordic SDK and trying to implement SAADC to read battery level. Have looked at a bunch of posts. I started with the ble_app_uart example app and tried to add SAADC code from the proximity example. Here&amp;#39;s relevant code: 
 
 I&amp;#39;ve added</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Nov 2019 19:38:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54064/saadc_event_handler-not-being-called" /><item><title>RE: saadc_event_handler not being called</title><link>https://devzone.nordicsemi.com/thread/218691?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2019 19:38:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71bdca60-0d07-4888-9313-6e35c454489e</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Solution: nrf_drv_saadc allows NULL for p_config in call to&amp;nbsp;nrf_drv_saadc_init and uses default configuration. I&amp;#39;m using nrfx_saadc and&amp;nbsp;&lt;span&gt;nrfx_saadc_init requires non-NULL p_config. Issue resolved once I added:&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;    nrfx_saadc_config_t saadc_config = NRFX_SAADC_DEFAULT_CONFIG;
&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;before calling nrfx_saadc_init and changed call to nrfx_saadc_init to:&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;    ret_code_t err_code = nrfx_saadc_init(&amp;amp;saadc_config, saadc_event_handler);
&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc_event_handler not being called</title><link>https://devzone.nordicsemi.com/thread/218690?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 07:30:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85192ba6-071b-4367-802a-c70897992919</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I made this ticket private then, please share your project when you have time :-)&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc_event_handler not being called</title><link>https://devzone.nordicsemi.com/thread/218689?ContentTypeID=1</link><pubDate>Thu, 31 Oct 2019 04:21:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2992c8e4-61eb-4393-a0dd-ea63df997a61</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Thanks Andreas. I&amp;#39;m currently looking at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/18174/why-there-is-no-easy-api-for-analog-input-of-nrf52-saadc#post-id-106511" rel="noopener noreferrer" target="_blank"&gt;this post and simple example&lt;/a&gt;&amp;nbsp;to see if I can figure it out. If no success, I will kindly accept your offer to look at my project (privately). I&amp;#39;ll followup here in the next days.&lt;/p&gt;
&lt;p&gt;Thanks, -Tim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc_event_handler not being called</title><link>https://devzone.nordicsemi.com/thread/218688?ContentTypeID=1</link><pubDate>Wed, 30 Oct 2019 13:36:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88f8c748-1620-43ea-b5f3-b67e2fa4effd</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Could you share the project you have so I can reproduce the issue?&lt;/p&gt;
&lt;p&gt;I can make the ticket private if you only wish to share it with a Nordic employee :-)&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc_event_handler not being called</title><link>https://devzone.nordicsemi.com/thread/218687?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2019 16:37:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d45191f-a70f-48e5-8cc7-4fdf44ef38c3</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Sure Andreas, sdk_config.h attached.&amp;nbsp;Thanks for you help.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/74106.sdk_5F00_config.h"&gt;devzone.nordicsemi.com/.../74106.sdk_5F00_config.h&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc_event_handler not being called</title><link>https://devzone.nordicsemi.com/thread/218686?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2019 11:41:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad8b64ad-b1e4-4c45-aae2-c5bfa39536b3</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi agian Tim.&lt;/p&gt;
&lt;p&gt;Could you share the whole sdk_config.h file with me so I can see the configuration you&amp;#39;re using?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc_event_handler not being called</title><link>https://devzone.nordicsemi.com/thread/218685?ContentTypeID=1</link><pubDate>Mon, 28 Oct 2019 17:41:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2105823e-e240-4f57-ab8a-f56b4f3c247a</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Thanks Andreas. First, I checked and all err_codes returned from SAADC calls and all are 0. Then I added a debug statement to&amp;nbsp;read_battery_voltage() to see if SAADC is busy:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void read_battery_voltage()
{
    NRF_LOG_DEBUG(&amp;quot;nrfx_saadc_is_busy() is %d&amp;quot;,nrfx_saadc_is_busy());

    ret_code_t err_code;
    err_code = nrfx_saadc_sample();
    APP_ERROR_CHECK(err_code);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and surprisingly it is busy (result is 1). The&amp;nbsp;&lt;span&gt;read_battery_voltage() routine exits normally and the main loop resumes.&amp;nbsp;I&amp;#39;m just learning SAADC and&amp;nbsp;I don&amp;#39;t fully understand what&amp;nbsp;nrfx_saadc_buffer_convert does. Seems I have a buffer of size 2 (static nrf_saadc_value_t adc_buf[2]) and I&amp;#39;ve seen some posts stating that you have to call&amp;nbsp;nrfx_saadc_sample() once for each byte of the buffer. I tried&amp;nbsp;adding a second call to nrfx_saadc_sample()&amp;nbsp;and still&amp;nbsp;saadc_event_handler(...) is not being called.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Advanced thanks for any support.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc_event_handler not being called</title><link>https://devzone.nordicsemi.com/thread/218684?ContentTypeID=1</link><pubDate>Mon, 28 Oct 2019 09:48:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23a779db-4af0-44cf-9a3d-b3db9f00fca6</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hello Tim.&lt;/p&gt;
[quote user=""]The app calls&amp;nbsp;read_battery_voltage() in response to a message sent from the connected BLE central (iOS app).&amp;nbsp;saadc_event_handler(...) is never called.[/quote]
&lt;p&gt;&amp;nbsp;Have you tried to debug and see where the code stops since you say the event handler is never called?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>