<?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: EEPROM setup MC9S12DP512 in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196332#M7269</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tend to use an union for this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;union un_long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; long l;&lt;BR /&gt;&amp;nbsp; word w[2];&lt;BR /&gt;&amp;nbsp; int i[2];&lt;BR /&gt;&amp;nbsp; byte b[4];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;};&lt;BR /&gt;union un_Long&amp;nbsp; Value;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and reference the value by&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value.L = 232085308;&lt;/P&gt;&lt;P&gt;&amp;nbsp; and thus can do this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; T = Value.W[0];&lt;/P&gt;&lt;P&gt;&amp;nbsp; T = value.W[1];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;faster code.&amp;nbsp; Simpler to understand and access the variable as needed - - as byte, int or long.&lt;/P&gt;&lt;P&gt;note Word is defined as unsigned Int&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>Sat, 16 Apr 2011 05:44:08 GMT</pubDate>
    <dc:creator>Jim_P</dc:creator>
    <dc:date>2011-04-16T05:44:08Z</dc:date>
    <item>
      <title>EEPROM setup MC9S12DP512</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196328#M7265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI, i am still new to freescale product and codewarrior.&lt;/P&gt;&lt;P&gt;I am trying to setup EEPROM, writing 32 bit data to EEPROM.&lt;/P&gt;&lt;P&gt;So far, i know the EEPROM can only consits of 16 bit of data so in order to write&lt;/P&gt;&lt;P&gt;32 biy of data, i need to write modify sector twice. But i do not know how to separate&lt;/P&gt;&lt;P&gt;the bit into two 16 bit data. I'm thinking the function will look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BOOL EEPROM_Write32(UINT32 volatile * const address, const UINT32 data)&lt;/P&gt;&lt;P&gt;*address = data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, if anyone can tell me how to separate the 32 bit into two 16 bit data, it would be great.&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Apr 2011 12:10:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196328#M7265</guid>
      <dc:creator>Leinad</dc:creator>
      <dc:date>2011-04-03T12:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: EEPROM setup MC9S12DP512</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196329#M7266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;long data;&lt;/P&gt;&lt;P&gt;unsigned short hiword, loword;&lt;/P&gt;&lt;P&gt;long *address;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; hiword =&amp;nbsp;data / 0x10000ul;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; loword = data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ((short*)address)[0] = hiword;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ((short*)address)[1] = loword;&lt;/P&gt;&lt;P&gt;--------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To update whole sector you need not two sector modify commands, but one sector modify&amp;nbsp;and one word program. Sector modify erases whole 2-words sector and updates one word.&lt;/P&gt;&lt;P&gt;Don't forget to word&amp;nbsp;align your data in EEPROM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Apr 2011 14:02:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196329#M7266</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-04-03T14:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: EEPROM setup MC9S12DP512</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196330#M7267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i tried it but the compiler gave me a warning&lt;/P&gt;&lt;P&gt;"possible loss of data" in this row:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataLo = data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect this is cus data is long and dataLo is short;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do you do the word alignment?&lt;/P&gt;&lt;P&gt;i've read some guides from here but still don understand&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/files/microcontrollers/doc/app_note/AN2400.pdf" rel="nofollow" target="_blank"&gt;http://www.freescale.com/files/microcontrollers/doc/app_note/AN2400.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data / 0x10000ul; what does this line do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Apr 2011 07:27:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196330#M7267</guid>
      <dc:creator>Leinad</dc:creator>
      <dc:date>2011-04-04T07:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: EEPROM setup MC9S12DP512</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196331#M7268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DP12 eeprom has an erase size of 4 bytes, and a write size of 2 bytes. This means that you have to erase a whole 4 bytes before writing, but once that is done you can write to the upper 2 and lower 2 bytes separately. This will not lead to the same sector getting written to twice. It is of course easiest to erase 4 and then write 4 at the same time, however.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Possible loss of data" in Codewarrior means nothing, that warning is completely broken and irrational, as discussed plenty elsewhere on these forums. I consider it a compiler bug, you should disable it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Word alignment you do manually. Each sector has to start at an address which is an even multiple of 4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; data / 0x10000ul; what does this line do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apparently it divides data by 0x10000 or 65536 dec. The purpose is to mask out the hiword from the long. It does look odd however... on a dumb compiler, that line will be evaluated to division, making it needlessly ineffective.&lt;/P&gt;&lt;P&gt;An alternative would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hiword = (uint16_t) (data &amp;gt;&amp;gt; 16)&lt;/P&gt;&lt;P&gt;loword = (uint16_t) data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Apr 2011 13:44:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196331#M7268</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2011-04-04T13:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: EEPROM setup MC9S12DP512</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196332#M7269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tend to use an union for this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;union un_long&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; long l;&lt;BR /&gt;&amp;nbsp; word w[2];&lt;BR /&gt;&amp;nbsp; int i[2];&lt;BR /&gt;&amp;nbsp; byte b[4];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;};&lt;BR /&gt;union un_Long&amp;nbsp; Value;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and reference the value by&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Value.L = 232085308;&lt;/P&gt;&lt;P&gt;&amp;nbsp; and thus can do this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; T = Value.W[0];&lt;/P&gt;&lt;P&gt;&amp;nbsp; T = value.W[1];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;faster code.&amp;nbsp; Simpler to understand and access the variable as needed - - as byte, int or long.&lt;/P&gt;&lt;P&gt;note Word is defined as unsigned Int&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>Sat, 16 Apr 2011 05:44:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/EEPROM-setup-MC9S12DP512/m-p/196332#M7269</guid>
      <dc:creator>Jim_P</dc:creator>
      <dc:date>2011-04-16T05:44:08Z</dc:date>
    </item>
  </channel>
</rss>

