<?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</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80723/saadc</link><description>Hello everybody, 
 I wonder if somebody could give me an example of an easy way to use saadc without using any adc_event_handler for sdk 15. 
 I&amp;#39;m trying to do it myself from the saadc example but I&amp;#39;m still not getting out of it. 
 
 I just need to reed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Oct 2021 06:40:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80723/saadc" /><item><title>RE: saadc</title><link>https://devzone.nordicsemi.com/thread/334476?ContentTypeID=1</link><pubDate>Mon, 18 Oct 2021 06:40:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:899aca29-2abc-438e-bf6b-cf456d6ea23f</guid><dc:creator>Ale_K</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;ahh what a coincidence ahah anyways thank you very much for your time and work.&lt;/p&gt;
&lt;p&gt;Greetings&lt;/p&gt;
&lt;p&gt;Ale &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc</title><link>https://devzone.nordicsemi.com/thread/334369?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 13:02:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab469750-0584-49c6-ba03-3df32b22f657</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I had already started on putting together a small example for you, but you beat me to it &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt; Anyway. Here is what I made: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1565.saadc.zip"&gt;devzone.nordicsemi.com/.../1565.saadc.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Looks like it&amp;#39;s quite similar to the one you found.&lt;/p&gt;
&lt;p&gt;The driver documentation can be found here:&amp;nbsp;&lt;span&gt;&lt;a title="SAADC" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/hardware_driver_saadc.html?cp=8_1_2_0_12"&gt;SAADC&lt;/a&gt;&lt;/span&gt; in case you have not seen it already.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: saadc</title><link>https://devzone.nordicsemi.com/thread/334363?ContentTypeID=1</link><pubDate>Fri, 15 Oct 2021 12:56:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68a72fb6-7f88-4f99-93b6-f82830eb5f85</guid><dc:creator>Ale_K</dc:creator><description>&lt;p&gt;I found&amp;nbsp; a solution on youtube:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=5slaFFj2SI4"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;/**&lt;/p&gt;
&lt;p&gt;*/&lt;/p&gt;
&lt;p&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;#include &amp;quot;nrf.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_drv_saadc.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_drv_ppi.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_drv_timer.h&amp;quot;&lt;br /&gt;#include &amp;quot;boards.h&amp;quot;&lt;br /&gt;#include &amp;quot;app_error.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_delay.h&amp;quot;&lt;br /&gt;#include &amp;quot;app_util_platform.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_pwr_mgmt.h&amp;quot;&lt;/p&gt;
&lt;p&gt;#include &amp;quot;nrf_log.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_log_ctrl.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_log_default_backends.h&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;/* Create an empty handler and pass this handler in the saadc initialization function&lt;br /&gt; &amp;gt; Normally this handler deals with the adc events but we are using blocking mode&lt;br /&gt; &amp;gt; In blocking mode the functions are called and the processor waits for the adc to finish taking samples from the respective channels&lt;br /&gt; &amp;gt; Event handler will not be called in this method&lt;br /&gt;*/&lt;/p&gt;
&lt;p&gt;void saadc_callback_handler(nrf_drv_saadc_evt_t const * p_event)&lt;br /&gt;{&lt;br /&gt; // Empty handler function&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;// Create a function which configures the adc input pins and channels as well as the mode of operation of adc&lt;/p&gt;
&lt;p&gt;void saadc_init(void)&lt;br /&gt;{&lt;br /&gt; // A variable to hold the error code&lt;br /&gt; ret_code_t err_code;&lt;/p&gt;
&lt;p&gt;// Create a config struct and assign it default values along with the Pin number for ADC Input&lt;br /&gt; // Configure the input as Single Ended(One Pin Reading)&lt;br /&gt; // Make sure you allocate the right pin.&lt;br /&gt; nrf_saadc_channel_config_t channel_config = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);&lt;/p&gt;
&lt;p&gt;// Initialize the saadc &lt;br /&gt; // first parameter is for configuring the adc resolution and other features, we will see in future tutorial&lt;br /&gt; //on how to work with it. right now just pass a simple null value&lt;br /&gt; err_code = nrf_drv_saadc_init(NULL, saadc_callback_handler);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;// Initialize the Channel which will be connected to that specific pin.&lt;br /&gt; err_code = nrfx_saadc_channel_init(0, &amp;amp;channel_config);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;// A function which will initialize the Log module for us&lt;br /&gt;void log_init(void)&lt;br /&gt;{&lt;br /&gt; // check if any error occurred during its initialization&lt;br /&gt; APP_ERROR_CHECK(NRF_LOG_INIT(NULL));&lt;/p&gt;
&lt;p&gt;// Initialize the log backends module&lt;br /&gt; NRF_LOG_DEFAULT_BACKENDS_INIT();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;/**&lt;br /&gt; * @brief Function for main application entry.&lt;br /&gt; */&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt; // call the log initialization function&lt;br /&gt; log_init();&lt;/p&gt;
&lt;p&gt;// call the saadc initialization function created above&lt;br /&gt; saadc_init();&lt;/p&gt;
&lt;p&gt;// a struct to hold 16-bit value, create a variable of this type because our input resolution may vary from 8 bit to 14 bits depending on our configurations&lt;br /&gt;// this variable holds the adc sample value&lt;br /&gt; nrf_saadc_value_t adc_val;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;// Print a simple msg that everything started without any error&lt;br /&gt; NRF_LOG_INFO(&amp;quot;Application Started!!!&amp;quot;);&lt;br /&gt; NRF_LOG_FLUSH();&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;// Inifinite loop&lt;br /&gt; while (1)&lt;br /&gt; {&lt;br /&gt; // a blocking function which will be called and the processor waits until the value is read&lt;br /&gt; // the sample value read is in 2&amp;#39;s complement and is automatically converted once retrieved&lt;br /&gt; // first parameter is for the adc input channel &lt;br /&gt; // second parameter is to pass the address of the variable in which we store our adc sample value&lt;br /&gt; nrfx_saadc_sample_convert(0, &amp;amp;adc_val);&lt;/p&gt;
&lt;p&gt;// print this value using nrf log : here %d represents the integer value &lt;br /&gt; NRF_LOG_INFO(&amp;quot;Sample value Read: %d&amp;quot;, adc_val);&lt;br /&gt; &lt;br /&gt; // use nrf log and float marker to show the floating point values on the log&lt;br /&gt; // calculate the voltage by this: input_sample * 3.6 / 2^n (where n = 8 or 10 or 12 or 14 depending on our configuration for resolution in bits)&lt;br /&gt; NRF_LOG_INFO(&amp;quot;Volts: &amp;quot; NRF_LOG_FLOAT_MARKER &amp;quot;\r\n&amp;quot;, NRF_LOG_FLOAT(adc_val * 3.6 / 512));&lt;br /&gt; NRF_LOG_FLUSH();&lt;br /&gt; &lt;br /&gt; // give 500ms delay &lt;br /&gt; nrf_delay_ms(500);&lt;br /&gt; &lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>