Hello Allem77!
EEPROM is non-valotile memory and In order to write/erase it you need special routines.... Some tips:
- An EEPROM address is erased when its value is 0xFF
- In order to re-write EEPROM, you first need to erased it and then write the new value.
- You should also know that it is dword aligned (4bytes) and that's the minimmun erase size... If you're trying to erase a single byte, the other 3bytes from that "block" would also be erased. See the next graphic:
4bytes 4bytes
+---------------+---------------+
| x | x | x | x | x | x | x | x |
^
If tryng to erase this byte, the other from the same block would also be erased
4bytes 4bytes
+---------------------------+---------------+
| 0xFF | 0xFF | 0xFF | 0xFF | x | x | x | x |
Take a look at page 1039 for 2k EEPROM or page 1073 for 4k EEPROM, from MC9S12XD family reference manual. And you may also find some examples routines.
Best Regards!