<?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>nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10306/nrf51-target-behaving-differently-from-dk</link><description>I&amp;#39;ve got a project that works perfectly on the PCA10028 DK. But the behavior is quite different when downloaded to my nRF51822 production target. My target is connected to the DK via the &amp;quot;debug out&amp;quot; connector and I can see it in nRFgo and download the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Nov 2015 22:27:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10306/nrf51-target-behaving-differently-from-dk" /><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38258?ContentTypeID=1</link><pubDate>Mon, 23 Nov 2015 22:27:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98ea66b6-2ff9-4c75-b241-cf995a004155</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;Found the problem. This was a code dependent power supply glitch. No problem using the example code but my test code was creating current spikes. I had only examined the power supply integrity with example code and it was solid. But my application causes bigger spikes. I added a BAC (big-ass-cap) on the power supply pins and all is well (so far).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38255?ContentTypeID=1</link><pubDate>Mon, 23 Nov 2015 17:59:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fed283fc-d11a-4f8e-8019-82aceb899f84</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;I tried using a DK in place of my target and all my code and the example code runs perfectly. The debugger also works fine. RTT is still flaky so you should be able to reproduce that.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think trying to isolate hardware versus software is going to be productive. The example code works fine on my target. My code works fine on the DK. It&amp;#39;s a hardware/software interaction and it&amp;#39;s particular to my use of the hardware to test throughput with a custom Characteristic. I tried using the same technique with the hr monitor code where I send notifies as fast as I can and it works fine on the DK and the target. As soon as I drop in a custom characteristic it breaks (on my target, not the DK).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38257?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 23:02:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9562fd2d-412b-444c-aba4-b3b509e6c03f</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;I&amp;#39;m able to single step into the main for a number of init calls, then it hangs on one of them. The init that hangs varies randomly as far as I can tell. I can also move a breakpoint down the list of inits and hit &amp;quot;run&amp;quot; and see if it reaches a given spot. That result is also completely random. I always have a breakpoint in the app error handler and it&amp;#39;s never hit it.
I&amp;#39;m seeing the code hang at the definition of automatic variables, which is characteristic of stack corruption.&lt;/p&gt;
&lt;p&gt;Since all this weird behavior is completely in the target and never in the DK, is there &lt;em&gt;any&lt;/em&gt; difference between the nRF51822 (my target) and the nRF51422 that might account for this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38256?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 20:24:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57ac5ba5-1190-4241-852b-2a533201033a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for testing, think we can rule out HW issues then. My assumption was based on the fact that you was not able to keep the link on your custom board while it worked with the DK kit. However, later you mention that the advertising function is asserting, which is unexpected because the same parameters should&amp;#39;ve been passed regardless of target.&lt;/p&gt;
&lt;p&gt;Were you able to single step at all after entering main, or is it a after a particular function where you are unable to halt? You can also try to place a breakpoint in the app error handler in  app_error.c and see if it is reached (set DEBUG define to keep it from resetting), and read out the parameters passed to this one if it did.&lt;/p&gt;
&lt;p&gt;Regarding your comments on the clock source;  the clock source is only set once when you call  SOFTDEVICE_HANDLER_INIT, and it will not get passed this if using a non-existent source (i.e., crystal), but you will still be able to halt the core as it&amp;#39;s only in wait loop withing the SD stack.  The application will not overwrite this configuration.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38254?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 19:34:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d9abf44-b720-42b6-b029-cb61df8d35df</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;I really wish the debugger would work on my target. Debugging with printfs is very difficult. I&amp;#39;m still getting the same errors as in the original post when trying to use the debugger.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38253?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 17:12:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f34903a4-bd3b-45f9-8882-5fec75a88007</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;The target advertises and connects fine (to the Android MCP) using the heart rate monitor example so I don&amp;#39;t think it&amp;#39;s a hardware problem. My application (the one that doesn&amp;#39;t work on the target) has a custom characteristic and was derived from the UART example in the BLE Central tutorial.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38252?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 01:14:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95338091-3afd-4f8c-a80f-a415c747afcf</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;OK, I cut loose the external 32KHz crystal on one of my DKs and it still works perfectly. So it&amp;#39;s some other difference between my target and the DK. I&amp;#39;m wrapping up for today and pick it up again tomorrow, including trying any ideas that might be proposed in this thread.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38251?ContentTypeID=1</link><pubDate>Thu, 19 Nov 2015 00:26:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4839623-d44e-4868-86b8-ceacfd88f4ef</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;I&amp;#39;m continuing to try experiments. The latest thing was to switch from fast to slow advertising. In that case  ble_advertising_start(BLE_ADV_MODE_SLOW) returned with an error code 7, invalid parameter. I&amp;#39;m going to look around for an example of slow advertising and try to figure out what parameter it&amp;#39;s hating.&lt;/p&gt;
&lt;p&gt;The next big step will be to cut the 32KHz clock on a DK and see if I can reproduce the problem that way.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38250?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 22:51:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b94ea68-6869-42ec-a045-bbf7944dcfe1</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;Is there a separate setting to control which clock the advertising module uses?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38249?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 22:50:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3742eb06-1479-4201-8b2c-a622990d1c37</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;It turns out that my diagnostic printfs were just not getting flushed before the nRF51 crashed. I added a spin-wait after the printf and now I can trace through the code with printfs.&lt;/p&gt;
&lt;p&gt;The problem is inside ble_advertising_start(BLE_ADV_MODE_FAST). On the DK, this works fine. On my target, it never returns. One key difference between the DK and my target is the presence of an external 32KHz clock on the DK. I wonder if the advertising module is trying to use the external clock. I&amp;#39;m initializing the clock for the SD like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_1000MS_CALIBRATION, NULL)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But maybe the advertising module is ignoring this setting? This would explain the failure of the debugger too - some piece of code is waiting for an external clock that never a arrives so the debug can&amp;#39;t take control.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38248?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 18:15:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e05cb54-7fe2-4e5f-ad43-09e0516e3d17</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;The second DK on the debug out of the first DK worked properly with the debugger and also with the RTT printf. It also connected with my Central and ran correctly. So the issue is with my target.&lt;/p&gt;
&lt;p&gt;Since I can&amp;#39;t debug to it and I can&amp;#39;t printf from it, I&amp;#39;m completely stopped. To recap - the same hex works perfectly on a DK and misbehaves badly on my target, including not being able to debug or printf and not being able to connect to my central.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m going to open a support ticket now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38247?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 17:52:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:904c96d1-ed7b-494b-8b99-567d2e7be684</guid><dc:creator>Bret Foreman</dc:creator><description>&lt;p&gt;According to nRFgo, it&amp;#39;s the nRF51822CFACA00. I just tried both blinky examples, with S110 and without and they both debug fine on the target. I&amp;#39;m already using the internal RC timer on both the DK and my target because my target does not have an external 32KHz crystal.&lt;/p&gt;
&lt;p&gt;My next step is to use a second DK in place of my target, wiring the the debug out of the first DK to the debug in of the second. This will reveal if I&amp;#39;m really dealing with some sort of Segger or Keil problem rather than something with my target.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51 target behaving differently from DK</title><link>https://devzone.nordicsemi.com/thread/38246?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2015 09:38:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10d0e800-d533-4242-9a7f-e4a3a54aa2f0</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;What chip variant of the nRF51822 are you using (&lt;a href="http://infocenter.nordicsemi.com/pdf/nRF51_Series_Compatibility_Matrix_v2.5.pdf"&gt;chip overview&lt;/a&gt;)?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure what could be causing this behavior you describe, but you can try to change the LF clock source to use the internal RC if you haven&amp;#39;t already (set SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_4000MS_CALIBRATION) in stack init). Another thing you can try is to load the blinky example without the softdevice and see if you are able to debug the chip then in order to narrow down the issue.&lt;/p&gt;
&lt;p&gt;EDIT 11.19&lt;/p&gt;
&lt;p&gt;It&amp;#39;s starting to sound more like a HW issue, maybe antenna or HFCLK. Please try with a clean copy of one of the ble examples in SDK (e.g., ble_app_hrs) and change the LF clock source to RC. Then see if you are able to connect to it using nRFToolbox on ios/android.&lt;/p&gt;
&lt;p&gt;EDIT 11.20&lt;/p&gt;
&lt;p&gt;There&amp;#39;s is no difference between nRF51822 and the nRF51422 besides that you can use the ANT stacks with the latter. In other words, same FW should work on both targets.&lt;/p&gt;
&lt;p&gt;One clue is that debugging isn&amp;#39;t working. Please try to power the you custom board from your your DK kit given that it&amp;#39;s doable and you haven&amp;#39;t tried that already. Were you able to debug the ble_app_hrs example?&lt;/p&gt;
&lt;p&gt;Also, you mentioned earlier that RTT didn&amp;#39;t work very well through the Debug out header. Tried to reproduce it here by using the DK kit to program an ext. kit with the ble_app_hrs example implemented with RTT logging, but it worked as excepted. Attached the .hex below if you want to try it.&lt;/p&gt;
&lt;p&gt;Heart rate example with RTT logging:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1614.nrf51422_5F00_xxac_5F00_s110.hex"&gt;nrf51422_xxac_s110.hex&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>