<?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>Can not using function contain while loop in setup</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87068/can-not-using-function-contain-while-loop-in-setup</link><description>Hi, I&amp;#39;m facing an weird problem when I use an function that is contain while loop 
 
 When I uncommented the 35th line =&amp;gt; call GPS_init_usingWhile(GPS_RMC,RMC_response); =&amp;gt; here is my debug terminal 
 
 Here is when I commented the 35th =&amp;gt; don&amp;#39;t call</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Apr 2022 06:42:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87068/can-not-using-function-contain-while-loop-in-setup" /><item><title>RE: Can not using function contain while loop in setup</title><link>https://devzone.nordicsemi.com/thread/364087?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 06:42:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d6ceb1f-1b55-45d7-9917-99aea49e541d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Those are the two main things to do in sleep.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;By default, the examples use Deferred logging in order to not spend too much time on the logging in the application. This is to get closer to the behavior when you turn off the log later (so that the timing in the application is not too much different in a release FW compared to the debug FW). This means that you would need to process the log somewhere, and this is done in the idle_state_handle().&lt;/p&gt;
&lt;p&gt;After the log is processed (if the log is enabled), the device will go to sleep to save power.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not using function contain while loop in setup</title><link>https://devzone.nordicsemi.com/thread/363994?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 14:32:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f6675af-f324-4377-a0ec-65aec8011869</guid><dc:creator>John12</dc:creator><description>&lt;p&gt;Hi Edvin, can you explain more clearly about idle_state_handle() what is purpose of this function?&lt;br /&gt;I think it check if nRF have no anything to handle and keep nRF sleep.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not using function contain while loop in setup</title><link>https://devzone.nordicsemi.com/thread/363760?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2022 07:11:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8e76489-2ad5-48cf-b0ab-72294e62dc2d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I think there is a misunderstanding here. If you uncomment GPS_init_using_While(...), you should see that you are actually inside that while loop. If you press the &amp;quot;pause&amp;quot; button when you are debugging, you should see that this is the case.&lt;/p&gt;
&lt;p&gt;The thing is that when you are in this while loop (that you never exit, because of the while (1), then the nRF52832 will never reach&amp;nbsp;idle_state_handle(), which will actually process and print the log over the UART.&lt;/p&gt;
&lt;p&gt;So either you need to call it only a limited amount of times&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void GPS_init_usingWhile(char* configCommand, char *expectedResponse) {
    uint16_t counter=0;
    NRF_LOG_INFO(&amp;quot;call GPS init using while&amp;quot;);
    while(1){
        NRF_LOG_INFO(&amp;quot;in while loop&amp;quot;);
        counter++;
        if (counter &amp;gt; 5)
        {
            break;
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or you can disable deferred logging in sdk_config.h by setting&amp;nbsp;NRF_LOG_DEFERRED to 0. This will cause the nRF to process the logging during runtime, and not in idle_state_handle().&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not using function contain while loop in setup</title><link>https://devzone.nordicsemi.com/thread/363718?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 21:13:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:175d1b72-df40-4244-b812-1603b1ed93a4</guid><dc:creator>qwertynoon</dc:creator><description>&lt;p&gt;I just saw it now&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Actualy this is &amp;quot;bad&amp;quot; implementation to cycle NRF_LOG_INFO into while(1)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;while(1) while(NRF_LOG_PROCESS() != NRF_SUCCESS);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not using function contain while loop in setup</title><link>https://devzone.nordicsemi.com/thread/363717?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 21:10:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3adf1401-4c07-4c14-9171-eebe43c31dc8</guid><dc:creator>qwertynoon</dc:creator><description>&lt;p&gt;I think RTT debug does not have time to print your debug info.&lt;/p&gt;
&lt;p&gt;Try to insert next line in your for(;;) loop&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;while(NRF_LOG_PROCESS() != NRF_SUCCESS);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>