What byte vaule should I see when reading empty EEPROM chip via I2C?
Best Answer
The way an EEPROM works, the act of erasing sets every bit to 1. When you write to it the bits that shouldn't be 1 are set to 0. It's all to do with the movement of free electrons in the semiconductor layers.
Therefore, an erased 'empty' EEPROM will always read 0xFF for every memory address.
However, you cannot always guarantee the current state of an EEPROM when it arrives from the supplier / manufacturer. It may have had some data written to it in order to test it, and not erased afterwards. You'd expect a good manufacturer to always finish the testing with an erase, but this isn't something that can be 100% guaranteed.
Therefore, you should erase the EEPROM before first use.
If the EEPROM is to be used to store data that is generated by the system it is placed in, then you could have an 'identifying' byte in a known location - check to see if that byte is there, and if not erase the EEPROM and write the identifying byte. That way you don't have to worry about what state it is in when first inserted into the circuit.
You're reading the data after clock is low again. You'll have to do that between making the clock high and making it low. After the clock is low the slave is allowed to change the data line, not while it's high.
So reading should be like this:
wait
SCL low
SDA high
for each bit (8 bits)
SCL high <--------
wait
check and store received bit <--------
wait
SCL low <--------
wait
wait
do a NACK or ACK depending on if it is the last byte
If you fill the 4096 byte EEPROM once, you still have 999999 write cycles left for each cell.
If you (over)write the same byte 4096 times, you have 995904 write cycle left for that particular byte and full 1000000 for each of the rest of 4095 bytes.
Best Answer
The way an EEPROM works, the act of erasing sets every bit to 1. When you write to it the bits that shouldn't be 1 are set to 0. It's all to do with the movement of free electrons in the semiconductor layers.
Therefore, an erased 'empty' EEPROM will always read 0xFF for every memory address.
However, you cannot always guarantee the current state of an EEPROM when it arrives from the supplier / manufacturer. It may have had some data written to it in order to test it, and not erased afterwards. You'd expect a good manufacturer to always finish the testing with an erase, but this isn't something that can be 100% guaranteed.
Therefore, you should erase the EEPROM before first use.
If the EEPROM is to be used to store data that is generated by the system it is placed in, then you could have an 'identifying' byte in a known location - check to see if that byte is there, and if not erase the EEPROM and write the identifying byte. That way you don't have to worry about what state it is in when first inserted into the circuit.