<?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 result not changing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9713/adc-result-not-changing</link><description>I&amp;#39;m trying to set up the ADC to read a battery voltage but am unable to get the adc result to change regardless of whether the input line is connected to VDD or GND. I&amp;#39;m using the nRF51-DK, and am configuring AIN5 for my ADC input. I&amp;#39;m reading the ADC</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Feb 2016 15:04:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9713/adc-result-not-changing" /><item><title>RE: ADC result not changing</title><link>https://devzone.nordicsemi.com/thread/35946?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2016 15:04:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6ffef46-e82f-4ebf-b3ae-587eea338d14</guid><dc:creator>MARTIN FR</dc:creator><description>&lt;p&gt;Hello brian, are you testing your battery votlage via USB or cr2032 battery? because for USB 2.89volt as VDD and cr2032 2.62 VDD  i measured in the DK you also getting the same kind of result?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC result not changing</title><link>https://devzone.nordicsemi.com/thread/35945?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2016 15:02:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da486aee-c06f-43c0-8533-e910f9be4ecb</guid><dc:creator>karan</dc:creator><description>&lt;p&gt;Could you share me some piece of detailed inofrmation about how you verfied your abttery voltage in the analog pin 5 ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC result not changing</title><link>https://devzone.nordicsemi.com/thread/35944?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2016 14:57:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d911ed22-29a9-4cf2-a5ee-1143b636df03</guid><dc:creator>Brian</dc:creator><description>&lt;p&gt;Hi Prabhudurai,
Yes, I am getting the correct battery voltage once I made the change that Stefan suggested.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC result not changing</title><link>https://devzone.nordicsemi.com/thread/35943?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2016 08:31:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:679c5180-c8de-4573-a5cc-6a4ced5db542</guid><dc:creator>MARTIN FR</dc:creator><description>&lt;p&gt;Hello Brian could you please tell me whether you got the correct battery voltage reading with this program? because am facing similar kind of issue with the ADC so your ideas or suggestion would be helpful for me to proceed further&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC result not changing</title><link>https://devzone.nordicsemi.com/thread/35942?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 20:26:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b416bd8f-a19d-420a-b746-d59754fa58c7</guid><dc:creator>Brian</dc:creator><description>&lt;p&gt;Hi Stefan,&lt;/p&gt;
&lt;p&gt;That was definitely the issue.  Thanks!  I&amp;#39;m now getting the expected readings with different voltages on the input.  Good catch!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC result not changing</title><link>https://devzone.nordicsemi.com/thread/35941?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 15:47:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25894531-8602-4c3d-b567-6621695c3895</guid><dc:creator>Brian</dc:creator><description>&lt;p&gt;Hi Stefan,&lt;/p&gt;
&lt;p&gt;I am configuring the ADC after the softdevice is configured.  The ADC configuration is one of the last things I do in my initialization.  Also, the values I&amp;#39;ve seen from the ADC result are 0xCA, 0xCB, or 0xCC - so it does actually change values.  Here is a register dump of the ADC registers right after the ADC_IRQHandler reads the ADC result:&lt;/p&gt;
&lt;p&gt;0x40007500  00000001 00002018 000000CC 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000  ..... ..Ì.......................................
0x40007530  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000  ................................................
0x40007560  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000  ................................................
0x40007590  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000  ................................................&lt;/p&gt;
&lt;p&gt;Also, I have verified with a scope that I have 0V on P0.04 when connected to GND and I read ~0xCC from the ADC.  I&amp;#39;ve also verified that when I connect P0.04 to VDD, I have 2.84V on P0.04 and I still read ~0xCC.  It also seems like P0.04 is not mapped to AIN5.  Is it possible for this mapping to be changed to a different port pin?&lt;/p&gt;
&lt;p&gt;And here is my main function.  I have tried removing all of the non-Nordic initialization other than the ADC initialization, but I get the same results.&lt;/p&gt;
&lt;p&gt;int main(void)
{
uint32_t ticks;
uint32_t err_code;
bool erase_bonds;
uint32_t var1;
uint32_t var2;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Initialize.
timers_init();
gpio_init();
uart_init();
system_tick_init();
buttons_leds_init(&amp;amp;erase_bonds);
button_init();
ls_init();
ble_stack_init();
device_manager_init(erase_bonds);
nvm_init();
gap_params_init();

// Comment out the next line to enable single-step debugging
//advertising_init();

services_init();
//sensor_simulator_init();
conn_params_init();

// Start execution.
application_timers_start();
system_tick_start();
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);

app_timer_cnt_get(&amp;amp;ticks);
printf(&amp;quot;%&amp;quot;PRIu32&amp;quot;: Starting Nordic Strobe\r\n&amp;quot;, ticks);


var1 = nvm_read(NVM_mode);
app_timer_cnt_get(&amp;amp;ticks);
printf(&amp;quot;%&amp;quot;PRIu32&amp;quot;: NVM_mode = %&amp;quot;PRIu32&amp;quot;\r\n&amp;quot;, ticks, var1);

var2 = nvm_read(NVM_speed);
app_timer_cnt_get(&amp;amp;ticks);
printf(&amp;quot;%&amp;quot;PRIu32&amp;quot;: NVM_speed = %&amp;quot;PRIu32&amp;quot;\r\n&amp;quot;, ticks, var2);

for(int i=GPIO_LED1; i&amp;lt;=GPIO_LED4; ++i)
{
    gpio_write(i, GPIO_ACTIVE);
    nrf_delay_ms(100);
}

for(int i=GPIO_LED1; i&amp;lt;=GPIO_LED4; ++i)
{
    gpio_write(i, GPIO_INACTIVE);
    nrf_delay_ms(100);
}

uint8_t battery_levels = display_init();
battery_init(battery_levels);
ls_start();
fsm_init();

// Enter main loop.
for (;;)
{
    // Run the state machine if it&amp;#39;s time to
    if (fsm_get_ready())
    {
        fsm_run();
    }

    // Flush NVM if it&amp;#39;s time to
    if (nvm_flush_ready())
    {
        nvm_update();
    }

    // If we&amp;#39;ve advanced past displaying the logo, then...
    if (fsm_get_state() &amp;gt; FSM_STATE_LOGO_DONE)
    {
        // Update the battery level display if it&amp;#39;s changed
        if (battery_level_changed())
        {
            display_battery(battery_get_level());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC result not changing</title><link>https://devzone.nordicsemi.com/thread/35940?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 12:41:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d425734f-27bc-4d0b-8834-6d9083436f1f</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Brian&lt;/p&gt;
&lt;p&gt;First hint: Make sure you configure the ADC after you initialize the softdevice.&lt;/p&gt;
&lt;p&gt;Perhaps &lt;a href="https://devzone.nordicsemi.com/question/53138/application-never-gets-into-adc_irqhandler/"&gt;this link&lt;/a&gt; could be relevant for further hints.&lt;/p&gt;
&lt;p&gt;Just to verify my understanding of the problem, do you always see 0xCC value from the ADC when a breakpoint is hit in the ADC handler?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 14.10.2015&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I see the error now. Instead of writing&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;adc_config.scaling    = NRF_ADC_CONFIG_SCALING_SUPPLY_ONE_THIRD;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;you should write&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;adc_config.scaling    = NRF_ADC_CONFIG_SCALING_INPUT_ONE_THIRD;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That will make the ADC sample from an analog input pin. With your current configuration, you are sampling the supply voltage of the chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>