<?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>topic Re: Flash cannot be erased with &amp;quot;FTFE Erase Flash Sector Command&amp;quot; in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1608767#M64801</link>
    <description>&lt;P&gt;thank you for your reply.&lt;BR /&gt;The first line of FSTAT is OR(|=) to clear the error.&lt;BR /&gt;This is because CCIF is not cleared even if 0 is written.&lt;/P&gt;&lt;P&gt;"nop" seems to work without being optimized as far as the assembler list file is concerned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.LBB19_1: @ =&amp;gt;This Inner Loop Header: Depth=1&lt;BR /&gt;movs r0, #0&lt;BR /&gt;movt r0, #16386&lt;BR /&gt;ldrb r0, [r0]&lt;BR /&gt;lsls r0, r0, #24&lt;BR /&gt;cmp r0, #0&lt;BR /&gt;bpl .LBB19_3&lt;BR /&gt;b .LBB19_2&lt;BR /&gt;.LBB19_2: @ in Loop: Header=BB19_1 Depth=1&lt;BR /&gt;.Ltmp39:&lt;BR /&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/5981"&gt;@app&lt;/a&gt;&lt;BR /&gt;nop&lt;BR /&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/203079"&gt;@no&lt;/a&gt;_APP&lt;BR /&gt;.Ltmp40:&lt;BR /&gt;b .LBB19_1&lt;BR /&gt;.LBB19_3:&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2023 23:50:28 GMT</pubDate>
    <dc:creator>tera</dc:creator>
    <dc:date>2023-03-02T23:50:28Z</dc:date>
    <item>
      <title>Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1600751#M64715</link>
      <description>&lt;P&gt;I am using MKE16F256VLL16&lt;/P&gt;&lt;P&gt;Even if I execute the "Erase Flash Sector Command" of the FTFE function, the flash is not erased normally.&lt;/P&gt;&lt;P&gt;The sector you want to erase is the memory starting at 0x00010000&lt;/P&gt;&lt;P&gt;FTFE execution is done from RAM.&lt;/P&gt;&lt;P&gt;The execution result is error free.&lt;BR /&gt;However, when I check the memory, it is erased in spots.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tera_0-1676594473081.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/211288i661641BC71111CED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tera_0-1676594473081.png" alt="tera_0-1676594473081.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please tell me how to solve this problem&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 00:42:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1600751#M64715</guid>
      <dc:creator>tera</dc:creator>
      <dc:date>2023-02-17T00:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1603786#M64747</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Could you explain a bit of the context of what are you doing? or the steps that you are follow? Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 15:25:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1603786#M64747</guid>
      <dc:creator>CarlosGarabito</dc:creator>
      <dc:date>2023-02-22T15:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1605665#M64775</link>
      <description>&lt;P&gt;uint8_t&amp;nbsp;FTFE_CommandExecute() __attribute__((section(".ARM.__at_0x20000000")));&lt;/P&gt;&lt;P&gt;uint8_t FTFE_CommandExecute()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; FTFE-&amp;gt;FSTAT |= ( FTFE_FSTAT_RDCOLERR(1) | FTFE_FSTAT_ACCERR(1) | FTFE_FSTAT_FPVIOL(1) );&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTFE-&amp;gt;FSTAT |= FTFE_FSTAT_CCIF(1);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; while( (FTFE-&amp;gt;FSTAT &amp;amp; FTFE_FSTAT_CCIF_MASK) ){&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; __asm("NOP");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; while( !(FTFE-&amp;gt;FSTAT &amp;amp; FTFE_FSTAT_CCIF_MASK) ){&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; __asm("NOP");&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return FTFE-&amp;gt;FSTAT;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; address=0x00010000;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; FTFE-&amp;gt;FCCOB0 = 0x09;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTFE-&amp;gt;FCCOB1 = (address&amp;gt;&amp;gt;16) &amp;amp; 0x000000FF;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTFE-&amp;gt;FCCOB2 = (address&amp;gt;&amp;gt; &lt;LI-EMOJI id="lia_smiling-face-with-sunglasses" title=":smiling_face_with_sunglasses:"&gt;&lt;/LI-EMOJI&gt; &amp;amp; 0x000000FF;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTFE-&amp;gt;FCCOB3 = address &amp;amp; 0x000000FF;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; __disable_irq();&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; FTFE_CommandExecute();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; __enable_irq();&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;If you break here and check the FLASH, it will look like the image above.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 01:58:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1605665#M64775</guid>
      <dc:creator>tera</dc:creator>
      <dc:date>2023-02-27T01:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1607980#M64790</link>
      <description>&lt;P&gt;I think so.&lt;/P&gt;&lt;P&gt;The spec sheet has the following:&lt;BR /&gt;Erase Flash Sector execution time—max 115ms&lt;/P&gt;&lt;P&gt;I think it is necessary to wait the above time after executing FTFE_CommandExecute().&lt;BR /&gt;That's because when I ran the program a little and checked the memory, it was erased.&lt;/P&gt;&lt;P&gt;Therefore, I made a program to check the memory after waiting for the above time, but the erasure was never completed.&lt;BR /&gt;I think it's probably due to time and other conditions.&lt;/P&gt;&lt;P&gt;Are there any conditions for flash erasing other than time and security?&lt;BR /&gt;Also, is my thinking correct?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 00:31:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1607980#M64790</guid>
      <dc:creator>tera</dc:creator>
      <dc:date>2023-03-02T00:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1608399#M64792</link>
      <description>NXP documentation is full of bad examples where they use "|=" when they should not. What is FSTAT starting out as? Make sure an OR (|=) is what you really want, rather than a simple assignment (=). First line should probably be (=) and second (|=).&lt;BR /&gt;&lt;BR /&gt;The nop should be marked as volatile. If the 'small' model is used, '-oS', GCC can be aggressive and remove the wait loop because it has no side effects.</description>
      <pubDate>Thu, 02 Mar 2023 13:17:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1608399#M64792</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2023-03-02T13:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1608767#M64801</link>
      <description>&lt;P&gt;thank you for your reply.&lt;BR /&gt;The first line of FSTAT is OR(|=) to clear the error.&lt;BR /&gt;This is because CCIF is not cleared even if 0 is written.&lt;/P&gt;&lt;P&gt;"nop" seems to work without being optimized as far as the assembler list file is concerned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.LBB19_1: @ =&amp;gt;This Inner Loop Header: Depth=1&lt;BR /&gt;movs r0, #0&lt;BR /&gt;movt r0, #16386&lt;BR /&gt;ldrb r0, [r0]&lt;BR /&gt;lsls r0, r0, #24&lt;BR /&gt;cmp r0, #0&lt;BR /&gt;bpl .LBB19_3&lt;BR /&gt;b .LBB19_2&lt;BR /&gt;.LBB19_2: @ in Loop: Header=BB19_1 Depth=1&lt;BR /&gt;.Ltmp39:&lt;BR /&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/5981"&gt;@app&lt;/a&gt;&lt;BR /&gt;nop&lt;BR /&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/203079"&gt;@no&lt;/a&gt;_APP&lt;BR /&gt;.Ltmp40:&lt;BR /&gt;b .LBB19_1&lt;BR /&gt;.LBB19_3:&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 23:50:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1608767#M64801</guid>
      <dc:creator>tera</dc:creator>
      <dc:date>2023-03-02T23:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1610032#M64811</link>
      <description>The Write-1-to-Clear (W1C) bits are exactly that write a '1'. FSTAT = [Appropriate bit].&lt;BR /&gt;&lt;BR /&gt;Using OR can lead to clearing bits that were not meant to be cleared. A bit could be lost by unintentional clearing if they are clearing interrupt flags. I realize that is not the case here.</description>
      <pubDate>Mon, 06 Mar 2023 13:15:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1610032#M64811</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2023-03-06T13:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1610331#M64814</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;BR /&gt;I'm sorry, but I'm not good at English, so I couldn't understand what you said.&lt;BR /&gt;very sorry.&lt;/P&gt;&lt;P&gt;＞Using OR can lead to clearing bits that were not meant to be cleared.&lt;BR /&gt;I don't think OR clears extra BITs.&lt;BR /&gt;Set only the necessary bits to 1.&lt;/P&gt;&lt;P&gt;&amp;gt;A bit could be lost by unintentional clearing if they are clearing interrupt flags.&lt;BR /&gt;Interrupt flag is not cleared.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 23:41:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1610331#M64814</guid>
      <dc:creator>tera</dc:creator>
      <dc:date>2023-03-06T23:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1610945#M64818</link>
      <description>(|=) Is a Read-Modify-Write operation.&lt;BR /&gt;If a bit in a register is a '1' when it is read, then it will be cleared when it is written.&lt;BR /&gt;&lt;BR /&gt;Some registers can have bits that transition to a '1' at any time.&lt;BR /&gt;&lt;BR /&gt;If that happens immediately before a (|=) operation to that register that '1' bit can be lost, because the bit is now a '1' and it will be written back to the register clearing the related Write-1-to-Clear (W1C) bit, without it ever being seen by the firmware.&lt;BR /&gt;&lt;BR /&gt;Some places using (|=) is required. Some places using it is bad. It depends on the register and the intention.&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Mar 2023 13:41:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1610945#M64818</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2023-03-07T13:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Flash cannot be erased with "FTFE Erase Flash Sector Command"</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1611203#M64820</link>
      <description>&lt;P&gt;&amp;gt;(|=) Is a Read-Modify-Write operation.&lt;BR /&gt;&amp;gt;If a bit in a register is a '1' when it is read, then it will be cleared when it is written.&lt;/P&gt;&lt;P&gt;I am doing OR with that intention&lt;/P&gt;&lt;P&gt;Writing a 1 clears the FSTAT flags.&lt;BR /&gt;There is no problem because OR is used to clear the flag.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 23:39:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-cannot-be-erased-with-quot-FTFE-Erase-Flash-Sector-Command/m-p/1611203#M64820</guid>
      <dc:creator>tera</dc:creator>
      <dc:date>2023-03-07T23:39:28Z</dc:date>
    </item>
  </channel>
</rss>

