<?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>Issue of changing the value of variables/flags automatically</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62877/issue-of-changing-the-value-of-variables-flags-automatically</link><description>Hi 
 I am facing two issues in the below code. I use segger embedded studio. 
 1.The value I am setting as fs_initialized = true in line number 90 (inside FRESULT fs_init() function )is changing to fs_initialized = false after the while loop or line number</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Jun 2020 11:20:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62877/issue-of-changing-the-value-of-variables-flags-automatically" /><item><title>RE: Issue of changing the value of variables/flags automatically</title><link>https://devzone.nordicsemi.com/thread/256397?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 11:20:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea58c1b0-ed64-438d-964b-16276b5d05a4</guid><dc:creator>Vishnu Pradeep</dc:creator><description>&lt;p&gt;This is a custom file for a NAND flash developed on SDK 15.2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue of changing the value of variables/flags automatically</title><link>https://devzone.nordicsemi.com/thread/256395?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 11:15:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:807e3a2f-c277-4a8d-9d9f-4e46f53d9394</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;The source file you copied here, is that from an nRF5 SDK? If yes, which version.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue of changing the value of variables/flags automatically</title><link>https://devzone.nordicsemi.com/thread/256353?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 09:22:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdd45f62-0592-4b87-8d21-71d9dfdfe287</guid><dc:creator>Vishnu Pradeep</dc:creator><description>&lt;p&gt;1. I tried to debug step by step.&amp;nbsp;&lt;span&gt;fs_initialized&amp;nbsp;= true is retained till the execution comes out of while loop when the file_index &amp;lt; MAX_INDEX condition becomes false! I&amp;nbsp;did&amp;nbsp;a workaround by initializing&amp;nbsp;fs_initialized&amp;nbsp;= true after&amp;nbsp;fs_data_reset(false). But this is not correct way. There might be other areas where the variable value changes and thus the application is not working as intended.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. I made it and it is the same. But when I change the optimization level from none to any other option, it works!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I does clean and re-build very often.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue of changing the value of variables/flags automatically</title><link>https://devzone.nordicsemi.com/thread/256349?ContentTypeID=1</link><pubDate>Tue, 23 Jun 2020 09:01:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7eced52-98a5-41ee-b963-2df41718bb7d</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;1. I don&amp;#39;t have any explanation to 1, maybe try and fail a bit to see if there is any code that is updating &lt;span&gt;fs_initialized, for instance by adding some debug output each time&amp;nbsp;fs_initialized change or set value.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. You can try to make&amp;nbsp;file_index volatile also.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sometimes a clean and re-build (Alt+F7) can help.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>