<?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>Kinetis MicrocontrollersのトピックRe: KL05 and FSTAT bus error</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373646#M19522</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eduardo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't explain why you seem to be able to execute the programming code from Flash.&lt;/P&gt;&lt;P&gt;However, since it is contradicting the instructions of usage I would concentrate on correcting the method rather than investigating why incorrect use can operate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Could you tell me which compiler you are using with the __DI() intrinsic? Is there a description of this because I would have thought that it disabled all interrupts (?)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinetis: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/kinetis.html" target="_blank"&gt;µTasker Kinetis support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;KL05: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/kinetis/FRDM-KL05Z.html" target="_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL05Z.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For the complete "out-of-the-box" Kinetis experience and faster time to market&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Jan 2015 13:27:56 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2015-01-26T13:27:56Z</dc:date>
    <item>
      <title>KL05 and FSTAT bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373643#M19519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using a KL05, I'm having problems with a bus error generated when reading the FSTAT register after launching a erase command operation. The exact operations I'm doing are the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;while(FTFA_PDD_GetCmdCompleteFlag(FTFA) != FTFA_FSTAT_CCIF_MASK);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* just to be sure peripheral is ready */&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;FTFA_PDD_SetFCCOBCommand(FTFA, FLASH_CMD_ERASE_SECTOR);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;FTFA_PDD_SetFCCOBAddress(FTFA, addr);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;FTFA_PDD_LaunchCommand(FTFA)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;/* verification to know when the operation has been completed */&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;while(FTFA_PDD_GetCmdCompleteFlag(FTFA) != FTFA_FSTAT_CCIF_MASK);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* THIS IS WHERE THE BUS ERROR IS GENERATED */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the bus error is generated, I observe the flag RDCOLERR in FTFA_FSTAT register has been enabled. I can't understand why this is happening. Even more weird: when I execute step by step this operation, no error is generated. I have tried to add a delay before the sencond FSTAT verification but it is useless.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have any idea about what could be happening? All help will be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eduardo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE: I'm not using Processor Expert code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 16:26:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373643#M19519</guid>
      <dc:creator>Ardoster</dc:creator>
      <dc:date>2015-01-23T16:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: KL05 and FSTAT bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373644#M19520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eduardo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the command is launched the Flash cannot be used until the operation has completed. This means that the code needs to run from RAM.&lt;/P&gt;&lt;P&gt;Check that the launch command is running form RAM otherwise it will indeed work when single-stepped but fail when running normally.&lt;/P&gt;&lt;P&gt;Also&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;while(FTFA_PDD_GetCmdCompleteFlag(FTFA) != FTFA_FSTAT_CCIF_MASK);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;after the launch command has completed is of no use since the launch command MAY never return before completed (otherwise it will immediately crash unless also the complete routine is run in RAM).&lt;/P&gt;&lt;P&gt;The only check that makes sense is for error bits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinetis: &lt;A href="http://www.utasker.com/kinetis.html" title="http://www.utasker.com/kinetis.html"&gt;µTasker Kinetis support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;KL05: &lt;A href="http://www.utasker.com/kinetis/FRDM-KL05Z.html" title="http://www.utasker.com/kinetis/FRDM-KL05Z.html"&gt;http://www.utasker.com/kinetis/FRDM-KL05Z.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 17:35:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373644#M19520</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2015-01-23T17:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: KL05 and FSTAT bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373645#M19521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your quick reply. You're right: according to the RM and &lt;A href="http://cache.freescale.com/files/32bit/doc/app_note/AN4695.pdf?fasp=1&amp;amp;WT_TYPE=Application%20Notes&amp;amp;WT_VENDOR=FREESCALE&amp;amp;WT_FILE_FORMAT=pdf&amp;amp;WT_ASSET=Documentation&amp;amp;fileExt=.pdf"&gt;this&lt;/A&gt; AN (AN4695), the launch command and supervision of completion flag must be executed from RAM. But this error is more interesting. Let me explain it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the AN note it is indicated that ISR should be disabled before erasing or programming flash operations. My problem is I disabled all peripheral ISR ( __DI(); ), but not core interrupts such as system tick. Once I have disabled the system tick interrupt the erase command is working correctly. This is indeed a good news, but it contradicts the RM and the AN: My code should still be crashing because I'm executing the erase command from the same block flash I'm erasing the sector.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have any explanation about this issue? Thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eduardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 12:20:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373645#M19521</guid>
      <dc:creator>Ardoster</dc:creator>
      <dc:date>2015-01-26T12:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: KL05 and FSTAT bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373646#M19522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eduardo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't explain why you seem to be able to execute the programming code from Flash.&lt;/P&gt;&lt;P&gt;However, since it is contradicting the instructions of usage I would concentrate on correcting the method rather than investigating why incorrect use can operate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Could you tell me which compiler you are using with the __DI() intrinsic? Is there a description of this because I would have thought that it disabled all interrupts (?)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinetis: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/kinetis.html" target="_blank"&gt;µTasker Kinetis support&lt;/A&gt;&lt;/P&gt;&lt;P&gt;KL05: &lt;A class="jive-link-external-small" data-content-finding="Community" href="http://www.utasker.com/kinetis/FRDM-KL05Z.html" target="_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL05Z.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For the complete "out-of-the-box" Kinetis experience and faster time to market&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 13:27:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373646#M19522</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2015-01-26T13:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Re: KL05 and FSTAT bus error</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373647#M19523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't worry. Looks like a matter related to flash instruction cache or similar. I have made several tests in the function I use to check if the operation has been completed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code is OK:&lt;/P&gt;&lt;PRE __default_attr="html" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14222851472088510" jivemacro_uid="_14222851472088510"&gt;
&lt;P&gt;&amp;lt;code&amp;gt;&lt;/P&gt;
&lt;P&gt;while(1){&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (FLASH_GetCmdCompleteFlag(FTFA) == FTFA_FSTAT_CCIF_MASK){&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res = FLASH_OK;&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;}&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/code&amp;gt;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this other fails:&lt;/P&gt;&lt;PRE __default_attr="html" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14222851471898494" jivemacro_uid="_14222851471898494" modifiedtitle="true"&gt;
&lt;P&gt;&amp;lt;code&amp;gt;&lt;/P&gt;
&lt;P&gt;while(num_ms &amp;lt; FLASH_TIMEOUT_MS){&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (FLASH_GetCmdCompleteFlag(FTFA) == FTFA_FSTAT_CCIF_MASK){&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; res = FLASH_OK;&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay_us(1000);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // IF SUPRESSING THIS CALL, EXECUTION IS OK&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num_ms++;&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;}&amp;lt;br&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/code&amp;gt;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess the flash memory buffers the immediate following instructions before they are executed. So this would explain why the execution of first code doesn't crash: because they are being executed from cache instead than flash. Because the code to be executed is more complex in the second one, they wouldn't fit in the flash cache, so it crashes. According to my register MCM_PLACR, cache is ON for both instruction and data, so I think this is a reasonable explanation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As conclusion: I think is strongly advisable to execute these functions from RAM. Although in my case, that method could give me problems at code certification time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot of for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eduardo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jan 2015 15:10:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL05-and-FSTAT-bus-error/m-p/373647#M19523</guid>
      <dc:creator>Ardoster</dc:creator>
      <dc:date>2015-01-26T15:10:54Z</dc:date>
    </item>
  </channel>
</rss>

