<?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>HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23165/help-i-cannot-change-the-value-of-a-variable</link><description>nrf52840, S140. 
 So for the past 1 or 2 weeks I have been fighting with this problem : 
 Now it turned out that the connection handle may actually be INVALID, it&amp;#39;s 0! 
 So I debugged the wind out of the whole thing and found that I cannot change the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 01 Jul 2017 11:26:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23165/help-i-cannot-change-the-value-of-a-variable" /><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91130?ContentTypeID=1</link><pubDate>Sat, 01 Jul 2017 11:26:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11894b05-4eb9-4ee7-9e4a-206c334d0078</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;if you want to actually debug at the source level as opposed to the assembler level then yes you should turn O3 off. That is why you&amp;#39;re seeing garbage values in the debugger, it just doesn&amp;#39;t have a way to work out where the variables are so it shows crap. In non optimised mode each variable in the frame is given a place on the stack and it&amp;#39;s slavishly copied to there and from there each time it&amp;#39;s used, that&amp;#39;s how the debugger shows it. I don&amp;#39;t really know why you&amp;#39;re using O3 for code you&amp;#39;re trying to debug, you&amp;#39;re just making life hard for yourself.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91129?ContentTypeID=1</link><pubDate>Sat, 01 Jul 2017 10:16:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96540b55-b813-4387-9fa3-1dc00310cabb</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;@Alex Hi, I&amp;#39;m trying to figure out how to see if the cccd handle were properly set or not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91128?ContentTypeID=1</link><pubDate>Sat, 01 Jul 2017 10:15:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09315d3a-ecdc-44fc-98c7-2d04f628733f</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;@RK Hello, I enabled the &amp;quot;DEBUG&amp;quot; macro but regrettably I&amp;#39;m using O3 optimization. Guess I need to turn it off...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91127?ContentTypeID=1</link><pubDate>Sat, 01 Jul 2017 04:14:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88fa7589-0220-42b4-bf14-996740de94f9</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;assembly looks fine to me, gets the 16bit value offset at +4 which is the connection handle, stores it into your variable and calls the service call with that value in r0 and r1, r2 and r3 zeroed. My guess would be if you single stepped one line from where you are on that picture, r0 would be zero, which is the connection handle.&lt;/p&gt;
&lt;p&gt;But as I&amp;#39;ve said already - that looks like optimized assembly to me. Code compiled optimized really doesn&amp;#39;t work very well in debuggers, even if it has debug information (which that does). That is probably why you&amp;#39;re having issues stepping it. Unless Keil compiles code in a very unusual way.&lt;/p&gt;
&lt;p&gt;Are you sure you are compiling the code not only with debug information but with zero optimisation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91135?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 13:26:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a45fa25e-5042-4605-a3bb-651fe0590727</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;@Mitch996, to be honest I don&amp;#39;t understand why you are wasting time investigating handle. You were told that zero is valid value. Invalid one is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define BLE_CONN_HANDLE_INVALID 0xFFFF
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In your another thread about sd_ble_gatts_hvx, did you check if notification enabled?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91134?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 13:16:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bffc0044-f858-4add-a2eb-82fff901a281</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;@RK I tried to decrypt the assembly but got stopped at the first instruction: LDRH, here is the screen cap, the pertinent first line is highlighted using bring yellow stripe:
&lt;a href="http://i.imgur.com/kD9NX7v.png"&gt;screen cap&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My even less educated guess:&lt;/p&gt;
&lt;p&gt;load halfword length of data from address stored in r0 + 0x04 into r0;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think that makes a lot of sense, but anyway, what does that mean exactly? My google-fu isn&amp;#39;t high enough to get the exact meaning of ldrh, I managed to find ldr under a different using case.&lt;/p&gt;
&lt;p&gt;Also, does the rest of the code look out of the normal to you?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91126?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 10:32:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9274cd3-70bf-4f9a-b3e9-77c3e455a1ac</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;@RK thank you! I&amp;#39;ll look up the assembly and see what I can find. I hate going there... I can&amp;#39;t remember all those instructions. Will get back with something new, meanwhile anyone reading this please help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91136?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 09:51:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41e46c72-4584-448b-9d6c-3a865db7ca4f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;A connection handle of 0x8e5, or 0x8e4, makes no sense. Connection handles start at 0 and go up (that&amp;#39;s not guaranteed but that&amp;#39;s how it actually works in practice with this softdevice).&lt;/p&gt;
&lt;p&gt;So it sounds to me like your actual issues are these&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;you&amp;#39;ve convinced yourself that something to do with a connection handle is the cause of your bug and that&amp;#39;s caused you to head into a different piece of functional code and start questioning it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;keil sounds like a total POS. Are you actually compiling with debug and full debugging symbols (don&amp;#39;t ask me how you do that in keil I don&amp;#39;t use it) If you aren&amp;#39;t the values you&amp;#39;re seeing are probably not correct.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If all else fails you could always drop down to the assembly and see what&amp;#39;s in the registers and that will tell you what&amp;#39;s really being passed to where.&lt;/p&gt;
&lt;p&gt;still think the assignment of 0 to the connection handle sounds completely right.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91125?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 09:12:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c4ead58-3680-4cf0-be05-7c7ef078611f</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;I can&amp;#39;t seem to change APP_RAM_BASE to anything, and the current value, acquired by breakpointing at the very line which calls sd_ble_enable, is 0, that&amp;#39;s not supposed to happen, yet it can advertise.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Take a break , start fresh and work out what&amp;#39;s wrong.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I wish I could. I&amp;#39;m pulling my hair out on this one, god why must everything be so hard!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;so you don&amp;#39;t need to play tricks to read them.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I wish that was the case! But all I see was &amp;quot;out of the scope&amp;quot; in the watchx window of keil. I&amp;#39;m at my wit&amp;#39;s end. Dammit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91124?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 09:09:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d19d7cd3-5eb6-4bcb-907a-93d2f0b29239</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;@RK:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;the code you post is entirely bizzare. why are you setting error_code to a pointer to the address of your variable?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Oh that... I was supposed to sort that out, it was used to test something, but I pasted it here anyway, I&amp;#39;m on the brink of insanity, I&amp;#39;ve done everything I am suppsoed to do, yet nothing works out.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;And what&amp;#39;s wrong with m_active_conn_handle being set to zero? That sounds like a perfectly valid and very likely connection handle to me.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That&amp;#39;s weird because the connection handle, passed from another struct, should be 0x8e5 (sorry about the 0x8e4 value, I remembered wrong)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I don&amp;#39;t understand your comment about USER_APP_RAM_BASE either,&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;to call the fucntion sd_ble_enable, I&amp;#39;m suppsoed to pass in the valid starting address of app RAM starting address. I looked it up it should be 0x20007000 or something, but&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91123?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 09:07:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:671b9720-23bb-4b0d-99d7-8637871c2fb6</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;@RK:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;they are just wrong, entirely. There&amp;#39;s no read only ram&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;No there are not, I&amp;#39;m being driven literally nuts on this.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;no wrong address anything.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I&amp;#39;m not gonna be so confident, there could be a memory leak somewhere and it&amp;#39;s usually difficult to find, also I have no idea how reliable nrfgo studio is when downloading my APP and SD.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;compilers are compilers&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You are right, but I was supposed to be on the look out for stack allocations, perhaps in the .s file, but I have no clue how to do that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91131?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 08:57:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a04903d6-24fb-45ec-975c-82e97ccda64e</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;@alex if the code is built debug then it&amp;#39;s guaranteed that after each operation the values are written to the debug area on the stack, so you don&amp;#39;t need to play tricks to read them. If the code is built release mode, then all bets are off about what it&amp;#39;s doing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91133?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 08:50:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cac998ac-1bb1-4e32-8947-35c6248adf31</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Let&amp;#39;s start with your uneducated guesses, they are just wrong, entirely. There&amp;#39;s no read only ram and no wrong address anything. memory is memory, compilers are compilers and things are where they are supposed to be.&lt;/p&gt;
&lt;p&gt;the code you post is entirely bizzare. why are you setting error_code to a pointer to the address of your variable? That&amp;#39;s just weird. And what&amp;#39;s wrong with m_active_conn_handle being set to zero? That sounds like a perfectly valid and very likely connection handle to me. Why do you think 0x8e4 is the correct value?&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t understand your comment about USER_APP_RAM_BASE either,&lt;/p&gt;
&lt;p&gt;You appear to have debugged yourself into a flap. Take a break , start fresh and work out what&amp;#39;s wrong.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91132?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 08:48:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d38d954-2b39-404f-b1dd-8b4e463e4544</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;As for error_code variable, it is local and if not used then it may not even be in stack, it may be for a short period in CPU register that&amp;#39;s why you may not see it in IDE. Define it as global and find it&amp;#39;s address in map file, same for m_active_conn_handle. In that case it will be easier to debug.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91122?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 08:03:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43a63e33-5114-4c0a-9a08-4b4aaa5c6819</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;Hi Alex, I used 2 different utilities, and I can confirm that it is not possible. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91121?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 07:58:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5ffd550-32fc-402b-86c3-95f4f34ec486</guid><dc:creator>Mitch996</dc:creator><description>&lt;p&gt;Hi Alex, that&amp;#39;s is a possibility, but won&amp;#39;t the compiler give me warnings or errors for that? Anyway, I&amp;#39;m doing the search :) will get back later.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HELP! I cannot change the value of a variable???</title><link>https://devzone.nordicsemi.com/thread/91120?ContentTypeID=1</link><pubDate>Fri, 30 Jun 2017 07:47:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d650077-8559-49e5-9200-017f22a8a834</guid><dc:creator>Alex</dc:creator><description>&lt;p&gt;Search through your code, may be you have m_active_conn_handle defined twice, one is global as should be and another is static in one of the files&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>