<?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: ram assy emulation code to page erase byte write flash in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ram-assy-emulation-code-to-page-erase-byte-write-flash/m-p/131645#M2810</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;sometimes these forums can be more or less useful but it really depends on the attitude of all of us.&lt;BR /&gt;&lt;BR /&gt;reference: mc9s08rd32dwe processor CodeWarrior hc(s)08 3.1&lt;BR /&gt;&lt;BR /&gt;anyway(s) flash page erase byte write problemo resolved. basically assembly code interface had two errors, well lets say three.&lt;BR /&gt;-the assembly code required an unsigned int of address and a Byte of data to be written to and the c language program was writting this data to the wrong address&lt;BR /&gt;-some interrupt, possibly due to my dwn rev version of CW, seemed to over wite the data even if it were written to the correct locations.&lt;BR /&gt;-no documentation, especially the assembly code. the stuff i saw looked very odd, tho i am sure it was working when submitted. i actuall saw somethig like this:&lt;BR /&gt;((unsigned char (*) (int, unsigned char))(Ram_Routine)))&lt;BR /&gt;&lt;BR /&gt;//the assembly routine express as a initilized array, not the lack of any comments except the address locations address 1 = (unsigned int)address address2 = (Byte)data&lt;BR /&gt;#pragma DATA_SEG _RAMROUTINE. Note here because something was over writting address 1&amp;amp;2 i moved these to the end of the array, see locations three locations 0x00,0x00,0x00. by the way Ram_Routine[] was linker located top of ram in the *.prn file. so note address 1&amp;amp;2 address&amp;amp;data are set to 0x0843 and 0x0845 and 0x845 is the last byte of ram.&lt;BR /&gt;unsigned char [] = {&lt;BR /&gt;0xc6,0x18,0x25,0xa5,0x10,0x27,0x07,0x45,0x18,&lt;BR /&gt;//address 1 //address 2&lt;BR /&gt;0x25,0xf6,0xaa,0x10,0xf7,0x32,0x08,0x43,0xc6,0x08,0x45,&lt;BR /&gt;0xf7,0xa6,0x40,0x45,0x18,0x25,0xe7,0x01,0xf6,0xaa,0x80,&lt;BR /&gt;0xf7,0x9d,0x9d,0x9d,0x9d,0xc6,0x18,0x25,0xc6,0x18,0x25,&lt;BR /&gt;0xa5,0x40,0x27,0xf9,0x81,0x00,0x00,0x00};&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;BR /&gt;&lt;BR /&gt;//usage of the above assembly code is at 2 levels, a C language interface and code in main.c&lt;BR /&gt;//C language interafce&lt;BR /&gt;//*************&amp;gt;&amp;gt;&amp;gt; erase Flash page at the the given address ********&lt;BR /&gt;void Flash_Erase (unsigned int FlashAddress){&lt;BR /&gt;*(unsigned int*)0x843 = 0xE001; //test code i elected to set address immediate because&lt;BR /&gt;*(Byte*)0x845 = 0x55; //of the over write problem.&lt;BR /&gt;Ram_Routine[22] = 0x40;//flash command&lt;BR /&gt;_asm jsr Ram_Routine;}&lt;BR /&gt;//*******&amp;gt;&amp;gt;&amp;gt; stores a byte of data onto the Flash at the given address ******&lt;BR /&gt;void Flash_Program(Byte data){&lt;BR /&gt;*(Byte*)0x845=data;&lt;BR /&gt;Ram_Routine[22] = 0x20;&lt;BR /&gt;_asm jsr Ram_Routine;}&lt;BR /&gt;//************************&lt;BR /&gt;&lt;BR /&gt;//main.c calles everything like this:&lt;BR /&gt;Flash_Erase ((unsigned int)0xE001) //must page erase first&lt;BR /&gt;*(unsigned int*)0x843=0xE001; //now able to write once to any byte in page&lt;BR /&gt;Flash_Program((Byte)0xCD);&lt;BR /&gt;&lt;BR /&gt;//linker command file settings, see the section RAMROUTINE&lt;BR /&gt;SEGMENTS&lt;BR /&gt;Z_RAM = READ_WRITE 0x0046 TO 0x00FF;&lt;BR /&gt;RAM = READ_WRITE 0x0100 TO 0x04FF;&lt;BR /&gt;PATCH_RAM = READ_WRITE 0x0500 TO 0x06FF;&lt;BR /&gt;XBITTOGGLE= NO_INIT 0x07C8 TO 0x07CF;&lt;BR /&gt;TEMP = NO_INIT 0x07D0 TO 0x07DF;&lt;BR /&gt;FLASHVAR = NO_INIT 0x07E0 TO 0x07E9;&lt;BR /&gt;RAM2 = READ_WRITE 0x07EA TO 0x0816;&lt;BR /&gt;RAMROUTINE= READ_WRITE 0x0814 TO 0x0845;&lt;BR /&gt;PLACEMENT&lt;BR /&gt;DEFAULT_ROM INTO ROM;&lt;BR /&gt;DEFAULT_RAM INTO RAM, RAM2;&lt;BR /&gt;_PATCH_RAM INTO PATCH_RAM;&lt;BR /&gt;_FLASHSECURITY INTO NV_REG;&lt;BR /&gt;_ROM_VARIABLES INTO MYROM;&lt;BR /&gt;_TABLE INTO KBTABLE;&lt;BR /&gt;_FLASHVARS INTO FLASHVAR;&lt;BR /&gt;_RAMROUTINE INTO RAMROUTINE;&lt;BR /&gt;_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;&lt;BR /&gt;_TV_TABLE INTO TV_DATA;&lt;BR /&gt;_TEMP INTO TEMP;&lt;BR /&gt;_XBITTOGGLE INTO XBITTOGGLE;&lt;BR /&gt;END&lt;P&gt;Message Edited by jah on &lt;SPAN class="date_text"&gt;2006-09-29&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;10:36 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Sep 2006 22:34:03 GMT</pubDate>
    <dc:creator>jah</dc:creator>
    <dc:date>2006-09-29T22:34:03Z</dc:date>
    <item>
      <title>ram assy emulation code to page erase byte write flash</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ram-assy-emulation-code-to-page-erase-byte-write-flash/m-p/131643#M2808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;does anyone have one for the mc9s08rd32dwe&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i know people are doing this, what code is working for them, chime in please&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i looked at a few but most of them are w/o documentation&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-where is the flash command loaded&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-the varriable to page erase and or write flash byte&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-the data to be written to flash is declared where what&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i tried this code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#pragma DATA_SEG _RAMROUTINE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unsigned char Ram_Routine[] = {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0xc6,0x18,0x25,0xa5,0x10,0x27,0x07,0x45,0x18,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//address 1 //address 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x25,0xf6,0xaa,0x10,0xf7,0x32,0x06,0xA0,0xc6,0x06,0xA2,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0xf7,0xa6,0x40,0x45,0x18,0x25,0xe7,0x01,0xf6,0xaa,0x80,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0xf7,0x9d,0x9d,0x9d,0x9d,0xc6,0x18,0x25,0xc6,0x18,0x25,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0xa5,0x40,0x27,0xf9,0x81};&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#pragma DATA_SEG DEFAULT&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#pragma DATA_SEG _FLASHVARS&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unsigned int FixedAddres; //by the code this seems to it should be 0x60 abouts&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;unsigned char DataToWrite;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#pragma DATA_SEG DEFAULT&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//this is how the above is used:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//looking through my example DataToWrite is at 0x7e2 and FixedAddres at 0x7E0, but //looking at teh Ram_Routine code i think its 0x6e2 and 0x6e0. in most of the ram&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//based flash erase write code not alot of documentation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void Flash_Program(Byte data){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DataToWrite = data;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ram_Routine[22] = 0x20;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;__asm jsr Ram_Routine;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 06:16:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ram-assy-emulation-code-to-page-erase-byte-write-flash/m-p/131643#M2808</guid>
      <dc:creator>jah</dc:creator>
      <dc:date>2006-09-28T06:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: ram assy emulation code to page erase byte write flash</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ram-assy-emulation-code-to-page-erase-byte-write-flash/m-p/131644#M2809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Try searching for flash programming in these forums. The topic has been discussed repeatedly. Also, check out the Flash Programming FAQ, reference # 26240, in the Freescale FAQ system. It's the mother of all Flash programming documents, and has pointers to a variety of application notes on Flash programming. Many of the referenced notes have example code.&lt;BR /&gt;&lt;BR /&gt;---Tom&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 22:15:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ram-assy-emulation-code-to-page-erase-byte-write-flash/m-p/131644#M2809</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2006-09-28T22:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: ram assy emulation code to page erase byte write flash</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/ram-assy-emulation-code-to-page-erase-byte-write-flash/m-p/131645#M2810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;sometimes these forums can be more or less useful but it really depends on the attitude of all of us.&lt;BR /&gt;&lt;BR /&gt;reference: mc9s08rd32dwe processor CodeWarrior hc(s)08 3.1&lt;BR /&gt;&lt;BR /&gt;anyway(s) flash page erase byte write problemo resolved. basically assembly code interface had two errors, well lets say three.&lt;BR /&gt;-the assembly code required an unsigned int of address and a Byte of data to be written to and the c language program was writting this data to the wrong address&lt;BR /&gt;-some interrupt, possibly due to my dwn rev version of CW, seemed to over wite the data even if it were written to the correct locations.&lt;BR /&gt;-no documentation, especially the assembly code. the stuff i saw looked very odd, tho i am sure it was working when submitted. i actuall saw somethig like this:&lt;BR /&gt;((unsigned char (*) (int, unsigned char))(Ram_Routine)))&lt;BR /&gt;&lt;BR /&gt;//the assembly routine express as a initilized array, not the lack of any comments except the address locations address 1 = (unsigned int)address address2 = (Byte)data&lt;BR /&gt;#pragma DATA_SEG _RAMROUTINE. Note here because something was over writting address 1&amp;amp;2 i moved these to the end of the array, see locations three locations 0x00,0x00,0x00. by the way Ram_Routine[] was linker located top of ram in the *.prn file. so note address 1&amp;amp;2 address&amp;amp;data are set to 0x0843 and 0x0845 and 0x845 is the last byte of ram.&lt;BR /&gt;unsigned char [] = {&lt;BR /&gt;0xc6,0x18,0x25,0xa5,0x10,0x27,0x07,0x45,0x18,&lt;BR /&gt;//address 1 //address 2&lt;BR /&gt;0x25,0xf6,0xaa,0x10,0xf7,0x32,0x08,0x43,0xc6,0x08,0x45,&lt;BR /&gt;0xf7,0xa6,0x40,0x45,0x18,0x25,0xe7,0x01,0xf6,0xaa,0x80,&lt;BR /&gt;0xf7,0x9d,0x9d,0x9d,0x9d,0xc6,0x18,0x25,0xc6,0x18,0x25,&lt;BR /&gt;0xa5,0x40,0x27,0xf9,0x81,0x00,0x00,0x00};&lt;BR /&gt;#pragma DATA_SEG DEFAULT&lt;BR /&gt;&lt;BR /&gt;//usage of the above assembly code is at 2 levels, a C language interface and code in main.c&lt;BR /&gt;//C language interafce&lt;BR /&gt;//*************&amp;gt;&amp;gt;&amp;gt; erase Flash page at the the given address ********&lt;BR /&gt;void Flash_Erase (unsigned int FlashAddress){&lt;BR /&gt;*(unsigned int*)0x843 = 0xE001; //test code i elected to set address immediate because&lt;BR /&gt;*(Byte*)0x845 = 0x55; //of the over write problem.&lt;BR /&gt;Ram_Routine[22] = 0x40;//flash command&lt;BR /&gt;_asm jsr Ram_Routine;}&lt;BR /&gt;//*******&amp;gt;&amp;gt;&amp;gt; stores a byte of data onto the Flash at the given address ******&lt;BR /&gt;void Flash_Program(Byte data){&lt;BR /&gt;*(Byte*)0x845=data;&lt;BR /&gt;Ram_Routine[22] = 0x20;&lt;BR /&gt;_asm jsr Ram_Routine;}&lt;BR /&gt;//************************&lt;BR /&gt;&lt;BR /&gt;//main.c calles everything like this:&lt;BR /&gt;Flash_Erase ((unsigned int)0xE001) //must page erase first&lt;BR /&gt;*(unsigned int*)0x843=0xE001; //now able to write once to any byte in page&lt;BR /&gt;Flash_Program((Byte)0xCD);&lt;BR /&gt;&lt;BR /&gt;//linker command file settings, see the section RAMROUTINE&lt;BR /&gt;SEGMENTS&lt;BR /&gt;Z_RAM = READ_WRITE 0x0046 TO 0x00FF;&lt;BR /&gt;RAM = READ_WRITE 0x0100 TO 0x04FF;&lt;BR /&gt;PATCH_RAM = READ_WRITE 0x0500 TO 0x06FF;&lt;BR /&gt;XBITTOGGLE= NO_INIT 0x07C8 TO 0x07CF;&lt;BR /&gt;TEMP = NO_INIT 0x07D0 TO 0x07DF;&lt;BR /&gt;FLASHVAR = NO_INIT 0x07E0 TO 0x07E9;&lt;BR /&gt;RAM2 = READ_WRITE 0x07EA TO 0x0816;&lt;BR /&gt;RAMROUTINE= READ_WRITE 0x0814 TO 0x0845;&lt;BR /&gt;PLACEMENT&lt;BR /&gt;DEFAULT_ROM INTO ROM;&lt;BR /&gt;DEFAULT_RAM INTO RAM, RAM2;&lt;BR /&gt;_PATCH_RAM INTO PATCH_RAM;&lt;BR /&gt;_FLASHSECURITY INTO NV_REG;&lt;BR /&gt;_ROM_VARIABLES INTO MYROM;&lt;BR /&gt;_TABLE INTO KBTABLE;&lt;BR /&gt;_FLASHVARS INTO FLASHVAR;&lt;BR /&gt;_RAMROUTINE INTO RAMROUTINE;&lt;BR /&gt;_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;&lt;BR /&gt;_TV_TABLE INTO TV_DATA;&lt;BR /&gt;_TEMP INTO TEMP;&lt;BR /&gt;_XBITTOGGLE INTO XBITTOGGLE;&lt;BR /&gt;END&lt;P&gt;Message Edited by jah on &lt;SPAN class="date_text"&gt;2006-09-29&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;10:36 AM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Sep 2006 22:34:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/ram-assy-emulation-code-to-page-erase-byte-write-flash/m-p/131645#M2810</guid>
      <dc:creator>jah</dc:creator>
      <dc:date>2006-09-29T22:34:03Z</dc:date>
    </item>
  </channel>
</rss>

