<?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>adc clock in nrf51</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19440/adc-clock-in-nrf51</link><description>what is minimum clock at which adc can operate in nrf51??. can anyone tell me??
how to change adc clock in nrf51??. i am using sdk11</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 07 Feb 2017 15:31:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19440/adc-clock-in-nrf51" /><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75510?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2017 15:31:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a28d3753-5d9b-463b-bb54-0b588fd20dfd</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;I commented out the printfs at the start, and commented out the nrf_delay_ms, and I measured 1.48mA on a nRF51-DK. Note that you are continuously sampling the ADC. If you don&amp;#39;t need continuous sampling of the ADC, I recommend setting up a app-timer that starts the ADC sample e.g. every 100ms. This will decrease the power consumption further.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75509?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2017 05:41:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47633491-0702-403d-b6f1-9801c57c5feb</guid><dc:creator>nordicbeginner</dc:creator><description>&lt;p&gt;Hi I removed delay part and i get 4 ma current&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75508?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2017 13:15:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c3816a3-93fc-475f-9fc3-d6701f9c79f0</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;During the delay (&lt;code&gt;nrf_delay_ms(..)&lt;/code&gt;) the CPU will be running and the current draw will large (several milliamps).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75504?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2017 12:02:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8414ed1e-62c4-4839-87b8-538866e38933</guid><dc:creator>nordicbeginner</dc:creator><description>&lt;p&gt;i use this code and then measure current and i am getting 11 mA&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75506?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2017 11:59:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70b56550-6f8c-4024-80da-113491491271</guid><dc:creator>nordicbeginner</dc:creator><description>&lt;p&gt;/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is property of Nordic Semiconductor ASA.
* Terms and conditions of usage are described in detail in NORDIC
* SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
*
* Licensees are granted free, non-transferable use of the information. NO
* WARRANTY of ANY KIND is provided. This heading must NOT be removed from
* the file.
*
*/&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/** @file
 * @defgroup nrf_adc_example main.c
 * @{
 * @ingroup nrf_adc_example
 * @brief ADC Example Application main file.
 *
 * This file contains the source code for a sample application using ADC.
 *
 * @image html example_board_setup_a.jpg &amp;quot;Use board setup A for this example.&amp;quot;
 */
 
#include &amp;quot;nrf.h&amp;quot;

#ifdef NRF51

#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;nrf_adc.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

volatile int32_t adc_sample;

#define UART_TX_BUF_SIZE 256 /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE 1   /**&amp;lt; UART RX buffer size. */

#ifndef NRF_APP_PRIORITY_HIGH
#define NRF_APP_PRIORITY_HIGH 1
#endif

/**
 * @brief UART events handler.
 */
void uart_events_handler(app_uart_evt_t * p_event)
{
    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_COMMUNICATION_ERROR: APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:          APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        case APP_UART_TX_EMPTY:            
            break;

        default: break;
    }
}


/**
 * @brief ADC interrupt handler.
 */
void ADC_IRQHandler(void)
{
    nrf_adc_conversion_event_clean();

    adc_sample = nrf_adc_result_get();
}


/**
 * @brief UART initialization.
 */
void uart_config(void)
{
    uint32_t                     err_code;
    const app_uart_comm_params_t comm_params =
    {
        RX_PIN_NUMBER,
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        APP_UART_FLOW_CONTROL_DISABLED,
        false,
        UART_BAUDRATE_BAUDRATE_Baud38400
    };

    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_events_handler,
                       APP_IRQ_PRIORITY_LOW,
                       err_code);

    APP_ERROR_CHECK(err_code);
}


/**
 * @brief ADC initialization.
 */
void adc_config(void)
{
    const nrf_adc_config_t nrf_adc_config = NRF_ADC_CONFIG_DEFAULT;

    // Initialize and configure ADC
    nrf_adc_configure( (nrf_adc_config_t *)&amp;amp;nrf_adc_config);
    nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_2);
    nrf_adc_int_enable(ADC_INTENSET_END_Enabled &amp;lt;&amp;lt; ADC_INTENSET_END_Pos);
    NVIC_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH);
    NVIC_EnableIRQ(ADC_IRQn);
}


/**
 * @brief Function for main application entry.
 */
int main(void)
{
    adc_config();

    //uart_config();

    printf(&amp;quot;\n\rADC HAL simple example\r\n&amp;quot;);

    printf(&amp;quot;Current sample value:\r\n&amp;quot;);

    while (true)
    {
			  // trigger next ADC conversion
			  nrf_adc_start();
        // enter into sleep mode
        __SEV();
        __WFE();
        __WFE();
			
			  nrf_delay_ms(1000);
         float value = (float)((adc_sample*3.6)/1024);		
    int    adc_sample1;
    uint8_t b_percent;
      adc_sample1 =(int)adc_sample;		
       if(adc_sample1 &amp;gt; 835)
			 {
			   b_percent = 0x64;
			 }				 
			else if(adc_sample1 &amp;lt; 480)
			 {
			   b_percent =0x00;
				 
			 }
			 else
			 b_percent = ((adc_sample1-480)*100/355);
			//	printf(&amp;quot;%d\r\n&amp;quot;, (int)adc_sample); // out ADC result
		//	printf(&amp;quot;%f\r\n&amp;quot;, (float)value); // out ADC result
		//	printf(&amp;quot;%d\r\n&amp;quot;, adc_sample1); // out ADC result
			// printf(&amp;quot;%x\r\n&amp;quot;, b_percent);
    }
}

#endif /* NRF51 */

/** @} */
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75512?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2017 08:26:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7831c4e-f32a-40c9-8212-48f79ba021c5</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;You don&amp;#39;t have any measurements?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75511?ContentTypeID=1</link><pubDate>Mon, 06 Feb 2017 06:51:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b29847c8-2f2b-462b-bcaf-d104adb1b735</guid><dc:creator>nordicbeginner</dc:creator><description>&lt;p&gt;I2C and adc peripherals are active&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75505?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 14:41:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:212fe3d1-8199-489b-b007-cb8ac181499f</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;What kind of current consumption are you seeing? What other peripherals are active?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75503?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 09:02:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2d6416e-e11a-47aa-9d99-543aefc781e3</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;The crystal oscillator consumes less power (470 uA) as compared to the RC oscillator (750 uA). If the ADC operation is sporadic with waking up from sleep in low power mode, the time to start the crystal oscillator may offset the power saving.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75507?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 07:51:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66a21be7-b01e-4e30-a862-32388f9563ab</guid><dc:creator>nordicbeginner</dc:creator><description>&lt;p&gt;can we use RC oscillator for adc??. because my adc consumes much power&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adc clock in nrf51</title><link>https://devzone.nordicsemi.com/thread/75502?ContentTypeID=1</link><pubDate>Fri, 03 Feb 2017 06:48:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87683d05-20d4-4605-90cf-6ad9273c6a41</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;All peripherals use the 16 MHz clock for their operation, including the ADC. The ADC accuracy improves when you use the 16 MHz crystal instead of the RC oscillator.&lt;/p&gt;
&lt;p&gt;So there is no clock configuration required for the ADC in nRF51.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>