<?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 EEPROM usage 9S08DZ32 for byte-wise writes in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198333#M16055</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in a software migration project 68HC05X16 to 9S08DZ32 I have to&lt;/P&gt;&lt;P&gt;implement a scheme for 'byte-wise' writes to EEPROM (as it was&lt;/P&gt;&lt;P&gt;possible with HC05, which had 256 byte of EEPROM).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;9S08DZ has 1024 bytes of EEPROM with an erase size of 8 bytes&lt;/P&gt;&lt;P&gt;at once. To write to an individual byte I first have to erase 8 bytes&lt;/P&gt;&lt;P&gt;and then restore 7 of them because only 1 byte needs to be changed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now my question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to program a (already programmed) byte without a prior&lt;/P&gt;&lt;P&gt;8-byte-erase if I only want to reduce the number of 1-bits in that byte?&lt;/P&gt;&lt;P&gt;(example of what I would like to do: after erase the byte is 0xFF, then I&lt;/P&gt;&lt;P&gt;program it with 0xC3, then I program it with 0x82h, which is a 1-&amp;gt;0 transition&lt;/P&gt;&lt;P&gt;for bit 6 and for bit 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data sheet (MC9S08DZ60 Series Rev.4, page 54) says:&lt;/P&gt;&lt;P&gt;"NOTE Before programming a particular byte in Flash or EEPROM,&lt;/P&gt;&lt;P&gt;the sector in which that particular byte resides must be erased&lt;/P&gt;&lt;P&gt;by a mass or sector erase operation"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This looks like the 1--&amp;gt;0 transition requires in all cases a&lt;/P&gt;&lt;P&gt;previous erase operation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have experience with this issue?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;-Roland&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Jul 2009 16:34:23 GMT</pubDate>
    <dc:creator>Cantalis</dc:creator>
    <dc:date>2009-07-11T16:34:23Z</dc:date>
    <item>
      <title>EEPROM usage 9S08DZ32 for byte-wise writes</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198333#M16055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in a software migration project 68HC05X16 to 9S08DZ32 I have to&lt;/P&gt;&lt;P&gt;implement a scheme for 'byte-wise' writes to EEPROM (as it was&lt;/P&gt;&lt;P&gt;possible with HC05, which had 256 byte of EEPROM).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;9S08DZ has 1024 bytes of EEPROM with an erase size of 8 bytes&lt;/P&gt;&lt;P&gt;at once. To write to an individual byte I first have to erase 8 bytes&lt;/P&gt;&lt;P&gt;and then restore 7 of them because only 1 byte needs to be changed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now my question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to program a (already programmed) byte without a prior&lt;/P&gt;&lt;P&gt;8-byte-erase if I only want to reduce the number of 1-bits in that byte?&lt;/P&gt;&lt;P&gt;(example of what I would like to do: after erase the byte is 0xFF, then I&lt;/P&gt;&lt;P&gt;program it with 0xC3, then I program it with 0x82h, which is a 1-&amp;gt;0 transition&lt;/P&gt;&lt;P&gt;for bit 6 and for bit 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data sheet (MC9S08DZ60 Series Rev.4, page 54) says:&lt;/P&gt;&lt;P&gt;"NOTE Before programming a particular byte in Flash or EEPROM,&lt;/P&gt;&lt;P&gt;the sector in which that particular byte resides must be erased&lt;/P&gt;&lt;P&gt;by a mass or sector erase operation"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This looks like the 1--&amp;gt;0 transition requires in all cases a&lt;/P&gt;&lt;P&gt;previous erase operation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have experience with this issue?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;-Roland&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jul 2009 16:34:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198333#M16055</guid>
      <dc:creator>Cantalis</dc:creator>
      <dc:date>2009-07-11T16:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: EEPROM usage 9S08DZ32 for byte-wise writes</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198334#M16056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Is it possible to program a (already programmed) byte without a prior&lt;/P&gt;&lt;P&gt;8-byte-erase if I only want to reduce the number of 1-bits in that byte?&lt;/P&gt;&lt;P&gt;(example of what I would like to do: after erase the byte is 0xFF, then I&lt;/P&gt;&lt;P&gt;program it with 0xC3, then I program it with 0x82h, which is a 1-&amp;gt;0 transition&lt;/P&gt;&lt;P&gt;for bit 6 and for bit 0)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It is possible, but programming erased byte to 0xC3, then programing it with 0x82 IS NOT writing more zero bits,&amp;nbsp;but&amp;nbsp;programming bits 1 and 7&amp;nbsp;from&amp;nbsp;'1' to '0' AND STRESS OVERPROGRAMMING bits 3-6! This can kill your eeprom, even on your old HC05.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jul 2009 15:31:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198334#M16056</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2009-07-12T15:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: EEPROM usage 9S08DZ32 for byte-wise writes</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198335#M16057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kef, thanks for your answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We did not do that even in HC05. It only came to my mind as a *possible* way to reduce the number of total erases. I remember in the 'old days' we did that with EPROMs (without having to UV erasing them through the window) or OTPs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I conclude from your answer that the way of "least stress" is indeed erasing the 8-byte-sector prior to any programming (no matter what the bit transitions are). The steps for programming a byte are then in any case:&lt;/P&gt;&lt;P&gt;1. Backup 8 bytes&lt;/P&gt;&lt;P&gt;2. Ersase 8 bytes&lt;/P&gt;&lt;P&gt;3. Update the new byte into the backup-buffer&lt;/P&gt;&lt;P&gt;4. Write backup buffer to original (now erased) 8 byte sector&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(The only special case would be the value 0xFF, which does not need to be written to a freshly erased byte)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this the way you would do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;-Roland&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jul 2009 17:16:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198335#M16057</guid>
      <dc:creator>Cantalis</dc:creator>
      <dc:date>2009-07-12T17:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: EEPROM usage 9S08DZ32 for byte-wise writes</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198336#M16058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed I miscalculated bit numbers, sorry. I meant&amp;nbsp;"but&amp;nbsp;programming bits 0 and&amp;nbsp;6&amp;nbsp;from&amp;nbsp;'1' to '0' AND STRESS OVERPROGRAMMING bits 2-5!"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Writing more '0' bits should work&amp;nbsp;on DZ32, though it's highly not recommended. Like&amp;nbsp;datasheet says, "NOTE Before programming a particular byte in Flash or EEPROM, the sector in which that particular byte resides must be erased by a mass or sector erase operation"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if you can't resist not trying to write without erase, then write more '0' bits should can be done in two steps:&lt;/P&gt;&lt;P&gt;1) check if you can program to desired state. if((desired &amp;amp; actual) != desired) then erase is required&lt;/P&gt;&lt;P&gt;2) value to be programmed to EEPROM has to be calculated like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_to_write = ~(desired ^ actual);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example actual value in EEPROM is 0xC3. Desired value is 0x82. data_to_write is 0xBE. As you may see, 0xBE has only two '0' bits, only in those bit positions, which must be reprogrammed in 0xC3 from '1' to '0'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since DZ , as you say, has&amp;nbsp;1kB EEPROM, you may try to sector align every&amp;nbsp;data item.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EEPROM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = NO_INIT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;aaaa TO&amp;nbsp;&amp;nbsp; bbbb ALIGN 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's up to 1024/8 = 128 8-byte-sector aligned items. To update&amp;nbsp;single item, you erase and reprogram just this single item.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Updating all 8 bytes at once isn't the best approarch, but it is very simple and thus may save precious code space.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jul 2009 19:46:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/EEPROM-usage-9S08DZ32-for-byte-wise-writes/m-p/198336#M16058</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2009-07-12T19:46:46Z</dc:date>
    </item>
  </channel>
</rss>

