<?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: Programming Flash, FADDR in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208370#M8534</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;i made those changes. still a no go. results are the same. EE that are already erased, I can write fine. EE that aren't, i get jibberish. The resulting values are neither the old nor new.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Dec 2008 04:38:45 GMT</pubDate>
    <dc:creator>HenryL</dc:creator>
    <dc:date>2008-12-17T04:38:45Z</dc:date>
    <item>
      <title>Programming Flash, FADDR - MC9S12DG256</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208362#M8526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;I'm writing a bootloader to program flash. I know the three main registries that I need are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FADDR - 16bit address of where flash data should be written to&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FDATA - 16bit data of flash&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FCMD - 8bit command to write/erase the flash&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My question is, according to the datasheet, bit 15 of FADDR is not writable, which means I can only write flash locations mapped at 0x0000 to 0x7FFF. How can I write to the rest of the memory?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using HCS12 dg256&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by Henry L on &lt;SPAN class="date_text"&gt;2008-12-08&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;06:53 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="time_text"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="time_text"&gt;Added p/n to subject.&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by NLFSJ on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2008-12-16&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;09:52 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2008 10:52:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208362#M8526</guid>
      <dc:creator>HenryL</dc:creator>
      <dc:date>2008-12-09T10:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208363#M8527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;From the docs:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Times New Roman"&gt;&lt;/FONT&gt;&lt;P align="left"&gt;&lt;FONT face="Times New Roman"&gt;&lt;STRONG&gt;In normal modes, the FADDR (FADDRHI, FADDRLO) register reads zeros and is not writable.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times New Roman"&gt;Instead of using FADDR and FDATA, as docs say, you should&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face="Times New Roman"&gt;&lt;FONT face="Times New Roman"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P align="left"&gt;&lt;FONT face="Times New Roman"&gt;&lt;FONT face="Times New Roman"&gt;&lt;STRONG&gt;...Write the aligned data word to be programmed to the valid Flash address space. The address and data will be stored in internal buffers...&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&lt;FONT face="Times New Roman"&gt;&lt;FONT face="Times New Roman"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2008 12:58:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208363#M8527</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2008-12-09T12:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208364#M8528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;so what is FADDR and FDATA used for, if anything at all?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"&lt;FONT face="Times New Roman"&gt;&lt;FONT face="Times New Roman"&gt;&lt;STRONG&gt;Write the aligned data word to be programmed to the valid Flash address space. The address and data will be stored in internal buffers..."&lt;BR /&gt;&lt;B&gt;&lt;BR /&gt;&lt;/B&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;Meaning I should do something like this?&lt;BR /&gt;unsigned int * Pointer = 0x8000;&lt;BR /&gt;*Pointer = WordOfFlashData;&lt;BR /&gt;FCMD = 0x20;&lt;BR /&gt;FSTAT |= CBEIF;&lt;BR /&gt;&lt;BR /&gt;with FADDR &amp;amp; FDATA, you had to write 2 bytes (a word) of data at a time, no more no less. Does this still hold true using this method?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And while we're on the subject, is writing to eeprom similar?&lt;STRONG&gt;&lt;/STRONG&gt;&lt;FONT face="Times New Roman"&gt;&lt;FONT face="Times New Roman"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by Henry L on &lt;SPAN class="date_text"&gt;2008-12-09&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:36 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 03:19:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208364#M8528</guid>
      <dc:creator>HenryL</dc:creator>
      <dc:date>2008-12-10T03:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208365#M8529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Henry L wrote:&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;so what is FADDR and FDATA used for, if anything at all?&lt;BR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;You can use them for example to program flash in special single chip&amp;nbsp;mode using BDM pod. You can't run in special mode without BDM.&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;"&lt;FONT face="Times New Roman"&gt;&lt;FONT face="Times New Roman"&gt;&lt;STRONG&gt;Write the aligned data word to be programmed to the valid Flash address space. The address and data will be stored in internal buffers..."&lt;BR /&gt;&lt;B&gt;&lt;BR /&gt;&lt;/B&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;Meaning I should do something like this?&lt;BR /&gt;unsigned int * Pointer = 0x8000;&lt;BR /&gt;*Pointer = WordOfFlashData;&lt;BR /&gt;FCMD = 0x20;&lt;BR /&gt;FSTAT |= CBEIF;&lt;BR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;Yes. But also keep in mind that flash and EEPROM are not readable while CCIF bit is 0. Not readable memory means also that CPU can't execute code from memory you are&amp;nbsp;programming. Also CPU can't fetch interrupt vectors from flash array being progammed / erased.&amp;nbsp;Your flash programming routines should run from RAM, EEPROM, another flash array (on D256 you have 4 flash arrays), or external memory.&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;BR /&gt;with FADDR &amp;amp; FDATA, you had to write 2 bytes (a word) of data at a time, no more no less. Does this still hold true using this method?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;You should find flash program and erase algorithms in the docs.&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And while we're on the subject, is writing to eeprom similar?&lt;STRONG&gt;&lt;/STRONG&gt;&lt;FONT face="Times New Roman"&gt;&lt;FONT face="Times New Roman"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;Yes.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2008 21:41:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208365#M8529</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2008-12-10T21:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208366#M8530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;kef wrote:&lt;BR /&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Yes. But also keep in mind that flash and EEPROM are not readable while CCIF bit is 0. Not readable memory means also that CPU can't execute code from memory you are&amp;nbsp;programming. Also CPU can't fetch interrupt vectors from flash array being progammed / erased.&amp;nbsp;Your flash programming routines should run from RAM, EEPROM, another flash array (on D256 you have 4 flash arrays), or external memory.&lt;BR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;I will running code from RAM. I'm implementing something similar to the app notes for LRAE &amp;amp; LFAE.&lt;BR /&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;You should find flash program and erase algorithms in the docs.&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;If you are referring to the FTS256K block guide, then yes, it seems that I do have to write one word at a time, allowing the CBEIF to trigger before continuing.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;Also, according to Fig4-2 of that document, after I launch the command, I should wait for CBEIF to be set before writing the next word. Should not also be waiting for CCIF for the command to complete, before writing the next word?&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2008 05:56:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208366#M8530</guid>
      <dc:creator>HenryL</dc:creator>
      <dc:date>2008-12-11T05:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208367#M8531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;Henry L wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;Also, according to Fig4-2 of that document, after I launch the command, I should wait for CBEIF to be set before writing the next word. Should not also be waiting for CCIF for the command to complete, before writing the next word?&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;While programming many words, you don't have&amp;nbsp;to wait for CCIF==1. But flash is not readable while FSTAT CCIF==0. So for example&amp;nbsp;you can't&amp;nbsp;verify what you programmed until CCIF==1.&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2008 13:00:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208367#M8531</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2008-12-11T13:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208368#M8532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;kef,&lt;BR /&gt;&lt;BR /&gt;i must kindly ask for your help again. I have been succesful at writing to flash. However, I am now having trouble writing to eeprom.&lt;BR /&gt;&lt;BR /&gt;the following is my code:&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;char FchrEepromWrite (unsigned char *PAuchrCanData){ unsigned char LuchrBankNum = 0; unsigned char LuchrReturn = 0; unsigned char LuchrIndex = 0; unsigned char LuchrDone = 0; int * LptrWriteAddr; //initialize commands //clear errors if (ESTAT &amp;amp; (PVIOL | ACCERR))  ESTAT |= (PVIOL | ACCERR);   //wait for cmd registries to be empty and ready to take new cmds while(!(ESTAT &amp;amp; CBEIF)); while(!LuchrDone) {  switch(LuchrIndex)  {  case 0:   LptrWriteAddr = (int *)((PAuchrCanData[1] &amp;lt;&amp;lt; 8) | PAuchrCanData[2]);   ECMD = defEeCmdSectErase;   break;  case 1:   LptrWriteAddr = (int *)((PAuchrCanData[1] &amp;lt;&amp;lt; 8) | PAuchrCanData[2]);   *LptrWriteAddr = (PAuchrCanData[3] &amp;lt;&amp;lt; 8) | PAuchrCanData[4];   ECMD = defEeCmdProgram;   break;  case 2:   LptrWriteAddr = (int *)(((PAuchrCanData[1] &amp;lt;&amp;lt; 8) | PAuchrCanData[2]) + 2);   *LptrWriteAddr = (PAuchrCanData[5] &amp;lt;&amp;lt; 8) | PAuchrCanData[6];   ECMD = defEeCmdProgram;   break;  }  ESTAT |= CBEIF;  if (ESTAT &amp;amp; PVIOL)  {   ESTAT |= PVIOL;   LuchrDone = 1;  }  else if (ESTAT &amp;amp; ACCERR)  {   ESTAT |= ACCERR;   LuchrDone = 1;  }  else  {   while (!(ESTAT &amp;amp; CBEIF));   while (!(ESTAT &amp;amp; CCIF));   LuchrIndex++;   if (LuchrIndex &amp;gt; 2)   {    LuchrDone = 1;    LuchrReturn = 1;   }  } } return LuchrReturn;}
&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;I am communicating via CAN. The 8 bytes of CAN data gets passed into this function, where bytes 1&amp;amp;2 form the addr of the EE, and bytes 3,4,5&amp;amp;6 form are the data. This function is a three step process. First I erase the 2 word (4 byte) sector. Then I write the two words in one at a time. However, it is not working. For sectors that are already erased (ie 0xFFFF) it works, but sectors that aren't, results are unpredictable. Am I not erasing properly? I made sure the address I'm specifying is aligned correctly.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by Henry L on &lt;SPAN class="date_text"&gt;2008-12-15&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;07:29 PM&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by Henry L on &lt;SPAN class="date_text"&gt;2008-12-15&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;07:32 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 11:20:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208368#M8532</guid>
      <dc:creator>HenryL</dc:creator>
      <dc:date>2008-12-16T11:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208369#M8533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I see that you are clearing ESTAT flags wrong way, but I'm not sure if this is what&amp;nbsp;makes your code not working. My advice is first fix these bugs, then let us know if it fixes problems or not. What's wrong with flags:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;When you do&amp;nbsp;&amp;nbsp; ESTAT |= (PVIOL | ACCERR);&amp;nbsp; , you write ones not only to PVIOL and ACCERR, but also to CBEIF, because CBEIF is most probably set already.&amp;nbsp;Actually you want to clear error flags, but in reality you are trying to start some EEPROM command. I hope you understand that. Either do&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;ESTAT = PVIOL | ACCERR;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;or&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;ESTAT &amp;amp;= PVIOL | ACCERR;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Please fix marked lines&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;char FchrEepromWrite (unsigned char *PAuchrCanData){ unsigned char LuchrBankNum = 0; unsigned char LuchrReturn = 0; unsigned char LuchrIndex = 0; unsigned char LuchrDone = 0; int * LptrWriteAddr; //initialize commands //clear errors if (ESTAT &amp;amp; (PVIOL | ACCERR))&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt; ESTAT |= (PVIOL | ACCERR);&lt;/STRONG&gt;&lt;/FONT&gt;   //wait for cmd registries to be empty and ready to take new cmds while(!(ESTAT &amp;amp; CBEIF)); while(!LuchrDone) {  switch(LuchrIndex)  {  case 0:   LptrWriteAddr = (int *)((PAuchrCanData[1] &amp;lt;&amp;lt; 8) | PAuchrCanData[2]);   ECMD = defEeCmdSectErase;   break;  case 1:   LptrWriteAddr = (int *)((PAuchrCanData[1] &amp;lt;&amp;lt; 8) | PAuchrCanData[2]);   *LptrWriteAddr = (PAuchrCanData[3] &amp;lt;&amp;lt; 8) | PAuchrCanData[4];   ECMD = defEeCmdProgram;   break;  case 2:   LptrWriteAddr = (int *)(((PAuchrCanData[1] &amp;lt;&amp;lt; 8) | PAuchrCanData[2]) + 2);   *LptrWriteAddr = (PAuchrCanData[5] &amp;lt;&amp;lt; 8) | PAuchrCanData[6];   ECMD = defEeCmdProgram;   break;  }&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt; ESTAT |= CBEIF;&lt;/FONT&gt;&lt;/STRONG&gt;  if (ESTAT &amp;amp; PVIOL)  {&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;  ESTAT |= PVIOL;&lt;/FONT&gt;&lt;/STRONG&gt;   LuchrDone = 1;  }  else if (ESTAT &amp;amp; ACCERR)  {&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;  ESTAT |= ACCERR;&lt;/FONT&gt;&lt;/STRONG&gt;   LuchrDone = 1;  }  else  {   while (!(ESTAT &amp;amp; CBEIF));   while (!(ESTAT &amp;amp; CCIF));   LuchrIndex++;   if (LuchrIndex &amp;gt; 2)   {    LuchrDone = 1;    LuchrReturn = 1;   }  } } return LuchrReturn;}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by kef on &lt;SPAN class="date_text"&gt;2008-12-16&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;09:29 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2008 15:23:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208369#M8533</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2008-12-16T15:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208370#M8534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;i made those changes. still a no go. results are the same. EE that are already erased, I can write fine. EE that aren't, i get jibberish. The resulting values are neither the old nor new.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2008 04:38:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208370#M8534</guid>
      <dc:creator>HenryL</dc:creator>
      <dc:date>2008-12-17T04:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash, FADDR</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208371#M8535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;update:&lt;BR /&gt;got it working! turns out that when I erase, not only do i need to assign an address to my variable LptrWriteAddr, I also have to assign data to it. My guess is that that's how the micro/compiler knows to put it in the cmd buffer eventhough data is not used on an erase command. So all i did was add one more line to my erase case.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;case 0:
 LptrWriteAddr = (int *)((PAuchrCanData[1] &amp;lt;&amp;lt; 8) | PAuchrCanData[2]);
 &lt;FONT color="#ff0000"&gt;*LptrWriteAddr = 0;
&lt;/FONT&gt; ECMD = defEeCmdSectErase;
 break;&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by Henry L on &lt;SPAN class="date_text"&gt;2008-12-16&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;01:33 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2008 05:32:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Programming-Flash-FADDR-MC9S12DG256/m-p/208371#M8535</guid>
      <dc:creator>HenryL</dc:creator>
      <dc:date>2008-12-17T05:32:42Z</dc:date>
    </item>
  </channel>
</rss>

