Sten Siren

EEPROM-programming on 9S12-controllers

Discussion created by Sten Siren on Oct 15, 2008
Latest reply on Oct 17, 2008 by kef
I have stumbled over a strange problem regarding EEPROM-programming on several different controllers in the 9S12-family. I have tested this on the following parts, and all behave in the same way: MC9S12DT128MPVE (chipset 1L59W), MC9S12D32VFUE (chipset 0M89C) and MC9S12XDT256CAL (chipset 0L15Y). I am using the same routines for EEPROM-handling on all parts.
The routine I am using to write a 4 byte page to the EEPROM starts by using the Sector-Modify command (0x60) to erase the page and program the first two bytes, then I wait for CBEIF (Command Buffer Empty Flag), continue with a Program command (0x20) to program the second two bytes and finally wait for both CBEIF and CCIF (Command Complete Flag).
This works (and has worked for a long time) fine, until I yesterday stumbled over something very strange. If the second two bytes of a page (any page anywhere in the EEPROM) is programmed to 10 4f, those two bytes remains erased (ff ff) and the 10 4f appears as the two first bytes in the next page to program.
This happens only with the exact bytes 0x10 and 0x4f and when programming to the second two bytes of a EEPROM page. For example, if I want to program 0 0 10 4f to adress 810 and 0 0 0 0 to address 820 the result will be 0 0 ff ff at 810 and 10 4f 0 0 at address 820.
I have fould out that if I wait also for the CCIF-bit after the Sector-Modify command (before using the Program command to write the 10 4f), it works ok. But should this be needed, because I am continuing the programming process, shouldn't it be enough to wait just for the CBEIF-bit? And why does it work with any other byte combination, but not with 10 4f?