<?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>MPC5xxxのトピックRe: flash erase on MPC5510</title>
    <link>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239556#M115</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lukas,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you for your reply.&lt;BR /&gt;Actually, I have already written a piece of code (very similar to yours) for flash erase. It works fine when I use it on a simple program, but I need to use it under a Real Time Operating System, and when I do the execution jumps to an address where it should not go. It is weird because it also works fine when I use step mode (when I run it with the RTOS).&lt;/P&gt;&lt;P&gt;Do you know if there may be some side effects because of using an RTOS (such as interrupts or something)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code for erasing a Low address space block, assuming the block has been enabled before.&lt;/P&gt;&lt;P&gt;Many thanks !&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1368789886308445" jivemacro_uid="_1368789886308445" modifiedtitle="true"&gt;
&lt;P&gt;/* erase a block from low adress space &lt;/P&gt;
&lt;P&gt; * block : 0..9 */&lt;/P&gt;
&lt;P&gt;void eraseBlock (int block) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* start erase sequence */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.MCR.B.ERS = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* block selection for erase */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.LMS.B.LSEL = 0b0000000000 | (1 &amp;lt;&amp;lt; block);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* erase interlock write */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; *(unsigned int *)(0x4000 * block) = 0xffffffff; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* high voltage enable */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.MCR.B.EHV = 1;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* wait for done and program/erase good */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; while(!FLASH.MCR.B.DONE) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; while (!FLASH.MCR.B.PEG) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* high voltage disable */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.MCR.B.EHV = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* end of erase sequence */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.MCR.B.ERS = 0;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* diselect block */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.LMS.B.LSEL = 0b0000000000;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 May 2013 11:28:44 GMT</pubDate>
    <dc:creator>petitbeurre</dc:creator>
    <dc:date>2013-05-17T11:28:44Z</dc:date>
    <item>
      <title>flash erase on MPC5510</title>
      <link>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239554#M113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a bit confused about some point on the MPC5510 Reference Manual, about flash erase. In section 22.5.5 (Flash Erase, chapter Flash Array and Control), step 3 indicates : "Write any address in flash. This is referred to as an erase interlock write".&lt;/P&gt;&lt;P&gt;I do not understand what an "erase interlock write" is, and what its purpose is. Also, I've noted that if I omit this step, the erase seems to work just as fine.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone enlighten me please?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Nicolas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 May 2013 14:42:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239554#M113</guid>
      <dc:creator>petitbeurre</dc:creator>
      <dc:date>2013-05-15T14:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: flash erase on MPC5510</title>
      <link>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239555#M114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;take a look at this thread:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/message/328958#328958"&gt;https://community.freescale.com/message/328958#328958&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I posted sample code where you can find how to do interlock write. It was written for another MCU but the principle is still the same.&lt;/P&gt;&lt;P&gt;Lukas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 10:59:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239555#M114</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2013-05-17T10:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: flash erase on MPC5510</title>
      <link>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239556#M115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lukas,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you for your reply.&lt;BR /&gt;Actually, I have already written a piece of code (very similar to yours) for flash erase. It works fine when I use it on a simple program, but I need to use it under a Real Time Operating System, and when I do the execution jumps to an address where it should not go. It is weird because it also works fine when I use step mode (when I run it with the RTOS).&lt;/P&gt;&lt;P&gt;Do you know if there may be some side effects because of using an RTOS (such as interrupts or something)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code for erasing a Low address space block, assuming the block has been enabled before.&lt;/P&gt;&lt;P&gt;Many thanks !&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1368789886308445" jivemacro_uid="_1368789886308445" modifiedtitle="true"&gt;
&lt;P&gt;/* erase a block from low adress space &lt;/P&gt;
&lt;P&gt; * block : 0..9 */&lt;/P&gt;
&lt;P&gt;void eraseBlock (int block) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* start erase sequence */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.MCR.B.ERS = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* block selection for erase */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.LMS.B.LSEL = 0b0000000000 | (1 &amp;lt;&amp;lt; block);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* erase interlock write */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; *(unsigned int *)(0x4000 * block) = 0xffffffff; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* high voltage enable */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.MCR.B.EHV = 1;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* wait for done and program/erase good */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; while(!FLASH.MCR.B.DONE) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; while (!FLASH.MCR.B.PEG) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* high voltage disable */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.MCR.B.EHV = 0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* end of erase sequence */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.MCR.B.ERS = 0;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; /* diselect block */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FLASH.LMS.B.LSEL = 0b0000000000;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 11:28:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239556#M115</guid>
      <dc:creator>petitbeurre</dc:creator>
      <dc:date>2013-05-17T11:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: flash erase on MPC5510</title>
      <link>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239557#M116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to ensure that there's no access to flash partition which contains flash block that is being programmed or erased. Read-while-write is supported only between partitions. For example, if you erase/program block L0 or L1 or L2 or L3, then you can't access whole partition 1 (0x0000_0000 - 0x0000_BFFF) during that operation.&lt;/P&gt;&lt;P&gt;So, if any other tasks or interrupts access that partition during erase/program operation then it could lead to problems.&lt;/P&gt;&lt;P&gt;Lukas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 11:40:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239557#M116</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2013-05-17T11:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: flash erase on MPC5510</title>
      <link>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239558#M117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay so if I understand correctly, if the code of my application is stored in block L2 for example, this code attempts to erase block L3, this could lead to a read-while-write problem because L2 and L3 are in the same partition?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 12:20:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239558#M117</guid>
      <dc:creator>petitbeurre</dc:creator>
      <dc:date>2013-05-17T12:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: flash erase on MPC5510</title>
      <link>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239559#M118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Exactly. The code must run from another partition or from RAM. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 12:22:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239559#M118</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2013-05-17T12:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: flash erase on MPC5510</title>
      <link>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239560#M119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well thank you very much Lukas for having helped me on this!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 May 2013 12:29:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/flash-erase-on-MPC5510/m-p/239560#M119</guid>
      <dc:creator>petitbeurre</dc:creator>
      <dc:date>2013-05-17T12:29:09Z</dc:date>
    </item>
  </channel>
</rss>

