<?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>How to read the value from ADC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/384/how-to-read-the-value-from-adc</link><description>Hi, 
 i want to use the adc, i use the code from here devzone.nordicsemi.com/.../is-there-an-example-code-for-using-pwm-on-the-nrf51822-with-a-softdevice and it works fine. But i don#t know how to handle the -&amp;gt;Result when i got 5 ADC Channels to use</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 11 Oct 2017 07:04:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/384/how-to-read-the-value-from-adc" /><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2014?ContentTypeID=1</link><pubDate>Wed, 11 Oct 2017 07:04:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b55be75-35c2-4890-8e42-2aa0951f4942</guid><dc:creator>KETAN_PATEL</dc:creator><description>&lt;p&gt;for this example no need to connect any of analog pin to VDD or VCC??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2019?ContentTypeID=1</link><pubDate>Sat, 08 Nov 2014 17:09:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0960884a-3e27-46a0-a279-f8d25cbb5105</guid><dc:creator>Gilson</dc:creator><description>&lt;p&gt;&lt;a href="https://github.com/NordicSemiconductor/nrf51-ADC-examples"&gt;&lt;strong&gt;https://github.com/NordicSemiconductor/nrf51-ADC-examples&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2024?ContentTypeID=1</link><pubDate>Fri, 03 Oct 2014 07:24:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0a688ea-aa1f-4228-b27d-294d3122b280</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;You are welcome. Please vote for the answers that you find helpful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2023?ContentTypeID=1</link><pubDate>Thu, 02 Oct 2014 19:53:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f348356-0db9-4683-a044-87732bd891f6</guid><dc:creator>jonf</dc:creator><description>&lt;p&gt;Stefan&amp;#39;s solution worked very well. I just implemented it with no troubles. Thank you very much.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2018?ContentTypeID=1</link><pubDate>Tue, 03 Jun 2014 18:35:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9646b8c-306a-4f68-9533-fdbc93314626</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;some ADC examples are now available here on Gibhub
&lt;a href="https://github.com/NordicSemiconductor/nrf51-ADC-examples"&gt;github.com/.../nrf51-ADC-examples&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2022?ContentTypeID=1</link><pubDate>Tue, 27 May 2014 12:20:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9d5a584-37e3-438b-bc99-0d57fcba5bdf</guid><dc:creator>Wayne</dc:creator><description>&lt;p&gt;the link is broken,is the zip available somewhere else please?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2021?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2013 11:40:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af16c2e0-9562-4bdf-9c12-480fb69670c9</guid><dc:creator>Nils Minor</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;thank you for your help, but my code works now, after trying soem changing of my code :) Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2020?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2013 10:12:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad7d090f-5be9-48fe-babb-8d97ff8d997c</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Nils&lt;/p&gt;
&lt;p&gt;Sorry for my late entrance into this thread.
I have attached an ADC example code that is perhaps more relevant for your purpose. It samples from two different ADC input pins and stores the result in two different variables. It is tested with the nRF51822 development kit and SDK 4.3&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/adc_5F00_example_5F00_from_5F00_AIN_5F00_8bit_5F00_10bit.zip"&gt;adc_example_from_AIN_8bit_10bit.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2026?ContentTypeID=1</link><pubDate>Mon, 02 Sep 2013 05:47:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b607fc77-ed2a-453f-ae22-17f0dd512c6a</guid><dc:creator>Nils Minor</dc:creator><description>&lt;p&gt;Ahh ok thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2025?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2013 07:59:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6032a6ee-750c-4bb7-8cb0-671b33d96ea4</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;You won&amp;#39;t normally get a quicker answer by posting several replies (that aren&amp;#39;t actual replies, but just bumping) to your own question. We try to tend to all questions here as we have time, but some days are more busy than others. Posting a complete, clear question, with detailed description on what you need to do, what exactly is the problem, and what you&amp;#39;ve already tried is the best way to get a quick reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2017?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2013 07:56:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e41c2ec8-ceb8-40b5-b4b6-20861c11993f</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;The ADC will measure one input at a time, so depending on which input was selected in PSEL when you started the measurement, the RESULT when you get the END event will be the result for this particular input. No special handling of this should be needed; if you need to measure 5 different inputs, you&amp;#39;ll just have to cycle through them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2016?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2013 06:09:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f7c7a82-7ded-462f-a02c-30a02b1f4116</guid><dc:creator>Nils Minor</dc:creator><description>&lt;p&gt;Can anyone explain to me how to handle the RESULT pls?&lt;/p&gt;
&lt;p&gt;thanks Nils&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2015?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2013 12:18:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53799142-e3e3-4865-a7ab-4bb98109c554</guid><dc:creator>Nils Minor</dc:creator><description>&lt;p&gt;Hi,
thanks for the answer.&lt;/p&gt;
&lt;p&gt;Mhh i don&amp;#39;t get it with this code. You also handle only one adc mesurement (adc_result), but i need to handle 5 mesurements from the ADCs but i don#t understand how to use -&amp;gt;ADC_RESULT&lt;/p&gt;
&lt;p&gt;thank you, Nils&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read the value from ADC</title><link>https://devzone.nordicsemi.com/thread/2013?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2013 06:51:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:188f4d13-475c-4859-a66e-6bdea12b4485</guid><dc:creator>S&amp;#233;bastien Despont</dc:creator><description>&lt;p&gt;Here is an example of ADC reading value :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**@brief ADC interrupt handler.
 * @details  This function will fetch the conversion result from the ADC, convert the value into
 *           percentage and send it to peer.
 */
void ADC_IRQHandler(void)
{
    if (NRF_ADC-&amp;gt;EVENTS_END != 0)
    {
        uint8_t     adc_result;
        uint16_t    batt_lvl_in_milli_volts;
        uint8_t     batt_lvl_formatted;			
        uint8_t     percentage_batt_lvl;
        uint32_t    err_code;

        NRF_ADC-&amp;gt;EVENTS_END     = 0;
        adc_result              = NRF_ADC-&amp;gt;RESULT;
        NRF_ADC-&amp;gt;TASKS_STOP     = 1;

        batt_lvl_in_milli_volts = ADC_RESULT_IN_MILLI_VOLTS(adc_result) ;//+ DIODE_FWD_VOLT_DROP_MILLIVOLTS;
        percentage_batt_lvl     = battery_level_in_percent(batt_lvl_in_milli_volts);
				
			  batt_lvl_formatted = batt_lvl_in_milli_volts/100;
			
			  if (batt_lvl_formatted != m_bas.battery_level_last)
        {
					uint16_t len = sizeof(uint8_t);
					
					// Save new battery value
					m_bas.battery_level_last = batt_lvl_formatted;
					
					// Update database
					err_code = sd_ble_gatts_value_set(m_bas.battery_level_handles.value_handle,
																						0,
																						&amp;amp;len,
																						&amp;amp;batt_lvl_formatted);					
				}
        err_code = ble_bas_battery_level_update(&amp;amp;m_bas, percentage_batt_lvl);
        if (
            (err_code != NRF_SUCCESS)
            &amp;amp;&amp;amp;
            (err_code != NRF_ERROR_INVALID_STATE)
            &amp;amp;&amp;amp;
            (err_code != BLE_ERROR_NO_TX_BUFFERS)
            &amp;amp;&amp;amp;
            (err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
        )
        {
            APP_ERROR_HANDLER(err_code);
        }
    }
}


/**@brief Function to make the ADC start a battery level conversion.
 */
static void adc_start(void)
{
    uint32_t err_code;

    // Configure ADC
    NRF_ADC-&amp;gt;INTENSET   = ADC_INTENSET_END_Msk;
    NRF_ADC-&amp;gt;CONFIG     = (ADC_CONFIG_RES_8bit                        &amp;lt;&amp;lt; ADC_CONFIG_RES_Pos)     |
                          (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling &amp;lt;&amp;lt; ADC_CONFIG_INPSEL_Pos)  |
                          (ADC_CONFIG_REFSEL_VBG                      &amp;lt;&amp;lt; ADC_CONFIG_REFSEL_Pos)  |
                          (ADC_CONFIG_PSEL_Disabled                   &amp;lt;&amp;lt; ADC_CONFIG_PSEL_Pos)    |
                          (ADC_CONFIG_EXTREFSEL_None                  &amp;lt;&amp;lt; ADC_CONFIG_EXTREFSEL_Pos);
    NRF_ADC-&amp;gt;EVENTS_END = 0;
    NRF_ADC-&amp;gt;ENABLE     = ADC_ENABLE_ENABLE_Enabled;

    // Enable ADC interrupt
    err_code = sd_nvic_ClearPendingIRQ(ADC_IRQn);
    APP_ERROR_CHECK(err_code);

    err_code = sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);
    APP_ERROR_CHECK(err_code);

    err_code = sd_nvic_EnableIRQ(ADC_IRQn);
    APP_ERROR_CHECK(err_code);

    NRF_ADC-&amp;gt;EVENTS_END  = 0;    // Stop any running conversions.
    NRF_ADC-&amp;gt;TASKS_START = 1;		
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>