<?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>S12 / MagniV MicrocontrollersのトピックRe: S12XDT flash erase/write issue</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12XDT-flash-erase-write-issue/m-p/213684#M8954</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah right, thanks for pointing it out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still have the same behaviour when trying to erase/write however. Is there something in particular I need to consider when working with the S12X?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Mar 2012 15:26:16 GMT</pubDate>
    <dc:creator>almqvist</dc:creator>
    <dc:date>2012-03-08T15:26:16Z</dc:date>
    <item>
      <title>S12XDT flash erase/write issue</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12XDT-flash-erase-write-issue/m-p/213682#M8952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have been working on a flash loader for S12XDT. The code I've been using as a base was originally written for, and runs fine on a S12C. While porting the code I've ran into a problem, let me try to explain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I erase a flash sector using the following function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;sbyte FlashEraseSector(word *__pptr pAddress){ static word* address; address = (word *)pAddress; FSTAT = FSTAT_ACCERR | FSTAT_PVIOL; // clear errors (*address) = 0xFFFF;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Dummy store to page to be erased FCMD = SECTOR_ERASE; (void)DoOnStack(pAddress); if (FSTAT_ACCERR) {&amp;nbsp; return ACCESS_ERROR; } else if (FSTAT_PVIOL) {&amp;nbsp; return PROTECTION_ERROR; } else {&amp;nbsp; return PASS; }}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This "seems" to work just well and a passed result is returned. But when I want to confirm that the memory is in fact erased I found out that it's not. This is the function used to write a word to flash, and it returns flash not erased.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#define FLASH_ERASED_WORD&amp;nbsp; 0xFFFFu&lt;/PRE&gt;&lt;PRE&gt;sbyte FlashWriteWord(word *__pptr pAddress, word data){ FSTAT = FSTAT_PVIOL | FSTAT_ACCERR;&amp;nbsp; if(*pAddress != FLASH_ERASED_WORD)&amp;nbsp; {&amp;nbsp; return FLASH_NOT_ERASED;// It returns here when I run... } else if(*pAddress == data) {&amp;nbsp;&amp;nbsp; return PASS; } else {&amp;nbsp; *pAddress = data;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Store desired data to address being programmed&amp;nbsp; FCMD = WORD_PROGRAM;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Store programming command in FCMD&amp;nbsp; (void)DoOnStack(pAddress);&amp;nbsp;&amp;nbsp;&amp;nbsp; // just passed for PPAGE&amp;nbsp; if (FSTAT_ACCERR)&amp;nbsp; {&amp;nbsp;&amp;nbsp; return ACCESS_ERROR;&amp;nbsp; }&amp;nbsp; else if (FSTAT_PVIOL)&amp;nbsp; {&amp;nbsp;&amp;nbsp; return PROTECTION_ERROR;&amp;nbsp; }&amp;nbsp; else&amp;nbsp; {&amp;nbsp;&amp;nbsp; if (*pAddress == data)&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; return PASS;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; else&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; return FAIL;&amp;nbsp;&amp;nbsp; }&amp;nbsp; } }}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also checked while debugging and find that the memory is not been erased. The memory I try to erase and write to is within paged flash (page F8 to FE).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any clue as to why the memory is no erased? I don't have alot of experience with S12C/S12XDT so I can't quite figure out how to tackle this problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 15:30:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12XDT-flash-erase-write-issue/m-p/213682#M8952</guid>
      <dc:creator>almqvist</dc:creator>
      <dc:date>2012-03-07T15:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: S12XDT flash erase/write issue</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12XDT-flash-erase-write-issue/m-p/213683#M8953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't know if this will help, but please fix this bug:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;FSTAT = FSTAT_ACCERR&lt;FONT color="#ff0000"&gt;_MASK&lt;/FONT&gt; | FSTAT_PVIOL&lt;FONT color="#ff0000"&gt;_MASK&lt;/FONT&gt;; // clear errors&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 16:26:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12XDT-flash-erase-write-issue/m-p/213683#M8953</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-03-07T16:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: S12XDT flash erase/write issue</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12XDT-flash-erase-write-issue/m-p/213684#M8954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah right, thanks for pointing it out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still have the same behaviour when trying to erase/write however. Is there something in particular I need to consider when working with the S12X?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Mar 2012 15:26:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12XDT-flash-erase-write-issue/m-p/213684#M8954</guid>
      <dc:creator>almqvist</dc:creator>
      <dc:date>2012-03-08T15:26:16Z</dc:date>
    </item>
  </channel>
</rss>

