On Mon, 22 Sep 1997 13:24:04 GMT Mike Watson writes: >> >> A method I have used keeps two copies of the data and a pointer >byte. >> I write alternately to the one or the other. I first write the data >and >> then write the single pointer byte to indicate which of the entries >> contain the most recent info. This method makes sure that the data >you >> read is always valid (although it might not be the newest data). >Is there not a danger with this method that the pointer location >could get corrupted if it is being written at the same time that >the power is being removed? > >Have you a mechanism to deal with that? It is important that the new pointer is written *after* the data. If power fails while writing to the new data block, the pointer will still point to the old one, so the incompletely written data will not be used. If the new data block is written but the power fails while writing the pointer, both blocks of data will be valid (one old, one new). The read routine must mask the pointer so it always reads one or the other data block. If the pointer is bad the worst that could happen is the older data will be retreived, the same result as if the new data were not completely written. All this is based on the assumption that cutting the power off in the middle of an EEPROM write will only affect the byte being written.