<?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>8-bit MicrocontrollersのトピックRe: Runtime FLASH erase issue (9S08DZ60A)</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203012#M16768</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I also forgot to add the FLASH/EEPROM&amp;nbsp;configuration that I use for this application:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FCDIV = 0x13;&amp;nbsp; // FLASH &amp;amp; EEPROM clock = 200kHz [BusClk / (DIV + 1) = 4MHz / (19+1) = 200kHz].&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // = 0b00010011&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // B7 - Divisor Loaded Status Flag (DIVLD - Read Only)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // B6 - Prescale (Divide) Flash &amp;amp; EEPROM Clock by 8 (PRDIV8 - Write Once)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // B5:B0 - Divisor for Flash &amp;amp; EEPROM Clock Divider (DIV - Write Once)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thus, my clock time appears to be valid at 200kHz (please remember that my EEPROM erase/write routines operate correctly).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok, thanks again, and I still look forward to any insight you may have.&lt;/P&gt;&lt;P&gt;~&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jul 2009 05:07:23 GMT</pubDate>
    <dc:creator>belskyc</dc:creator>
    <dc:date>2009-07-29T05:07:23Z</dc:date>
    <item>
      <title>Runtime FLASH erase issue (9S08DZ60A)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203011#M16767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm working on an application using the MC9S08DZ60ACLH where I'd like to store the "factory configuration" into a block of FLASH to be used later for a "restore to factory defaults" reset service routine.&amp;nbsp; I currently have&amp;nbsp;successful EEPROM erase/write routines, so my first impression was to adapt these to a FLASH erase/write routine.&amp;nbsp; I've investigated the forums on FLASH erasing/writing and have started by implementing the common CopyToRAM() function in order to execute the FLASH erase/write from RAM.&amp;nbsp; This CopyToRAM() executes fine.&amp;nbsp; The problem is&amp;nbsp;after executing the Erase_FLASH()&amp;nbsp;function during &lt;SPAN style="text-decoration: underline;"&gt;runtime&lt;/SPAN&gt; from RAM,&amp;nbsp;my controller UUT&amp;nbsp;gets 'lost', resets a few times (assuming due to the COP)&amp;nbsp;and then finally locks up.&amp;nbsp; A curious symptom is that if I step through the Erase_FLASH() function using the CodeWarrior Real-Time Debugger, then the UUT will NOT lock up&amp;nbsp;and a 256-byte block of FLASH will successfully erase, but if I simply start the firmware from the beginning running real-time the UUT operates OK until it executes the Erase_FLASH after which it resests then locks up.&amp;nbsp; I've&amp;nbsp;attached my implementation.&amp;nbsp; A couple questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)&amp;nbsp; Has anyone seen this symptom before?&lt;/P&gt;&lt;P&gt;2)&amp;nbsp; After examining my code, can anyone see where I'm going wrong?&lt;/P&gt;&lt;P&gt;3)&amp;nbsp; Does anybody know where I can find exactly the addresses of the&amp;nbsp;FLASH blocks?&amp;nbsp; Perhaps I'm erasing a block containing code (even though I believe I have my PRM file setup correctly and the MAP file seems to verify this).&lt;/P&gt;&lt;P&gt;4)&amp;nbsp; The DZ60A data sheet says the FLASH block size is 768 bytes, why would the Real-Time Debugger Memory window only show a 256-byte block erased?&amp;nbsp; I'm wondering if this is real or if the Real-Time Debugger is giving me bogus data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much for your input.&lt;/P&gt;&lt;P&gt;~&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.freescale.com%2Ffiles%2Fcommunity_files%2F8BITCOMM%2Fmsg14618_Copy_of_IFC_DZ60.zip" rel="nofollow" target="_blank"&gt;Copy_of_IFC_DZ60.prm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.freescale.com%2Ffiles%2Fcommunity_files%2F8BITCOMM%2Fmsg14618_Copy_of_RAM_Funcs.c" rel="nofollow" target="_blank"&gt;Copy_of_RAM_Funcs.c&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.freescale.com%2Ffiles%2Fcommunity_files%2F8BITCOMM%2Fmsg14618_Copy_of_Main.c" rel="nofollow" target="_blank"&gt;Copy_of_Main.c&lt;/A&gt;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by belskyc on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-28&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;04:25 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by t.dowe on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-09-04&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;02:06 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2009 04:20:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203011#M16767</guid>
      <dc:creator>belskyc</dc:creator>
      <dc:date>2009-07-29T04:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime FLASH erase issue (9S08DZ60A)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203012#M16768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I also forgot to add the FLASH/EEPROM&amp;nbsp;configuration that I use for this application:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FCDIV = 0x13;&amp;nbsp; // FLASH &amp;amp; EEPROM clock = 200kHz [BusClk / (DIV + 1) = 4MHz / (19+1) = 200kHz].&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // = 0b00010011&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // B7 - Divisor Loaded Status Flag (DIVLD - Read Only)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // B6 - Prescale (Divide) Flash &amp;amp; EEPROM Clock by 8 (PRDIV8 - Write Once)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // B5:B0 - Divisor for Flash &amp;amp; EEPROM Clock Divider (DIV - Write Once)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thus, my clock time appears to be valid at 200kHz (please remember that my EEPROM erase/write routines operate correctly).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok, thanks again, and I still look forward to any insight you may have.&lt;/P&gt;&lt;P&gt;~&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2009 05:07:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203012#M16768</guid>
      <dc:creator>belskyc</dc:creator>
      <dc:date>2009-07-29T05:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime FLASH erase issue (9S08DZ60A)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203013#M16769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, and welcome to the forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can see a couple of issues with your sector erase code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, you have globally disabled interrupts near the start of the function, and have then incorrectly re-enabled interrups after the command is launched.&amp;nbsp; Interrupts should not be re-enabled until after the FCCF flag is set (or an error exit occurs).&amp;nbsp; The flash cannot be read during the execution of the command, so the interrupts vectors are inaccessible.&amp;nbsp; It is possible that a hardware interrupt, perhaps a timer interrupt, could occur during the 20 millisecond sector erase period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you using the derivative header file associated with the CW installation?&amp;nbsp; If so, you seem to be using the bit identification macros, rather than the bit mask macros required by your expressions. For example,&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FSTAT |= FSTAT_FCBEF; &amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;FONT face="arial,helvetica,sans-serif"&gt;should be corrected to the following&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FSTAT = FSTAT_FCBEF_MASK; // Launch command&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Similarly, for the error flag tests.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;while(!(FSTAT &amp;amp; FSTAT_FCCF_MASK)) { }&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Personally, I would not bother with a separate test of the FCBEF flag, since the FCCF flag indicates the completion of the command.&amp;nbsp; In fact, for more compact code, I would probably derive a composite mask for the FCCF flag and the two error flags, and then exit the wait loop when any one of the three flags became set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that not all your code needs to reside in RAM, only the code between the launching of the command and the exit from the wait loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the DZ60 device you also have another alternative to running the code from RAM.&amp;nbsp; It should be possible to store and run the code in EEPROM flash, which is separate from the main flash array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2009 13:43:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203013#M16769</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-07-29T13:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime FLASH erase issue (9S08DZ60A)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203014#M16770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mac,&lt;/P&gt;&lt;P&gt;Thanks for the advice, you hit it right on.&amp;nbsp; That's awesome.&amp;nbsp; The issue was Enabling Interrupts before the FCCF bit check was complete.&amp;nbsp; Thus, I'm able to erase &amp;amp; write to the FLASH sector now.&amp;nbsp; I learned something new today.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do have one more question, though.&amp;nbsp; Are you familiar with the CodeWarrior Real-Time Debugger, in particular the "Memory" window?&amp;nbsp; I'm able to successfully erase &amp;amp; write to the FLASH segment now, but the "Memory" window in the Real-Time Debugger doesn't seem to update correctly.&amp;nbsp; In short, I added a for-loop in my code for debugging to read back out of the FLASH segment to verify the data was correctly written into FLASH.&amp;nbsp; This passed ok, but the "Memory" window in the Real-Time debugger shows the first 160 bytes of the FLASH segment as value 0xFF (thereafter the window displays the correct data), whereas when I read the values from these same addresses (by using&amp;nbsp;the for-loop) the correct data is there.&amp;nbsp; Any ideas on this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for the great insight,&lt;/P&gt;&lt;P&gt;~Belskyc&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by belskyc on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-30&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;04:03 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2009 04:01:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203014#M16770</guid>
      <dc:creator>belskyc</dc:creator>
      <dc:date>2009-07-31T04:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime FLASH erase issue (9S08DZ60A)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203015#M16771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any updates in MEMORY window issue?&lt;/P&gt;&lt;P&gt;We have a problem with calculation of CRC over configuration parameters stored in flash (linear part) memory but are unable to debug the problem as the memory window is showing us old/wrong values. That’s the same with DATA window and when viewing single "variables" based in flash memory.&lt;/P&gt;&lt;P&gt;Any hints??&lt;/P&gt;&lt;P&gt;thnx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Mar 2010 16:10:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203015#M16771</guid>
      <dc:creator>BenFan</dc:creator>
      <dc:date>2010-03-11T16:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Runtime FLASH erase issue (9S08DZ60A)</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203016#M16772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BenFan,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you should modify Debugging Memory Map:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.freescale.com/message/33624#33624" title="https://community.freescale.com/message/33624#33624"&gt;https://community.freescale.com/message/33624#33624&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Mar 2010 19:07:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Runtime-FLASH-erase-issue-9S08DZ60A/m-p/203016#M16772</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-03-11T19:07:12Z</dc:date>
    </item>
  </channel>
</rss>

