Re: [EE] High reliability store and recall of data in EEPROM
Neil <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.pic |
|---|---|
| Message-ID | <[email protected]> |
0x01 XOR 0xFE should be 0xFF, shouldn't it? ;) A long (long) time ago, I had to do something similar with a PIC16F877 after learning how unreliable the EEPROM within the PIC was. I was storing odometer data, and a big part of that each data value required multiple bytes (4 IIRC, as I was storing up to 1,000,000 with 0.01 precision). I used an external serial EEPROM. With ideas/help from this list way back then, what I ended up doing was this: - Group EEPROM memory into *many* sets of (IIRC) 6-bytes each. One byte represented "dirty" (with a key value to represent "clean"), 4 were the data bytes, and one was a checksum - Mark set as dirty (all were initialized to dirty from the start anyway) - Write 4 data bits and checksum - Read back 4 data bits and checksum and if all match, then mark the dirty bit as clean. - Increment set index for next value. Worked beautifully. Some of these ideas may be useful for you saving multiple bytes for each value. Cheers, -Neil. On 12/6/2024 4:49 PM, David VanHorn wrote: > I have a need to store some data in non-volatile memory, with the caveat > that corrupt data MUST NOT occur. Things go "big badda boom" otherwise. > > Offhand, I came up with storing each byte as a four byte array (I have TONS > of space available) > If I'm storing 0x01 then it would look like this: > > 1 2 3 4 > 0x01, 0xFE, 0x01, 0x55 > > Xor 1 and 2, result must be zero. > Xor 3 and 2, result must be zero. > compare 1 and 3 result must be zero (not sure this is needed) > check 4, must be 0x55 otherwise a wild write has happened in EE. > Finally the values allowed will be sparse, and likely only a single bit > will be set, so I will check that the value I read is one of the allowable > values. > > If any of those checks fails, we render safe and halt. > > Is there a more "rock solid" method? What would be done in an automotive > environment for something like throttle position? What would be best > practice for medical life safety? -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at https://mailman.mit.edu/mailman/listinfo/piclist