<?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: XDP512 Runtime flash writing</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209974#M8683</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;You can have code in another bank of Flash memory erase and program a different Flash memory bank. You just need to be careful that you don't step outside of the address range of the bank you're programming. This technique only works for MCUs with two of more banks of Flash, so it won't work on all MCUs. Executing the Flash programming code from RAM will work across all processors, which is why folks keep emphasizing the technique. However, if allyou're using is this specific MCU then the program-from-another-Flash-bank technique will work. More information on the subject can be found on this &lt;A href="http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&amp;amp;message.id=302&amp;amp;query.id=108904#M302" target="_blank"&gt;thread&lt;/A&gt;.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Apr 2008 20:52:58 GMT</pubDate>
    <dc:creator>J2MEJediMaster</dc:creator>
    <dc:date>2008-04-07T20:52:58Z</dc:date>
    <item>
      <title>XDP512 Runtime flash writing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209971#M8680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;I am trying to write in flash memory on runtime. There are some faults.&lt;/DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;DIV class="text_smallest"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="text_smallest"&gt;#define ALIGNED_WORD_MASK 0x0001&lt;/DIV&gt;&lt;DIV class="text_smallest"&gt;#define PROG&amp;nbsp;0x20&lt;/DIV&gt;&lt;DIV class="text_smallest"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="text_smallest"&gt;#pragma push&lt;BR /&gt;#pragma DATA_SEG FLASH_DIAG&lt;BR /&gt;unsigned int FLASH_DiagSave[16];&lt;/DIV&gt;&lt;DIV class="text_smallest"&gt;#pragma pop&lt;/DIV&gt;&lt;PRE&gt;unsigned int ProgFlash(unsigned int* progAdr,unsigned int* bufferPtr,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int size){ if(((unsigned int)progAdr &amp;amp; ALIGNED_WORD_MASK) != 0)&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Check for aligned word */ {&amp;nbsp; return(FAIL); }&amp;nbsp;&amp;nbsp; while (!FSTAT_CBEIF);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (FSTAT_ACCERR || FSTAT_PVIOL)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FSTAT = 0x30;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *progAdr = 15;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FCMD = PROG;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FSTAT = FSTAT_CBEIF_MASK;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!FSTAT_CBEIF);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!FSTAT_CCIF);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(PASS);}//------------------------------------------------------------------------------void ConfigFCLKDIV(void)&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!FCLKDIV_FDIVLD)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FCLKDIV_PRDIV8 = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FCLKDIV_FDIV = 10;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&amp;nbsp; }//------------------------------------------------------------------------------void main(void) {&amp;nbsp; unsigned int result = 0;&amp;nbsp; volatile byte flashValue;&amp;nbsp; byte debug=0;&amp;nbsp; unsigned char i;&amp;nbsp; /* put your own code here */&amp;nbsp; SetupXGATE();&amp;nbsp; EnableInterrupts;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConfigFCLKDIV(); result = ProgFlash(FLASH_DiagSave, DiagBuffer, 16);&amp;nbsp; flashValue = (byte)FLASH_DiagSave[0];&amp;nbsp; for(;;) {&amp;nbsp;&amp;nbsp;&amp;nbsp; } /* wait forever */&amp;nbsp; /* please make sure that you never leave this function */}&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;If I set a break point at the line of&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "flashValue = (byte)FLASH_DiagSave[0];"&amp;nbsp;&amp;nbsp;&amp;nbsp; program don't stop and run forever. If I halt it stops unknown area. But if I set a breakpoint at the line of&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "while (!FSTAT_CBEIF);"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in&amp;nbsp; "ProgFlash" function there is no problem writing 15 to&amp;nbsp; FLASH_DiagSave[0].&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am using 16MHz osc.&amp;nbsp;And FLASH_DIAG is in ROM_4000.&lt;/DIV&gt;&lt;DIV&gt;What is problem?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Apr 2008 13:52:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209971#M8680</guid>
      <dc:creator>sfb</dc:creator>
      <dc:date>2008-04-05T13:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: XDP512 Runtime flash writing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209972#M8681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;again and again and again, flash memory is not readable while it's being programmed. It's not readable and MCU is unable to read and execute program in flash from the moment you clear CBEIF bit until&amp;nbsp;CCIF is set. You should move relevant code to RAM, EEPROM, external memory etc.&lt;/DIV&gt;&lt;DIV&gt;Flash memory is also not readable during backdoor unsecure procedure and during all other flash commands, including erase verify (blank check)&amp;nbsp;and compress (checksum) commands.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;BTW this is wrong:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FCLKDIV_PRDIV8 = 1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FCLKDIV_FDIV = 10;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;above won't work in normal mode since FCLKDIV is write once register in normal mode.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Apr 2008 17:03:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209972#M8681</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2008-04-05T17:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: XDP512 Runtime flash writing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209973#M8682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Doesn't the XDP512 have multiple flash blocks (hmm. quite sure this is not the right term :smileyhappy: ) that can be programmed independently? But the code looks like it would only use the last one, which contains all the unbanked flash so this setup does not work.&lt;BR /&gt;But by moving the write code into another block, or probably better, the stored data, the copy to ram step would not be necessary.&lt;BR /&gt;Also to consider are interrupts which must not access the block being programmed either and possibly runtime routines used for the C code (I doubt that the given version uses any though).&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Apr 2008 01:03:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209973#M8682</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-04-06T01:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: XDP512 Runtime flash writing</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209974#M8683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;You can have code in another bank of Flash memory erase and program a different Flash memory bank. You just need to be careful that you don't step outside of the address range of the bank you're programming. This technique only works for MCUs with two of more banks of Flash, so it won't work on all MCUs. Executing the Flash programming code from RAM will work across all processors, which is why folks keep emphasizing the technique. However, if allyou're using is this specific MCU then the program-from-another-Flash-bank technique will work. More information on the subject can be found on this &lt;A href="http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&amp;amp;message.id=302&amp;amp;query.id=108904#M302" target="_blank"&gt;thread&lt;/A&gt;.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Apr 2008 20:52:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/XDP512-Runtime-flash-writing/m-p/209974#M8683</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2008-04-07T20:52:58Z</dc:date>
    </item>
  </channel>
</rss>

