<?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>Program sort of freezes or doesn&amp;#39;t after a while when I change something completely unrelated (or so I think)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61525/program-sort-of-freezes-or-doesn-t-after-a-while-when-i-change-something-completely-unrelated-or-so-i-think</link><description>Hi everyone, 
 I have a problem I can&amp;#39;t sort out. My program runs fine indefinitely if I set one variable in a function at one point but if I don&amp;#39;t do that, the program, or at least the debugging stops after a while. The program sort of continues (I can</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 May 2020 05:56:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61525/program-sort-of-freezes-or-doesn-t-after-a-while-when-i-change-something-completely-unrelated-or-so-i-think" /><item><title>RE: Program sort of freezes or doesn't after a while when I change something completely unrelated (or so I think)</title><link>https://devzone.nordicsemi.com/thread/251160?ContentTypeID=1</link><pubDate>Fri, 22 May 2020 05:56:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e7e5708-7426-4e06-adb2-2af77bb034d0</guid><dc:creator>samuel.zetterlund</dc:creator><description>&lt;p&gt;Hi again Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I followed your example and replaced all my static variables&amp;nbsp;from my header files&amp;nbsp;with externs and defined them in the source files instead. I remember looking at some of the Nordic library files before starting this project, trying to follow the same pattern but apparently got it all confused. I see now that many source files have static variables but no header files so I got it wrong. &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Anyway, the problem went away after doing this so many, many thanks! I still can&amp;#39;t say exactly what was going on but I don&amp;#39;t need to know either.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I really appreciate you addressing this although the problem formulation was fuzzy. I&amp;#39;ve enjoyed working with Nordic chips much thanks to this community!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;One other question: regarding&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SOME_CONSTANT 2&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I see that for example app_button.c and .h both have #defines and sometimes defines are placed in the source file and sometimes in the header file. Where would you put your defines?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks again Karl!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program sort of freezes or doesn't after a while when I change something completely unrelated (or so I think)</title><link>https://devzone.nordicsemi.com/thread/251010?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 13:34:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d88748a-816d-4328-9998-399d32174381</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Samuel,&lt;/p&gt;
[quote user="samuel.zetterlund"]Thanks so much for your reply.[/quote]
&lt;p&gt;&amp;nbsp;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="samuel.zetterlund"]I&amp;#39;ll try to be more detailed about this in my next post. I just wanted to thank you for your time and the link to the stackoverflow page. I&amp;#39;ll follow that example to improve my code.[/quote]
&lt;p&gt;Great, I am happy to hear that you found the link useful. There are many pitfalls with embedded C programming, and this issue is certainly one of them.&lt;/p&gt;
[quote user="samuel.zetterlund"]Regarding the formatting, I saw that the formatting was completely messed up and tried to change it but didn&amp;#39;t manage but I&amp;#39;ll be more careful next time.[/quote]
&lt;p&gt;Oh, I understand. I think a certain font might trigger some unexpected behavior. I think this can be resolved by using the &amp;quot;insert&amp;quot; option to add a text box, but I am not entirely sure as I have not tried it myself.&lt;br /&gt;Reading over my own comments again I see that I might have come across as crass&amp;nbsp; - know that this was not my intention at all!&lt;br /&gt;&lt;br /&gt;Looking forward to hearing from you,&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program sort of freezes or doesn't after a while when I change something completely unrelated (or so I think)</title><link>https://devzone.nordicsemi.com/thread/250923?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 10:52:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b94dcb18-9b38-46d6-8ead-d768d6e27ef6</guid><dc:creator>samuel.zetterlund</dc:creator><description>&lt;p&gt;Hi Karl.&lt;/p&gt;
&lt;p&gt;Thanks so much for your reply. I&amp;#39;ll try to be more detailed about this in my next post. I just wanted to thank you for your time and the link to the stackoverflow page. I&amp;#39;ll follow that example to improve my code.&lt;/p&gt;
&lt;p&gt;Regarding the formatting, I saw that the formatting was completely messed up and tried to change it but didn&amp;#39;t manage but I&amp;#39;ll be more careful next time. &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program sort of freezes or doesn't after a while when I change something completely unrelated (or so I think)</title><link>https://devzone.nordicsemi.com/thread/250921?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 10:52:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfd181ba-67ec-4d34-b729-6c5448e58eae</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again,&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="samuel.zetterlund"]I know this is super hard to answer.[/quote]
&lt;p&gt;Yes, but if you provide me with the information I requested in my other comment, then we may start attempting to resolve your issue.&lt;br /&gt;I am looking forward to hearing back from you on that!&lt;/p&gt;
[quote user="samuel.zetterlund"]Just wanted to add a few things. The program doesn&amp;#39;t freeze actually, it&amp;#39;s just the printing in the console window that stops.[/quote]
&lt;p&gt;Thank you for the update - I am glad you were able to verify that the program does not crash.&lt;/p&gt;
[quote user="samuel.zetterlund"]I&amp;#39;ve tried renaming the variable and it doesn&amp;#39;t change the behavior.[/quote]
&lt;p&gt;I would not expect the variable name to matter here, but I think its declaration and the placement of the declaration might contribute to the unexpected behavior.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;br /&gt;&lt;br /&gt;P.S If you are worried about Intellectual property when sharing code, I may convert this ticket to a private ticket which is only viewable to you and the support staff here at Nordic Semiconductor. Please let me know if you would like me to do this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Program sort of freezes or doesn't after a while when I change something completely unrelated (or so I think)</title><link>https://devzone.nordicsemi.com/thread/250918?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 10:45:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:640581ef-a49f-4bf3-a260-30e34aa885e3</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Samuel,&lt;/p&gt;
[quote user=""]My program runs fine indefinitely if I set one variable in a function at one point but if I don&amp;#39;t do that, the program, or at least the debugging stops after a while. The program sort of continues (I can send a few&amp;nbsp;messages from my app to it) but after a while it just doesn&amp;#39;t seem to respond.[/quote]
&lt;p&gt;Keep in mind that I do not know anything other than this description and code snippets of them, when reading the rest of my answer.&lt;/p&gt;
[quote user=""]BUT! If I don&amp;#39;t make that function call and set that variable the debugging (and parts of the program) stops after exactly the same amount of time every time[/quote]
&lt;p&gt;This would lead me to believe that the change of &amp;quot;the variable&amp;quot; might not be the cause of your issue.&lt;/p&gt;
[quote user=""]But what could cause this?[/quote]
&lt;p&gt;In truth, I have little to no idea - since I have seen a total of 3 lines of un-commented code. There is a multiple of reasons that could be causing an issue here, and I am not sure I understand your issue correctly either.&lt;br /&gt;&lt;br /&gt;With my limited insight into your application/project, I am seeing this as an embedded programming issue, more than an nRF issue.&lt;br /&gt;I am not sure I understand your issue correctly, but it seems to me that your trouble is with changing the &amp;quot;actual_potentiometer_resistance&amp;quot; variable, which you have placed as a static variable in the potentiometer header file.&amp;nbsp;&lt;br /&gt;This is bad C practice, because static global variables are not passed to the linker.&lt;br /&gt;Please see this &lt;a href="https://stackoverflow.com/questions/3837490/initializing-a-static-variable-in-header/3837513"&gt;stackoverflow question&lt;/a&gt; on the matter for further detail.&lt;br /&gt;&lt;br /&gt;For me to be able to help you more with this issue it would be highly beneficial if you could share more of your code, along with an explanation of what you are trying to achieve - and how the applications behavior differs from what you would have expected.&lt;br /&gt;With this information, I would be better equipped to help you.&lt;br /&gt;&lt;br /&gt;As a side note, it is good practice that you are using the &amp;quot;insert&amp;quot; format possibilities in your ticket - but the ticket currently is very hard to read and understand what is part of your reflection and comments in between the code. For future reference it would be greatly beneficial if the ticket was easier to read, for us to better be able to quickly understand your issue.&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Karl&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: Program sort of freezes or doesn't after a while when I change something completely unrelated (or so I think)</title><link>https://devzone.nordicsemi.com/thread/250706?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 12:08:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2907cee8-7d76-4bc4-8b8f-185d0b33e967</guid><dc:creator>samuel.zetterlund</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;I know this is super hard to answer.&lt;/p&gt;
&lt;p&gt;Just wanted to add a few things. The program doesn&amp;#39;t freeze actually, it&amp;#39;s just the printing in the console window that stops.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried renaming the variable and it doesn&amp;#39;t change the behavior. I&amp;#39;ve placed the variable in a different included file and then the debug&amp;nbsp;freezes. I&amp;#39;ve tried to remove the variable and that won&amp;#39;t work.&lt;/p&gt;
&lt;p&gt;So the program needs this specific variable (name can be changed) placed in this specific header (or source, tried that as well) file to not continue print debug messages. I can also change the name of the function with the same result. I just need to set this variable to some value for the debugging to work continuously...&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve also tried another board as well as cleaned the project and so on. Same result.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>