<?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>topic Re: S12X Flash write access in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185544#M6990</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm running on S12XD right now because I only have such a hardware. Later in the project we'll change to S12XE. That means I have to chage my flash routines again right? :smileywink:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem of the flash write access in continues mode was no code&amp;nbsp;problem. It was a problem of the debugger not refreshed the memory data properly. :smileysad:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; FSTAT_CBEIF = 1;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; ^^ it shouldn't cause your&lt;/P&gt;&lt;P&gt;&amp;gt; problem, but this code is&lt;/P&gt;&lt;P&gt;&amp;gt; clearing not just CBEIF,&lt;/P&gt;&lt;P&gt;&amp;gt; but also all other FSTAT&lt;/P&gt;&lt;P&gt;&amp;gt; flags. You know it, right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand...what I have to change...?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Dec 2011 15:09:40 GMT</pubDate>
    <dc:creator>mark99</dc:creator>
    <dc:date>2011-12-07T15:09:40Z</dc:date>
    <item>
      <title>S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185536#M6982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I implemented the flash routines for the S12 and it works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have a new project with&amp;nbsp;HCS12XEP and have to adapt the flash routines. Is it correct that I can write to a flash&amp;nbsp;block while code fetching from a different flash block? Or is it the same like S12 (flash routines in RAM and no IRQ while flash access)?&amp;nbsp;I didn't find an answer in the datasheet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Nov 2011 18:33:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185536#M6982</guid>
      <dc:creator>mark99</dc:creator>
      <dc:date>2011-11-23T18:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185537#M6983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;...I did find out it myself: It is possible to read from a Flash block while a command is executing on a different Flash block. &lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Nov 2011 16:27:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185537#M6983</guid>
      <dc:creator>mark99</dc:creator>
      <dc:date>2011-11-24T16:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185538#M6984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you should disable interrupts and run code from memory, which is readable and not from which you are&amp;nbsp;erasing/programming.&amp;nbsp;Those MCU's, which don't require&amp;nbsp;disable of &amp;nbsp;interrupts or running from RAM, have CPU halted&amp;nbsp;while flash is being erased or programmed. Yes, you may run from one flash block (block is not the same like page), while other is being programmed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Nov 2011 16:34:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185538#M6984</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-11-24T16:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185539#M6985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an other question: I'm trying to write to Flash page E0. What I have to define in prm?&lt;/P&gt;&lt;P&gt;NO_INIT?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.prm:&lt;/P&gt;&lt;P&gt;SEGMENTS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PAGE_E0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = NO_INIT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATA_FAR IBCC_FAR&amp;nbsp; 0xE08000 TO 0xE0BFFF;&lt;/P&gt;&lt;P&gt;:&lt;/P&gt;&lt;P&gt;PLACEMENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NON_VOLATILE_STORAGE&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp; PAGE_E0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Flash.c:&lt;/P&gt;&lt;P&gt;#pragma &lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;CONST_SEG NON_VOLATILE_STORAGE&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;const c&lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;har __far non_volatile_data[] = { 0xFFFF };&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;#pragma &lt;FONT face="Consolas" size="2"&gt;&lt;FONT face="Consolas" size="2"&gt;CONST_SEG DEFAULT&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Nov 2011 21:37:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185539#M6985</guid>
      <dc:creator>mark99</dc:creator>
      <dc:date>2011-11-25T21:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185540#M6986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Either NO_INIT or READ_ONLY.&amp;nbsp;READ_ONLY for&amp;nbsp;settings defined in your code, and implicit zeros for not initialized settings. NO_INIT for not initialized data.&lt;/P&gt;&lt;P&gt;I'm using NO_INIT, because READ_ONLY makes all data reset with data from S-records file, when upgrading firmware using bootloader. I think that&amp;nbsp;old settings should survive firmware upgrade.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Nov 2011 22:29:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185540#M6986</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-11-25T22:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185541#M6987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually have a very strange problem. If I run my flash write routine in debug mode (single step), it works. In normal mode (continue) the write access fails with ACCERR=1. Seems I have to look for the error for a while...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Nov 2011 22:53:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185541#M6987</guid>
      <dc:creator>mark99</dc:creator>
      <dc:date>2011-11-25T22:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185542#M6988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That code (HCS12XDP512)&amp;nbsp;runs in debug mode (single step) fine&amp;nbsp;but not in contiues mode. Any idea where the error could be? Thanks a lot!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG .data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;static void LaunchCommand(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // launch flash command&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FSTAT_CBEIF = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // wait for command completion &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } while (!FSTAT_CCIF);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG NON_BANKED&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UInt16 *pDestination = (UInt16 *)0x8000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PPAGE = 0xE0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FSTAT = 0x32;&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;&amp;nbsp; // clear error flags&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *pDestination = *pSource;&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; // write data to address &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FCMD = 0x20;&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;&amp;nbsp;&amp;nbsp; // program command &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __asm SEI;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // disable interrupts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LaunchCommand();&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; // call routine in RAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __asm CLI;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enable interrupts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pSource++; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDestination++; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma CODE_SEG DEFAULT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 Nov 2011 16:46:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185542#M6988</guid>
      <dc:creator>mark99</dc:creator>
      <dc:date>2011-11-27T16:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185543#M6989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hm, should work. But are you running it really on S12XD and not on S12XE?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FSTAT_CBEIF = 1;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;^^ it shouldn't cause your problem, but this code is clearing not just CBEIF, but also all other FSTAT flags. You know it, right?&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, 29 Nov 2011 19:03:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185543#M6989</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-11-29T19:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185544#M6990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm running on S12XD right now because I only have such a hardware. Later in the project we'll change to S12XE. That means I have to chage my flash routines again right? :smileywink:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem of the flash write access in continues mode was no code&amp;nbsp;problem. It was a problem of the debugger not refreshed the memory data properly. :smileysad:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; FSTAT_CBEIF = 1;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; ^^ it shouldn't cause your&lt;/P&gt;&lt;P&gt;&amp;gt; problem, but this code is&lt;/P&gt;&lt;P&gt;&amp;gt; clearing not just CBEIF,&lt;/P&gt;&lt;P&gt;&amp;gt; but also all other FSTAT&lt;/P&gt;&lt;P&gt;&amp;gt; flags. You know it, right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand...what I have to change...?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 15:09:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185544#M6990</guid>
      <dc:creator>mark99</dc:creator>
      <dc:date>2011-12-07T15:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185545#M6991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;P&gt;Right, S12XE has different type of flash and requires different program/erase routines. But this doesn't happen too often. From ancient HC12 until now this is only 4th or so version of flash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding debugger. It doesn't update read only memories, unless you edit memory mapping in debugger to refresh memory when halting. See in P&amp;amp;E Multilnk menu in debugger.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; FSTAT_CBEIF = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok. Let consider more dangerous line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; FSTAT_PVIOL = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looks like innocent attempt to clear PVIOL flag. But in fact this is an attempt to clear all FSTAT flags, including CBEIF! You are launching flash command here. Don't you see how? The answer is in how C bitfields (see how FSTAT_PVIOL is defined in headers) are working. PVIOL bit like other bitfields members not addresseable. You can address only whole bytes, belonging to bitfield struct. So how you or compiler can change just one bit? Only reading whole byte, manipulating read bit pattern, then writing resulting bitpattern back to byte in memory. This is exactly what happens in our example. FSTAT is read with PVIOL set or not, but with CBEIF most likely set. Whatever you do to PVIOL bit in read bit pattern, all other bits are preserved, including CBEIF=1. So you get a write of one to CBEIF, which is an attempt to launch flash command. :smileyhappy:&lt;/P&gt;&lt;P&gt;What to do? Don't use bitfields with flags. Below red lines are wrong. Use green lines&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;FSTAT&amp;nbsp;&amp;nbsp; |= FSTAT_PVIOL_MASK;&amp;nbsp; // clears all FSTAT flags&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;FSTAT&amp;nbsp;&amp;nbsp; &amp;amp;= ~FSTAT_PVIOL_MASK; // clears all FSTAT flags except PVIOL&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;FSTAT_PVIOL = 1; // clears all FSTAT flags&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;FSTAT_PVIOL = 0; // clears all FSTAT flags except PVIOL﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;FSTAT&amp;nbsp;&amp;nbsp; =&amp;nbsp; FSTAT_PVIOL_MASK;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;FSTAT&amp;nbsp; &amp;amp;= FSTAT_PVIOL_MASK; // note no ~&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 15:46:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185545#M6991</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-12-07T15:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: S12X Flash write access</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185546#M6992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; FSTAT_PVIOL = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ups, yes I understand the problem of this line. Thank you for you explanations!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll change&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FSTAT_CBEIF = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FSTAT = FSTAT_CBEIF_MASK;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 19:45:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/S12X-Flash-write-access/m-p/185546#M6992</guid>
      <dc:creator>mark99</dc:creator>
      <dc:date>2011-12-07T19:45:14Z</dc:date>
    </item>
  </channel>
</rss>

