<?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>Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9901/getting-different-adc-readings-when-using-jlink-debugging-than-when-not</link><description>I have built a PCB that includes the nRF51822. I have AIN7 reading an input voltage that I measure on my DMM at 269mV. 
 When I measure the voltage through the nRF51822&amp;#39;s ADC, I get 261 mV when the code is run through Eclipse debugging with the nRF51</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Oct 2015 08:29:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9901/getting-different-adc-readings-when-using-jlink-debugging-than-when-not" /><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36729?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2015 08:29:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41d88bc2-d40f-4866-b16e-be418d3d6864</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;So it is a very slow power ramp-up that causes the problem?
The ADC core is shut down completely when the ADC is disabled. You could therefore try to disable the ADC, wait 2us, and enable the ADC again before sampling.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36728?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2015 09:49:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98dcbc0b-b624-4909-ba48-8422d905d22d</guid><dc:creator>i_am_trying</dc:creator><description>&lt;p&gt;I isolated the problem of incorrect ADC reading (i.e.: saturated 1.2V reading) to happen when ADC sampling request occurs within 10-100ms of supplying 3V power from a bench power supply (note: This does not occur when immediately supplying 3V power from a battery).&lt;/p&gt;
&lt;p&gt;What I don&amp;#39;t understand: subsequent samplings maintain the saturated reading as if the ADC is &amp;quot;stuck&amp;quot; ...i.e.: the initial reading caused the ADC to not be set up to sample correctly.  I would like to understand why this is happening however it would take more internal knowledge on the specifics of how the ADC works (which I do not have).&lt;/p&gt;
&lt;p&gt;A &amp;quot;hack/fix&amp;quot; is to delay taking an ADC sample to about 1/2 second after a reboot (in the case the power source is mains/power bench).&lt;/p&gt;
&lt;p&gt;Thank you very much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36727?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 13:09:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bc71803-ab3b-4916-bc4d-3e9c6e9c7063</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;the radio enables the high frequency crystal before BLE event yes, but then it is disabled again when the BLE radio event finishes. If the application requests the crystal, the crystal will be enabled for the ADC operation even though the radio is not enabled.&lt;/p&gt;
&lt;p&gt;I am not sure if I have further ideas at this point. Have you tried to sample on a different AIN pin?&lt;/p&gt;
&lt;p&gt;How are you testing the value without the debugger? Are you printing the ADC value on UART?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36725?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 11:48:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:648e0453-5a4f-40e9-81e1-f625f3e9459d</guid><dc:creator>i_am_trying</dc:creator><description>&lt;p&gt;Thank you.  I tried this.  However, enabling the high frequency clock (using the method with the softdevice) had no effect.  I was wondering given the radio requires the high frequency xtal, shouldn&amp;#39;t this already be enabled?  Hmmm..any other suggestions greatly appreciated!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36724?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 11:00:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d35b02c-04e4-4616-b393-659df72f85b4</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Try to enable the high frequency crystal for better accuracy. The code to do that is &lt;a href="https://github.com/NordicSemiconductor/nrf51-ADC-examples/blob/master/rtc0_triggering_ADC_sample_from_GPIO_pin/main.c"&gt;here&lt;/a&gt; when not using the softdevice, see the hfclk_config function.  &lt;a href="https://github.com/NordicSemiconductor/nrf51-ADC-examples/blob/master/adc-example-with-softdevice/main.c"&gt;Here&lt;/a&gt; is code to enable it when the softdevice is enabled, enable it with sd_clock_hfclk_request() and disable it with sd_clock_hfclk_release()&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36723?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 10:46:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a24f26ec-8ad7-4ae7-bb32-1187ad48c53e</guid><dc:creator>i_am_trying</dc:creator><description>&lt;p&gt;Thank you.  The trace going into the AIN is from an out pin of an op amp.  So the impedance should not be an issue.  Any other thoughts?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36722?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 10:41:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1af07f5-f6df-487b-ba26-1972c36e1ec7</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;LPCOMP: ok, that is not the issue then. The LPCOMP is disabled by default, so if you have not manually enabled it, it should not be enabled. So that is clearly not the issue.&lt;/p&gt;
&lt;p&gt;The circuit connected to the analog input pin should not have high impedance, optimally lower than 1 kohm, even though 5 kohms should be without causing considerable error on the ADC. If you have higher impedance, there are workarounds, e.g. with connecting a capacitor between the AIN pin and ground, as described on &lt;a href="https://devzone.nordicsemi.com/question/990/how-to-measure-lithium-battery-voltage/"&gt;this thread&lt;/a&gt; and &lt;a href="https://devzone.nordicsemi.com/blogs/30/measuring-lithium-battery-voltage-with-voltage-div/"&gt;this thread&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36726?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 09:19:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2df50f21-f23d-4ac6-ae37-62908516ce80</guid><dc:creator>i_am_trying</dc:creator><description>&lt;p&gt;Update: I checked the AC side worked as expected.  E.g.: on a AIN I expected to see 1.46V going in.  This was true in all set ups.&lt;/p&gt;
&lt;p&gt;I then disabled LPCOMP.  I also changed the macro for the clock - I do not have an external crystal on my board.  Neither of these changes made a difference in getting 1.2V when NOT going through Eclipse debugger.&lt;/p&gt;
&lt;p&gt;So - since I observe this behavior only when the SWD lines are being used for debuging (i.e.: nrf51 DK is providing debug out), i assume there is something different when Eclipse/debug reads/writes to the SWD lines?  Does this make sense?  Any thoughts on why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36721?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2015 16:09:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e52b30f7-ea7a-45c6-b70c-8a420bfc0084</guid><dc:creator>i_am_trying</dc:creator><description>&lt;p&gt;re: LPCOMP.  I truly don&amp;#39;t know.  The code I show above is how I understand getting a reading of the ADC should work.  I have read that if the softdevice is there, LPCOMP should be disabled.  But not sure what to add to the code above?&lt;/p&gt;
&lt;p&gt;I am using the same power source that is powering the nRF51822 to create a voltage divider.  The circuit should not have a high impedance. ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Getting different ADC readings when using JLink debugging than when not</title><link>https://devzone.nordicsemi.com/thread/36720?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2015 16:02:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54a5a5ad-079f-4e4b-be2a-86c93d478d52</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I dont think I have seen this issue before. Some thoughts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is the result different if you use another analog input pin, e.g. #5 ?, just thinking that there is possibly another adjacent pin that has some activity that causes disturbance.&lt;/li&gt;
&lt;li&gt;Do you have LPCOMP enabled. That is known to cause some issues.&lt;/li&gt;
&lt;li&gt;What are you measuring on the analog input pin? Does the external circuit have high impedance?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>