<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>MQX Software SolutionsのトピックMFS and volatile variables</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/MFS-and-volatile-variables/m-p/155637#M751</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all ,&lt;/P&gt;&lt;P&gt;I have an issue with MFS on SD Card file writing. I have function in which I open file (fopen()), then write into it (write()) and close file (fclose()). In that function I have several local variables defined. MFS writting only works when I declare these variables as volatile, otherwise file is not created/writen and in some situations SD card file sistem become corrupted (Windows require formating). All these problems disapears when I declare variables as volatile. Why this is happen . Is this some bug in MFS functions and interrupt handling or I make mistake. ?&lt;BR /&gt;For better understanding here is the part of function which not works well because not all locals are volatile :&lt;/P&gt;&lt;P&gt;void parameters_to_file()&lt;BR /&gt;{&lt;BR /&gt;volatile MQX_FILE_PTR fd;&lt;/P&gt;&lt;P&gt;int enum_id;&lt;BR /&gt;&lt;BR /&gt;int_32 bytes_written;&lt;BR /&gt;int_32 data_length;&lt;BR /&gt;&lt;BR /&gt;PARAMETERS_OBJECT* par_obj;&lt;BR /&gt;PARAMETER* par;&lt;BR /&gt;PARAMETER_DESCRIPTOR* par_desc;&lt;BR /&gt;PARAMETERS_OBJECT** objects;&lt;BR /&gt;PARAMETER** params;&lt;BR /&gt;&lt;BR /&gt;int i , j , k;&lt;BR /&gt;&lt;BR /&gt;enum_id = 1;&lt;BR /&gt;&lt;BR /&gt;fd = fopen("c:mrk.bin","a+");&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;/* write header */&lt;BR /&gt;strcpy((char*)&amp;amp;write_data, "device,");&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;bytes_written = write(fd,&amp;amp;write_data,data_length);&lt;BR /&gt;_time_delay(10);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// do something with variables //&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;fclose(fd);&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Apr 2012 04:10:55 GMT</pubDate>
    <dc:creator>infoterm</dc:creator>
    <dc:date>2012-04-19T04:10:55Z</dc:date>
    <item>
      <title>MFS and volatile variables</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MFS-and-volatile-variables/m-p/155637#M751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all ,&lt;/P&gt;&lt;P&gt;I have an issue with MFS on SD Card file writing. I have function in which I open file (fopen()), then write into it (write()) and close file (fclose()). In that function I have several local variables defined. MFS writting only works when I declare these variables as volatile, otherwise file is not created/writen and in some situations SD card file sistem become corrupted (Windows require formating). All these problems disapears when I declare variables as volatile. Why this is happen . Is this some bug in MFS functions and interrupt handling or I make mistake. ?&lt;BR /&gt;For better understanding here is the part of function which not works well because not all locals are volatile :&lt;/P&gt;&lt;P&gt;void parameters_to_file()&lt;BR /&gt;{&lt;BR /&gt;volatile MQX_FILE_PTR fd;&lt;/P&gt;&lt;P&gt;int enum_id;&lt;BR /&gt;&lt;BR /&gt;int_32 bytes_written;&lt;BR /&gt;int_32 data_length;&lt;BR /&gt;&lt;BR /&gt;PARAMETERS_OBJECT* par_obj;&lt;BR /&gt;PARAMETER* par;&lt;BR /&gt;PARAMETER_DESCRIPTOR* par_desc;&lt;BR /&gt;PARAMETERS_OBJECT** objects;&lt;BR /&gt;PARAMETER** params;&lt;BR /&gt;&lt;BR /&gt;int i , j , k;&lt;BR /&gt;&lt;BR /&gt;enum_id = 1;&lt;BR /&gt;&lt;BR /&gt;fd = fopen("c:mrk.bin","a+");&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;/* write header */&lt;BR /&gt;strcpy((char*)&amp;amp;write_data, "device,");&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;bytes_written = write(fd,&amp;amp;write_data,data_length);&lt;BR /&gt;_time_delay(10);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// do something with variables //&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;fclose(fd);&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2012 04:10:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MFS-and-volatile-variables/m-p/155637#M751</guid>
      <dc:creator>infoterm</dc:creator>
      <dc:date>2012-04-19T04:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: MFS and volatile variables</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MFS-and-volatile-variables/m-p/155638#M752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi infoterm,&lt;/P&gt;&lt;P&gt;I'm not so familiar with MFS. But, could it be a buffer overflow issue? So could you try to limit the data_length inside the parameter_to_file() function to max. Bytes you are awaiting? I know such issues at 8 and 16 bit processors, where an 32 bit value can be illegal because of interrupted copy operation. Which processor do you use?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 15:10:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MFS-and-volatile-variables/m-p/155638#M752</guid>
      <dc:creator>Fabi</dc:creator>
      <dc:date>2012-05-16T15:10:23Z</dc:date>
    </item>
  </channel>
</rss>

