PicDude wrote: >Had a problem recently where the EEPROM data on a PIC got corrupted during >operation. I feel strongly that a power-surge/issue caused this. Is this >really possible? Or are there other conditions that can cause this? > >BTW, here's why I feel that power caused it... the PIC stores counts of events >that occur periodically. Each new data point is higher in value than the >previous one. The EEPROM area is virtually divided into multiple groups, and >the groups are written to sort of like a circular buffer. When writing a >group, each byte is written and then a checksum is written in the appropriate >location for that group. After the last group is written, the first group is >re-used. There are something like 20 groups of 4 bytes each. If power is >switched off and back on, all EEPROM data is scanned as groups for valid data >(using the checksum) and the highest valid value is where the counting >re-starts for future events. A loss of 1 occassionally due to power being >switched off during a write is okay. > > > This has come up before on the list. I did a consulting job on this and here is what I decided: 1. This problem is unique to the newer PIC's, and was not noticed with PIC16C??? devices. The problem exists on other EEPROMs built from other vendors, including ATMEL and others, as well. 2. It seems that there is now a requirement to periodically refresh the EEPROM. Microchip recommends it but the reason was never clear. Their method takes too much code space to implement. 3. The best way to solve this seems to be to write the code so that data was written in triplicate, and when read back, use the "best two of three" method to decide what data to use. When writing, write all three in ONE PASS, then read them back to make sure all three are written. This solved the problem for my client and hasn't arisen since. --Bob >This has been running successfully for some weeks, but when the EEPROM got >corrupted, there was a lot else on that power line, being switched on an off. >And all of this occuring on a breadboard with a pretty crappy old AT >power-supply that can't regulate 5V properly to save it's life. It varies >from 4.6V to 5.1V regularly depending on load. As soon as I saw that data >get screwy (based on display output), I read-back the contents of the EEPROM, >and all locations were screwed up. And the time between the noticed >corruption and the read-back was small enough to allow only 1 or 2 events to >occur. The remaining data groups should've been valid. > >Any idea what could cause this, and more what else I should be doing to >protect against this in the future? > >Cheers, >-Neil. > > > > -- Note: To protect our network, attachments must be sent to attach@engineer.cotse.net . 1-866-263-5745 USA/Canada http://beam.to/azengineer -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist