PDA

View Full Version : How to avoid corrupting an EEPROM Write



jessey
- 5th July 2005, 10:29
Hello Everyone

I'm using a 5K potentiometer connected to an AD converter on my 16F877 to generate a number. The reason I used a pot was, so that I wouldn't have to save the value to the eeprom and take a chance that the value of that variable would become corrupted if I had a power failure during a write to the eeprom.

Now I'd like to learn the proper way of doing this but don't know where to begin.

I'd like to use pushbuttons instead of the pot to increase and decrease the value of the variable but I'm not sure on how or what I need to accomplish the task of detecting the power failure to be able to safely save the value of that variable before the power is lost.

I won't have any problems with the code routines for the pushbuttons to increase and decrease the variable and I know how to save the word variable to the onboard eeprom.

What I need to know is if I need a special chip of some sort to detect the power failure and will the onboard eeprom be adequate for saving the value? Could someone explain my options and suggest what would be the best way of accomplishing this. I'm totally in the dark on this one and would appreciate any feedback.

Thanks
Jessey

Melanie
- 5th July 2005, 11:45
Take a look at this thread...

http://www.picbasic.co.uk/forum/showthread.php?t=360

Obviously you don't need the connection to the Battery. You need a large capacitor to act as a reservoir to keep the PIC alive long enough to complete an EEPROM write operation (10mS per byte). You simply detect that the power has failed (or not) by sampling the raw supply input and decide whether to proceed with the Write.

Personally I wouldn't bother... we manufacture hundreds of thosands of products annually, most have some kind of setup in EEPROM which can be user changed with Menu routines. I've yet to hear of a single instance where a system's been corrupted due a power outage. I'm not saying it can't happen, but I am saying that it's a seriously rare occurance that unless I was designing a Mission Critical application (aircraft, medical, elevator, chocolate dispenser kind of thing...) then I wouldn't worry about it.

Ingvar
- 5th July 2005, 15:32
Don't we just love those chocolates ....... *LOL* But seriously Mel, didn't you forget to mention creditcardreaders. It would surely be a disatser if we couldn't pay for our new shiny dominatrix leather boots just because the machine couldn't read our Visa :p

Melanie
- 5th July 2005, 16:51
I consider Chocolate as Mission Critical…

You know the Government tells us that we need to eat five portions of vegetables each day to stay healthy…

Chocolate comes from a bean… beans are pulses… pulses are right in the middle of the vegetable family, so that makes chocolate squarely a vegetable…

I believe everything our Government says… yup… every word…

PS… there is (almost) nothing as sensual as eating chocolate wearing just thigh-high dominatrix boots with long spiky heels… you should try it, it'll change your outlook on life forever…

Ingvar
- 6th July 2005, 08:34
That would definitely change my life forever. Waking up in the ER with two broken ankles and chocolate smeared all over my face .... some people would find that slightly embarrassing, myself included :o