Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] EEPROM write and power failure

2008-04-28 by David Kelly

On Apr 27, 2008, at 8:38 PM, Tim Gilbert wrote:

> We're doing an instrument that needs to store a variable in EEPROM.   
> It is a statistical certainty that, at some point, the power will  
> fail just as the software starts to write the data. Any idea's how  
> to handle this?

Write more than one copy.

A simple way to implement would be to declare 0xff not legal value for  
the variable and each time you write put it in the next EEPROM  
address. Out of RESET look for the last non-0xFF value.

Probably also want to store a checksum or CRC of the value just to  
make sure power didn't fail while the EEPROM write timer was running.  
A simple check would be to store a 1's complement.

--
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.