<?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>Code only runs in debugging</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35773/code-only-runs-in-debugging</link><description>Hello, 
 I have nRF52832 with custom board and using SDK15 with Keil uVISION 5. I am working on beacon example and I have modified it to show battery level. I have done necessary changes for SAADC. 
 I am getting values too but only when I do step by</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Jun 2018 09:02:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35773/code-only-runs-in-debugging" /><item><title>RE: Code only runs in debugging</title><link>https://devzone.nordicsemi.com/thread/138044?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 09:02:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ad802c5-224b-4735-bf6a-71abc07ec227</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;You could loop over it to ensure that it is fetched when it&amp;#39;s non-zero, similar to this:&lt;/p&gt;
&lt;p&gt;do&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;es_battery_voltage_get(&amp;amp;vbatt);&lt;/p&gt;
&lt;p&gt;} while (vbatt == 0);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code only runs in debugging</title><link>https://devzone.nordicsemi.com/thread/137780?ContentTypeID=1</link><pubDate>Wed, 27 Jun 2018 04:16:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13b46f17-009f-4a79-ab40-48c532e6f8bd</guid><dc:creator>Vishwas Jain</dc:creator><description>&lt;p&gt;Thank you Hakon,&lt;/p&gt;
&lt;p&gt;I moved es_battery_voltage_get() just before setting it as the manufacturer data and disabled the logging but it is not working. To check, I kept es_battery_voltage_get() in advertising function only and enabled the logging and now everything works fine!&lt;/p&gt;
&lt;p&gt;I also tried to add delay(500ms) between these two, _init() &amp;amp; _get() functions but didn&amp;#39;t work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code only runs in debugging</title><link>https://devzone.nordicsemi.com/thread/137704?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 13:49:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5fbe9fd-28d8-42d9-b9a9-4321fbf6b63e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;I suspect that this added a smaller delay, allowing the SAADC callback handler to execute before you call es_battery_voltage_get(), so that you got the correct value. Best option is to move the call further in time so that you do not end up in this scenario again when disabling logging.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code only runs in debugging</title><link>https://devzone.nordicsemi.com/thread/137681?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 12:35:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42315c0b-035b-4e24-a43e-641f5fe26674</guid><dc:creator>Vishwas Jain</dc:creator><description>&lt;p&gt;I do not know the reason but I did &lt;em&gt;SAADC_CONFIG_LOG_ENABLED 1 &lt;/em&gt;in sdk_config.h and the true values start broadcasting.&lt;/p&gt;
&lt;p&gt;Can it be the problem? If yes, why was it the problem because it is just a log info, nothing to do with values. &lt;/p&gt;
&lt;p&gt;If no, then according to your suggestion, I would try to add delay between es_battery_voltage_get() &amp;amp; es_battery_voltage_init().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Code only runs in debugging</title><link>https://devzone.nordicsemi.com/thread/137676?ContentTypeID=1</link><pubDate>Tue, 26 Jun 2018 12:27:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:184f65d2-c89c-4b02-864e-5e0ed8b2107a</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The es_battery_voltage_saadc library will initially start a conversion, and if you call&amp;nbsp;es_battery_voltage_get() straight after the _init(), it will not be done yet and you will get the default value (0) back.&lt;/p&gt;
&lt;p&gt;Could you try to call&amp;nbsp;es_battery_voltage_get() just before setting it as the manufacturer data in your advertising payload, and see if this works better?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>