<?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>ColdFire/68K Microcontrollers and ProcessorsのトピックRe: MCF52259 and flash writing / erasing</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164907#M5597</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the FLASH memory is made up of multiple banks it is possible to run code from one bank while programming the othe. Therefore you have to ensure that the code and programming section don't occupy the same bank (logical block) - if this is the case the code must be run from RAM otherwise is will fail. The larger chips tend to have two logical blocks while the smaller ones only one - therefore smaller chips have no alternative to running FLASH programming code from RAM. Generally it may be easier to always run from RAM so that such details don't become a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When programming double type variables they just need to be programmed as multiple 32 bit words. The 32 bit words also support cumulative write so it is also possible to write individual bytes at a time - the other bits in the long words should however be written with '1'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.uTasker.com" rel="nofollow" target="_self"&gt;www.uTasker.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Dec 2009 05:22:38 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2009-12-31T05:22:38Z</dc:date>
    <item>
      <title>MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164906#M5596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone. I'm working on a project of mine and using a board based upon MCF52259. I need to write some variables into the flash memory and I have two questions for you:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I read the application note AN3521 about flash programming on MCF5223X which is similar to MCF5225X. It says that accesses to flash memory should be done from RAM and provides a very good example code for doing that. Well, I tried to write and erase words and pages of the flash directly from the flash itself and it works fine at all. Is MCF5225X different from MCF5223X?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) I successfully succeded in writing datas into the flash. Now I need to write some double type variables into flash. The program command is only for 32-bit word data. Do you have any suggestions or ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;best regards and happy new year &lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Marco.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Dec 2009 03:05:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164906#M5596</guid>
      <dc:creator>LordMark</dc:creator>
      <dc:date>2009-12-31T03:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164907#M5597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the FLASH memory is made up of multiple banks it is possible to run code from one bank while programming the othe. Therefore you have to ensure that the code and programming section don't occupy the same bank (logical block) - if this is the case the code must be run from RAM otherwise is will fail. The larger chips tend to have two logical blocks while the smaller ones only one - therefore smaller chips have no alternative to running FLASH programming code from RAM. Generally it may be easier to always run from RAM so that such details don't become a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When programming double type variables they just need to be programmed as multiple 32 bit words. The 32 bit words also support cumulative write so it is also possible to write individual bytes at a time - the other bits in the long words should however be written with '1'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.uTasker.com" rel="nofollow" target="_self"&gt;www.uTasker.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Dec 2009 05:22:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164907#M5597</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2009-12-31T05:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164908#M5598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Lord Mark wrote:&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;...&lt;BR /&gt;&lt;P&gt;1) I read the application note AN3521 about flash programming on MCF5223X which is similar to MCF5225X. It says that accesses to flash memory should be done from RAM and provides a very good example code for doing that. Well, I tried to write and erase words and pages of the flash directly from the flash itself and it works fine at all. Is MCF5225X different from MCF5223X?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The manual says:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;After a command has been successfully launched, the CFM signals the core platform to hold off read accesses to any active flash physical block until all active and buffered commands have completed (CCIF=1). A flash write operation from the internal flash bus holds off the Core platform until it is completed.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe this means that it's not necessary to execute flash writing code out of RAM, it can be done from flash. That's how I do it with MCF52233 and MCF52259 - no problem so far.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Dec 2009 15:34:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164908#M5598</guid>
      <dc:creator>scifi</dc:creator>
      <dc:date>2009-12-31T15:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164909#M5599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;Well, the memory of the MCF52259 is made up of 4 blocks so you all are right about that. I was using the latest page of the flash memory for my variables, that's why I succeded in accessing it without executing code from RAM.&amp;nbsp;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&amp;nbsp;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;mjbcswitzerland wrote:&amp;nbsp;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When programming double type variables they just need to be programmed as multiple 32 bit words. The 32 bit words also support cumulative write so it is also possible to write individual bytes at a time - the other bits in the long words should however be written with '1'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&amp;nbsp;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;What do you mean with "Cumulative write"? &amp;nbsp;Shouldn't the flash be erased before writing?&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&amp;nbsp;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;Regards,&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;Marco.&amp;nbsp;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&amp;nbsp;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Dec 2009 19:12:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164909#M5599</guid>
      <dc:creator>LordMark</dc:creator>
      <dc:date>2009-12-31T19:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164910#M5600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of cumulative writes are setting a long word from 0xffffffff to 0x5555ffff and then to 0x55555555&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Starting from 0xffffffff (non-programmed) the first write sets some bits to '0'. These can not be set back to '1' without deleting the complete sector. However it is possible to program the same long word address to set other bits to '0' as in the case of the 0x55555555 (it has only programmed additional bits to '0').&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Coldfire FLASH, as various others, has no problems doing this. Some FLASH types can cause data corruption when this is tried either due to electrical stresses or check sums in the FLASH line which are no longer correct after a second write (eg. NXP devices).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"After a command has been successfully launched, the CFM signals the core platform to hold off read accesses to any active flash physical block ..."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know exactly what to make of this since when I first went to the Coldfire seminars the instructor said that it was absolutely necessary to run code from RAM when programming the same logical block and therefore I have always run it from RAM (generally it is also necessary to block interrupts since they could cause code to attempt to run from an area being programmed). In a project with the M52235 there were crashes during FLASH programming due to an NMI interrupt (which is not blocked by the interrupt masking) due to the fact that the NMI handler (in FLASH) would try to access the 'not-available' FLASH, which immediately causes an exception (crash of the board). By ensuring that FLASH programming was not performed in parallel to the NMI (eg. during motor control sequences)this problem was successfully avoided. This experience showed that there is some relevance to not allowing FLASH to be accessed while programming - whether there are differences between exception accesses and standard code sequence accesses is another question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have more information or conclusive explanations?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Dec 2009 21:18:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164910#M5600</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2009-12-31T21:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164911#M5601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;programming more bits to '0' should be clarified a bit, at least for newbies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Programming erased long word (0xFFFFFFFF) to 0x5555FFFF programs some bits from erased state '1' to programmed state '0'. That's obvious, I guess.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is &lt;STRONG&gt;not completely&amp;nbsp;true that programming 0x5555FFFF&amp;nbsp;to 0x55555555&lt;/STRONG&gt; &lt;STRONG&gt;&lt;U&gt;only&lt;/U&gt; programs additional bits to '0'&lt;/STRONG&gt;. In fact it programs some bits from '1' to '0' and also &lt;STRONG&gt;overprogramms some previously programmed bits&amp;nbsp;from '0' to '0'&lt;/STRONG&gt;. Overprogramming&amp;nbsp;is very very bad, (I believe) not allowed by Freescale and may lead to premature flash wearout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When one wants to reprogram 0x5555FFFF to 0x55555555, he should write to the flash array 0xFFFF5555. Then resulting word in flash will be 0x55555555 and no bit will be overprogrammed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Logics should be like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) if ( (want_word &amp;amp; current_flash_word) != want_word ) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flash must be erased. It is not possible to program want_word without erasing current_flash_word&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) // make want_word not overprogramming '0' bits to '0'. Force&amp;nbsp;already programmed bits to '1'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; want_word = ~current_flash_word | want_word;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current_flash_word = 0x5555FFFF&lt;/P&gt;&lt;P&gt;~current_flash_word = 0xAAAA0000&lt;/P&gt;&lt;P&gt;want_word | ~current_flash_word = 0x55555555 | 0xAAAA0000 = 0xFFFF5555&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) latch want_word to flash and program it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jan 2010 18:41:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164911#M5601</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-01-01T18:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164912#M5602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anyway I don't need to reprogram a word already partially programmed. I just needed to write double type variables (64 bit) into flash. So it should be done 32 bit at a time, shouldn't it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Marco.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jan 2010 19:40:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164912#M5602</guid>
      <dc:creator>LordMark</dc:creator>
      <dc:date>2010-01-01T19:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164913#M5603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;kef wrote:&lt;BR /&gt;...&lt;P&gt;But it is &lt;STRONG&gt;not completely&amp;nbsp;true that programming 0x5555FFFF&amp;nbsp;to 0x55555555&lt;/STRONG&gt; &lt;STRONG&gt;&lt;U&gt;only&lt;/U&gt; programs additional bits to '0'&lt;/STRONG&gt;. In fact it programs some bits from '1' to '0' and also &lt;STRONG&gt;overprogramms some previously programmed bits&amp;nbsp;from '0' to '0'&lt;/STRONG&gt;. Overprogramming&amp;nbsp;is very very bad, (I believe) not allowed by Freescale and may lead to premature flash wearout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When one wants to reprogram 0x5555FFFF to 0x55555555, he should write to the flash array 0xFFFF5555. Then resulting word in flash will be 0x55555555 and no bit will be overprogrammed.&lt;/P&gt;...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;We have firmware on the 5282 that occasionally performs the overprogramming in the naiive manner that Mark described. During development I tried it and is seemed to work without problems, so I left it in. It has probably been executed no more than 20 times on any given 5282 chip,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But we don't want to wear the chips out early, so I guess I should prevent the overprogramming using the technique you outlined, test it and include it in the next firmware update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A quick net search turned up no other references about overprogramming flash. Can you tell us where you learned about this overprogramming problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx, Bryan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jan 2010 22:55:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164913#M5603</guid>
      <dc:creator>bkatt</dc:creator>
      <dc:date>2010-01-01T22:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164914#M5604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class="MsoNormal"&gt;&lt;FONT color="#000000"&gt;&lt;FONT size="3"&gt;&lt;FONT face="Times New Roman"&gt;Marco,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;FONT color="#000000"&gt;&lt;FONT size="3"&gt;&lt;FONT face="Times New Roman"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;FONT color="#000000"&gt;&lt;FONT size="3"&gt;&lt;FONT face="Times New Roman"&gt;of course&amp;nbsp;you should write 64bit double&amp;nbsp;32 bits at a time,&amp;nbsp;two times.&amp;nbsp;But you should make sure you write them to long word aligned address, else you may need 3 program operations. Your compiler can align your flash variables by default or should provide some compiler #pragma or something to let you align your variables.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;FONT color="#000000"&gt;&lt;FONT size="3"&gt;&lt;FONT face="Times New Roman"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;FONT color="#000000"&gt;&lt;FONT size="3"&gt;&lt;FONT face="Times New Roman"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;FONT color="#000000"&gt;&lt;FONT size="3"&gt;&lt;FONT face="Times New Roman"&gt;Bryan, Mark,&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;P class="MsoNormal"&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;Unfortunately I don’t know good document that could explain it all clearly. The only good related Freescale/Motorola document I know is old HC11 reference manual. There’s over 10 pages chapter 4.6, EEPROM application information, which falls quite deep into EEPROM internals, discussing also write-more-zeros method (writing 0x55 to 0x5F to get 0x55) and selective-write method (writing 0xF5 to 0x5F to get 0x55). I don’t know how far flash EEPROM technology went from HC11 times, but I guess it should be still similar to old EEPROM technology. HC11 reference manual is here:&lt;/FONT&gt; &lt;A href="http://www.freescale.com/files/microcontrollers/doc/ref_manual/M68HC11RM.pdf" rel="nofollow" target="_blank"&gt;&lt;FONT face="Times New Roman" size="3"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://www.freescale.com/files/microcontrollers/doc/ref_manual/M68HC11RM.pdf" target="test_blank"&gt;http://www.freescale.com/files/microcontrollers/doc/ref_manual/M68HC11RM.pdf&lt;/A&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Times New Roman"&gt;But it seems I also was wrong suggesting selective-write method is better than write-more-zeros. Both methods have problems. Sorry for that.&amp;nbsp;Write-more-zeros exposes flash cells to programming voltage for two or more&amp;nbsp;nominal program times (high voltage exposure times). As you may know, flash clock divider determines program and erase times. There’s a caution note in MCF52259RM, saying “&lt;SPAN&gt;Programming the flash with bus frequency &amp;lt; 150 KHz should be avoided. Setting CFMCLKD to a value such that FCLK &amp;lt; 150 KHz &lt;STRONG&gt;can destroy the&lt;/STRONG&gt; &lt;STRONG&gt;flash memory due to overstress&lt;/STRONG&gt;…&lt;/SPAN&gt; ” . So if too long program time is a problem, then cumulative write more zeros also should be a problem and can destroy the flash, isn’t it?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;P class="MsoNormal"&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;Selective write more zeros method (what I suggested and what I shouldn’t suggest) seems being also bad. It seems I didn’t understand it long time ago, when I was using HC11. Unless there are extra p-n junctions or something smart in flash cells (unlikely due to extra costs), selective write method can cancel programming process prematurely. Please look into HC11RM. I also tried to explain that in my pictures. Please see them attached.&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color="#000000" face="Times New Roman" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;P class="MsoNormal"&gt;I use selective write method with HC11, HC12 and HCS12 EEPROM for years. No single problem was reported. But I'll better revise my EEPROM routines.&lt;/P&gt;&lt;P class="MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;IMG border="0" height="510" src="http://s53.radikal.ru/i142/1001/86/9360036a7c46.png" width="602" /&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;IMG border="0" height="400" src="http://s50.radikal.ru/i129/1001/17/1716f97e9d6e.png" width="602" /&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;IMG border="0" height="400" src="http://s51.radikal.ru/i131/1001/77/a8a1bb2ffb18.png" width="602" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Jan 2010 18:44:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164914#M5604</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-01-02T18:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164915#M5605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;But looking at NOR flash cell structure at &lt;A href="http://en.wikipedia.org/wiki/Flash_memory" rel="nofollow" target="_blank"&gt;http://en.wikipedia.org/wiki/Flash_memory&lt;/A&gt;&amp;nbsp;, and taking into account that programming is done using hot-electron emission; high current through turned on flash cell transistor is what makes floating gate charged; I don't see how selective-write-more-zeros method could cause an issue to flash cells. So maybe it is indeed better to use selective write more zeros than just write more zeros. Not enough data at hand to be sure.&amp;nbsp;Most Freescale MCU reference manuals state that programming of not erased words is not allowed...&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Jan 2010 23:25:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164915#M5605</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-01-02T23:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164916#M5606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;First off, just because it works on the MCF5225x part does not mean that it should.&amp;nbsp; Technically, according to the designers, you should not be able to erase one block of flash while running from another.&amp;nbsp; Although it seems to work, doesn't mean that we can recommend people do it. At least this was valid for the MCF5223x&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;You’re doing something that technically should not be allowed.&amp;nbsp;You should be happy that something that isn't supposed to work actually does work on the MCF5225x parts!&lt;/SPAN&gt; &lt;SPAN&gt;&lt;SPAN&gt;:smileyhappy:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 04:35:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164916#M5606</guid>
      <dc:creator>PaoloRenzo</dc:creator>
      <dc:date>2010-01-05T04:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164917#M5607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd like to join Mark in his call for information on this issue.&lt;/P&gt;&lt;P&gt;So far it's all hearsay, and microcontroller manuals don't seem to be of much help here.&lt;/P&gt;&lt;P&gt;Of course, there is the safe option of running flash writing code from RAM. But in many cases that would be a considerable complication. It would be nice if this could be avoided.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 18:31:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164917#M5607</guid>
      <dc:creator>scifi</dc:creator>
      <dc:date>2010-01-05T18:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164918#M5608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's the answer form Freescale Support about this issue. I asked about accessing the flash directly from the flash itself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;"Customer can run code from Flash to do Flash erase/program applications,&lt;BR /&gt;such as using Flash as an eeprom device and so on.&lt;BR /&gt;The restriction condition is that: application code area and data&lt;BR /&gt;storage area is not in the same Flash sector. customer can not run "Mass&lt;BR /&gt;Erase" &amp;amp; "Blank Check" commands.&lt;BR /&gt;Although it seems to work, while we can not recommend engineers to do&lt;BR /&gt;like this way.&lt;BR /&gt;The application note recommend to copy code from Flash to RAM, and run&lt;BR /&gt;from RAM."&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it seems to me that it is 100% safe to write flash from RAM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 18:37:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164918#M5608</guid>
      <dc:creator>LordMark</dc:creator>
      <dc:date>2010-01-05T18:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164919#M5609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I should have searched the site first. There is a FAQ entry from 2007 that confirms Lord Mark's findings:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/webapp/TransformXMLServlet?XmlId=FAQ-27893&amp;amp;XslId=SingleFaqDisplay.xsl&amp;amp;XslId2=FAQAttachment.xsl&amp;amp;fsrch=1" rel="nofollow" target="_self"&gt;Coldfire Flash Module CFM - when the code/data relocation is needed&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for repeated programming of the same longword, the only thing I could find is Application Note 3521:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/files/32bit/doc/app_note/AN3521.pdf" rel="nofollow" target="_self"&gt;AN3521&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It concerns the CFM of the MCF521. Among other things, it says:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;After erasing a longword, using page or mass erase, the value is 0xFFFFFFFF. The programmer can clear bits in the same longword, but cannot set bits, until an erase command is executed previously.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This suggests that it's OK to program the same longword repeatedly to clear bits. But there is no information on how repeated writes affect flash reliability. I guess I should submit a service request with the question...&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by scifi on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2010-01-05&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;12:01 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 19:55:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164919#M5609</guid>
      <dc:creator>scifi</dc:creator>
      <dc:date>2010-01-05T19:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164920#M5610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Lord Mark wrote:&lt;BR /&gt;&lt;P&gt;Here's the answer form Freescale Support about this issue. I asked about accessing the flash directly from the flash itself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;"...Although it seems to work, while we can not recommend engineers to do like this way.&lt;BR /&gt;The application note recommend to copy code from Flash to RAM, and run rom RAM."&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it seems to me that it is 100% safe to write flash from RAM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The manufacturer is saying "can not recommend" and you're translating that as "100% safe". Remind me to never buy any products you've written code for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you're doing this a a hobby, then it is safe as a hobby, but "real world products" had better follow the rules laid down by the component manufacturer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&amp;nbsp;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 20:45:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164920#M5610</guid>
      <dc:creator>TomE</dc:creator>
      <dc:date>2010-01-05T20:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164921#M5611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Freescale engineers cannot recommend to write flash directly from flash. So I wrote "it is 100% safe to write flash from RAM" as suggested in the application note... where am I wrong?&amp;nbsp;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Lord Mark on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2010-01-05&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;12:56 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 20:55:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164921#M5611</guid>
      <dc:creator>LordMark</dc:creator>
      <dc:date>2010-01-05T20:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164922#M5612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;scifi wrote: &lt;A href="http://www.freescale.com/files/32bit/doc/app_note/AN3521.pdf" rel="nofollow" target="_self"&gt;http://www.freescale.com/files/32bit/doc/app_note/AN3521.pdf" rel="nofollow" target="_self&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;A href="http://www.freescale.com/files/32bit/doc/app_note/AN3521.pdf" rel="nofollow" target="_self"&gt;AN3521&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It concerns the CFM of the MCF521. Among other things, it says:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;After erasing a longword, using page or mass erase, the value is 0xFFFFFFFF. The programmer can clear bits in the same longword, but cannot set bits, until an erase command is executed previously.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This suggests that it's OK to program the same longword repeatedly to clear bits.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It seems to read that way. What the writer may have meant is that you can clear bits in successive longwords in a SECTOR (write to location zero, then 4 then 8 and so on, but can't write ones until the SECTOR has been erased.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The App Note refers to the Reference Manual for details. I've just read the whole of the FLASH chapter and there's no mention of multiple writes. It only states "Program: The operation programs a previously erased address in the flash memory using an embedded algorithm."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No mention there of programming a previously-programmed location. That reads as "you can only write to an erased word" and I'd read that to say you only get to do it once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please do submit a service request. I suspect you'll get a "not recommended" response like the previous poster got. If Freescale doesn't have production tests for a chip function, then they can't GUARANTEE the function on all of their chips.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just because something "seems to work" on one batch of chips doesn't guarantee the next 10,000 units are going to work the same way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's a huge amount of FLASH, unlike EEPROM in old HC11's. Why would you WANT to overwrite multiple bits in a word? What's the reason?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another point, if you did find a chip that let you do this, the code would not be portable to any other chips that didn't allow this. Code written to not depend on this "feature" is a lot more portable to other chips.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In response to a previous post, EEPROM and FLASH are different. What worked 15 years ago in manually programming an EEPROM in an HC11 doesn't help with what an embedded algorithm programming modern FLASH hardware is doing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 21:18:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164922#M5612</guid>
      <dc:creator>TomE</dc:creator>
      <dc:date>2010-01-05T21:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164923#M5613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Lord Mark wrote:&lt;BR /&gt;Freescale engineers cannot recommend to write flash directly from flash. So I wrote "it is 100% safe to write flash from RAM" as suggested in the application note... where am I wrong?&amp;nbsp;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You're correct. I misread your post as "safe to write FLASH from FLASH". Sorry.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 21:20:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164923#M5613</guid>
      <dc:creator>TomE</dc:creator>
      <dc:date>2010-01-05T21:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164924#M5614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;TomE wrote:&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;There's a huge amount of FLASH, unlike EEPROM in old HC11's. Why would you WANT to overwrite multiple bits in a word? What's the reason?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;When I first started to look around for ideas to emulate EEPROM, I was working with the STR710 from ST. ST have an application note:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.st.com/stonline/books/pdf/docs/11025.pdf" rel="nofollow" target="_self"&gt;EEPROM Emulation with STR71x&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It mentions 'incremental programming':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Incremental programmming: The Flash controller will accept to program a word that is already programmed if the new word is adding more “0” bits.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was used in the proposed EEPROM emulation algorithm to update the sector status code incrementally: 0xFF, 0xFE, 0xFC, 0xF8 and so on. The status codes would mean something like 'erased', 'updating', 'up-to-date', 'expired'.&lt;/P&gt;&lt;P&gt;I implemented EEPROM emulation based on ideas from ST's application notes. Incremental programming was used in the implementation. It's useful for 2 reasons:&lt;/P&gt;&lt;P&gt;- My implementation adds new records to flash in 16-bit chunks. Transitioning to 32-bit chunks will waste more memory.&lt;/P&gt;&lt;P&gt;- 'Transaction complete' markers. Right now I use a single bit for those. Without incremental programming I'll have to use 32-bit words. That's a considerable waste of memory.&lt;/P&gt;&lt;P&gt;When porting software to Coldfire, I only made minor modifications. EEPROM emulation is essentially identical to that of STR710. I should probably correct that now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 23:17:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164924#M5614</guid>
      <dc:creator>scifi</dc:creator>
      <dc:date>2010-01-05T23:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: MCF52259 and flash writing / erasing</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164925#M5615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not wishing to start a war of opinions but I must admit that there are many occasions when incremental programming of 32 bit words is a nice advantage - the Freescale devices are quite pleasant to use in this respect:&lt;/P&gt;&lt;P&gt;1) when porting Flash drivers from 8 or 16 bit processors&lt;/P&gt;&lt;P&gt;2) when counting events in non-volatile memory (one event can be counted by setting a further '0' in a block of memory rather than a complete word. 32x saving is very noticable in such cases.&lt;/P&gt;&lt;P&gt;3) EEPROM emulation and safe updates (this is also the method used in Intel application notes from the first FLASH devices that I used around 1993 - here their recommendation was to mark a block as in progress by setting its first byte to 0xfe, then mark that it was ready by setting it to 0xfc, and later marking it as temporarily deleted by setting it to 0xf8 - once a new block was ready it could be deleted but in the mean time could always be recovered in case of a system failure during the sequence -&lt;EM&gt;or something like that&lt;/EM&gt;). Admitedly it could also be done using several reserved words...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On a side note - try porting any existing Flash driver (whether byte, short word or long word oriented) to an NXP chip. Porting is then not really the name for it - it is more like "starting again"...;-)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jan 2010 23:34:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/MCF52259-and-flash-writing-erasing/m-p/164925#M5615</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2010-01-05T23:34:50Z</dc:date>
    </item>
  </channel>
</rss>

