<?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>Do Long delays in main loop cause problems? (possible brownout problem)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/24304/do-long-delays-in-main-loop-cause-problems-possible-brownout-problem</link><description>I&amp;#39;m using nrf_delay_ms to trigger a series of beeps though a speaker using PWM, but I seem to have intermittent problems with this when the device is connected. 
 Basically my Android app, connects to the &amp;quot;beacon&amp;quot; and write to a characteristic with a</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Aug 2017 23:00:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/24304/do-long-delays-in-main-loop-cause-problems-possible-brownout-problem" /><item><title>RE: Do Long delays in main loop cause problems? (possible brownout problem)</title><link>https://devzone.nordicsemi.com/thread/95676?ContentTypeID=1</link><pubDate>Mon, 14 Aug 2017 23:00:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24422f77-18c9-4dbe-a593-e18999a7fe73</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;I&amp;#39;ve now attached an oscilloscope across the battery on this device, and I think the problem is the CR2477 battery can&amp;#39;t supply the necessary current to run the buzzer device that was fitted by the manufacturer :-(&lt;/p&gt;
&lt;p&gt;On the scope I see the voltage drops to 1.6V in the worst case, (below the minamum for the nRF51)&lt;/p&gt;
&lt;p&gt;The strange thing is,that the CPU side of the nRF51 seems to be running OK. Because after 30 second an application timer fires and my code disconnects so that the device does not get permanently left turned but idle.
However, I do not get a disconnection notification either in the nRF51 code or from the Android end.&lt;/p&gt;
&lt;p&gt;iOS seems to be different. If I try to write to the device, iOS immediately notices even though the characteristic is WriteWithoutResponse.&lt;/p&gt;
&lt;p&gt;I will need to replace the buzzer with a lower current device, but I thought I&amp;#39;d post the resolution in case it helps anyone.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do Long delays in main loop cause problems? (possible brownout problem)</title><link>https://devzone.nordicsemi.com/thread/95675?ContentTypeID=1</link><pubDate>Sun, 13 Aug 2017 23:20:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1242f883-b0ff-423f-8ca0-2fbf9d020025</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;@RK&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;You are right...&lt;/p&gt;
&lt;p&gt;Changing this has not fixed the problem :-(&lt;/p&gt;
&lt;p&gt;So I&amp;#39;ll need to check if its a power /voltage issue.&lt;/p&gt;
&lt;p&gt;Its strangely intermittent.&lt;/p&gt;
&lt;p&gt;It can start to work, OK, even if I upload or reset the board multiple times&lt;/p&gt;
&lt;p&gt;But if I unplug and put it on its battery, it fails again, and does not start working again when I put it back on the PSU from the PC.&lt;/p&gt;
&lt;p&gt;On the PC I have a 1A regulator from the 5V, so it won&amp;#39;t be short of current&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do Long delays in main loop cause problems? (possible brownout problem)</title><link>https://devzone.nordicsemi.com/thread/95674?ContentTypeID=1</link><pubDate>Sun, 13 Aug 2017 22:43:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23ea2488-95d3-4910-80ce-a23bf1695604</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;no there wouldn&amp;#39;t be junk left on the stack, the pre- and post- code would put the stack back exactly as it was before the call. However if your declaration and definition were different and the code actually tried to use that data in those parameters, it would read rubbish out of r0 and r1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do Long delays in main loop cause problems? (possible brownout problem)</title><link>https://devzone.nordicsemi.com/thread/95673?ContentTypeID=1</link><pubDate>Sun, 13 Aug 2017 22:23:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fd5611b-7a18-4e0b-9bda-46d162fdbb05</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;I think I found a bug in my code which is potentially causing the problem&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void findMeBeeps(void) 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;should be&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void findMeBeeps(void * p_event_data, uint16_t event_size)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So there would be junk left on the stack which sometimes caused the system some problems&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure if this totally fixes the problem or whether there is something else wrong.&lt;/p&gt;
&lt;p&gt;But that code was definitely wrong.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do Long delays in main loop cause problems? (possible brownout problem)</title><link>https://devzone.nordicsemi.com/thread/95672?ContentTypeID=1</link><pubDate>Sun, 13 Aug 2017 21:19:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37120ad5-1355-4077-b752-2757c698b162</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;Thanks.
I will rule out hogging the main loop as the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do Long delays in main loop cause problems? (possible brownout problem)</title><link>https://devzone.nordicsemi.com/thread/95671?ContentTypeID=1</link><pubDate>Sun, 13 Aug 2017 11:34:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0062a70-0f70-4cd9-910e-6511548d4ceb</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;In general you can lock up the main loop as long as you like. It&amp;#39;s running at the lowest priority possible so the softdevice and every kind of interrupt handler out there interrupts it whenever it wants. So you&amp;#39;re not really blocking anything.&lt;/p&gt;
&lt;p&gt;If you have time-sensitive code in your loop, that might be an issue. If you have an interrupt which is higher priority than softdevice low priority and that REALLY drags, you might cause issues, but apart from that, it&amp;#39;s pretty hard to mess it up.&lt;/p&gt;
&lt;p&gt;Consider that the default no-sleep main loop is often written as&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;while(1)
    ;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and that works fine - you can see a main loop which just burns electrons isn&amp;#39;t really a problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Do Long delays in main loop cause problems? (possible brownout problem)</title><link>https://devzone.nordicsemi.com/thread/95670?ContentTypeID=1</link><pubDate>Sun, 13 Aug 2017 11:32:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f15fcf8-7287-4627-bf8c-cdb7d79a60a7</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;Just to update this.&lt;/p&gt;
&lt;p&gt;I think perhaps this is some sort of power problem.&lt;/p&gt;
&lt;p&gt;I powered the device from a 3V 1000mAH lithium cell, and tried again, and the problem returned, even though I had not uploaded any new code.&lt;/p&gt;
&lt;p&gt;I put it back in the bench power supply, but the problem still persists&lt;/p&gt;
&lt;p&gt;Which is very odd.&lt;/p&gt;
&lt;p&gt;The beeper does not seem to completely crash the device, because I have a 30 second timer running, which I use to close open connections to the Android app, in case the android app does not auromatically close the connection.&lt;/p&gt;
&lt;p&gt;So after 30 secs the connection is closed and I can press the button on the App again, to send the command to beep, and it works - just once&lt;/p&gt;
&lt;p&gt;I will probably unsolder the beeper off one board and replace it with a LED send see if it still has this strange behaviour&lt;/p&gt;
&lt;p&gt;PS. I forgot to say I&amp;#39;m using a nRF51822 custom board, with SDK 12.3&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>