<?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 measurement results change when switching from debug to release</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111213/adc-measurement-results-change-when-switching-from-debug-to-release</link><description>I use one channel of the SAADC on nRF52832 to measure the power supply voltage. Code for configuration &amp;amp; operation of SAADC attached: 
 
 Short description: 
 - Configure the SAADC once by calling ADC_Init (). 
 - Each time you need a measurement, call</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 27 May 2024 17:40:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111213/adc-measurement-results-change-when-switching-from-debug-to-release" /><item><title>RE: ADC measurement results change when switching from debug to release</title><link>https://devzone.nordicsemi.com/thread/486058?ContentTypeID=1</link><pubDate>Mon, 27 May 2024 17:40:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcbd98f3-d6e7-432a-abe5-a3fd8d5ada6e</guid><dc:creator>Sigurd</dc:creator><description>[quote user="MartinZ"]Yes, it does disappear.[/quote]
&lt;p&gt;&lt;span&gt;Sounds like the compiler is doing some optimization on the &amp;#39;vin&amp;#39; variable then. Try declaring it as volatile.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Change&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t vin = p_event-&amp;gt;data.done.p_buffer[0]; // vin = Digits * Reference / Gain / 2^resolution&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;to&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;b&gt;&lt;/b&gt;&lt;pre class="ui-code" data-mode="text"&gt;volatile uint32_t vin = p_event-&amp;gt;data.done.p_buffer[0]; // vin = Digits * Reference / Gain / 2^resolution&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC measurement results change when switching from debug to release</title><link>https://devzone.nordicsemi.com/thread/485921?ContentTypeID=1</link><pubDate>Sun, 26 May 2024 10:55:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82a96b75-bf67-4cc7-9775-d63375905eac</guid><dc:creator>MartinZ</dc:creator><description>&lt;p&gt;Yes, it does disappear. I used this as a &amp;quot;fix&amp;quot; in the meantime, but it&amp;#39;s not very reassuring. I started to ask myself what else might break when switching from debug to release build, without being noticed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC measurement results change when switching from debug to release</title><link>https://devzone.nordicsemi.com/thread/485743?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 08:25:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0c65478-3ecf-46de-972c-f72abf7927c2</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;If you take your project, and change the release configuration from &amp;quot;Optimize for Size&amp;quot;, to None. Does the issue disappear?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1716539071639v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC measurement results change when switching from debug to release</title><link>https://devzone.nordicsemi.com/thread/484759?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 16:28:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54caa4d5-8aee-48d7-80af-fefe7671b20a</guid><dc:creator>MartinZ</dc:creator><description>&lt;p&gt;It&amp;#39;s a custom board, I don&amp;#39;t have a DK for this MCU. But we&amp;#39;ve done another project on this same board before, and there, voltage measurement was working fine both in debug and release mode.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC measurement results change when switching from debug to release</title><link>https://devzone.nordicsemi.com/thread/484747?ContentTypeID=1</link><pubDate>Thu, 16 May 2024 15:10:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8289fe2e-75a8-442a-903f-d81f41934422</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Is this issue observed on a custom board? Do you see the same on the DK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>