CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

write eeprom redundant / voltage drop

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nilsener
Guest







write eeprom redundant / voltage drop
PostPosted: Tue Feb 18, 2003 9:30 am     Reply with quote

Dear,

PCWH 3.110 and 18F452

I am writing to the internal EEPROM, in case of a supply voltage drop during a write operation the written data will be garbage. If this happens, the valid data that has been stored before the write operation must be restored. I think this is only possible by writing data redundant to the EEPROM and after reading corrupted data to decide which of them are valid.

Has anyone a sophisticated idea or algorithm to do this with few redundancy ?

regards nilsener
___________________________
This message was ported from CCS's old forum
Original Post ID: 11832
Eric Minbiole
Guest







Re: write eeprom redundant / voltage drop
PostPosted: Tue Feb 18, 2003 1:41 pm     Reply with quote

<font face="Courier New" size=-1>Here's the best approach I could come up with. It may not be the most elegant, but it seems like it would work and would use relatively few (3) extra locations:

1) Reserve three locations in EEPROM. I'll call them address_to_write, value_to_write, and write_in_progress.

2) When your code is about to update any EEPROM value, set address_to_write and value_to_write appropriately.

3) Only <I>after</I> those two values are set (and verified), set write_in_progress to be TRUE.

4) Now, you should write the actual value to the actual address in EEPROM.

5) Once this has been written <I>and verified</I>, set write_in_progress back to FALSE.

Now, whenever you power up, check the write_in_progress flag. If it's TRUE, you should repeat steps 4 & 5, using the data you saved in step 2.

Benefits:
- Power can fail at <I>any</I> point throughout the sequence, and you will still recover with valid data.
- Uses only three extra EEPROM locations total.

Drawbacks:
- The three EEPROM locations are used every time there's an EEPROM write, so, depending on your application, you may reach the chip's maximum Erase/Write cycles quickly. (Microchip guarantees them for 100k cycles.) If your app needs to write more often, you may consider doing some sort of round-robin approach.

Let us know what you decide. I'm curious to see what works well.


:=Dear,
:=
:=PCWH 3.110 and 18F452
:=
:=I am writing to the internal EEPROM, in case of a supply voltage drop during a write operation the written data will be garbage. If this happens, the valid data that has been stored before the write operation must be restored. I think this is only possible by writing data redundant to the EEPROM and after reading corrupted data to decide which of them are valid.
:=
:=Has anyone a sophisticated idea or algorithm to do this with few redundancy ?
:=
:=regards nilsener </font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11840
nilsener
Guest







Re: write eeprom redundant / voltage drop
PostPosted: Fri Feb 21, 2003 2:08 am     Reply with quote

Dear,

thanks for your suggestion, since there are only a few write cycles in my application I am not afraid to reach the max. cycles of 1M for the 18F452. I am happy to use only three extra locations because of the small eeprom.

Your idea animates me for an other think over. It must be possible to locate three locations for each value.
Benefit: increasing number of write cyles.
Drawback: needs much more eeprom space.

value_to_write, write_in_progress, valid_value.

I have to think over a little bit more, and will give you a feedback about my decision and what works well.

Thanks a lot for your help,

regards nilsener

:=<font face="Courier New" size=-1>Here's the best approach I could come up with. It may not be the most elegant, but it seems like it would work and would use relatively few (3) extra locations:
:=
:=1) Reserve three locations in EEPROM. I'll call them address_to_write, value_to_write, and write_in_progress.
:=
:=2) When your code is about to update any EEPROM value, set address_to_write and value_to_write appropriately.
:=
:=3) Only <I>after</I> those two values are set (and verified), set write_in_progress to be TRUE.
:=
:=4) Now, you should write the actual value to the actual address in EEPROM.
:=
:=5) Once this has been written <I>and verified</I>, set write_in_progress back to FALSE.
:=
:=Now, whenever you power up, check the write_in_progress flag. If it's TRUE, you should repeat steps 4 & 5, using the data you saved in step 2.
:=
:=Benefits:
:=- Power can fail at <I>any</I> point throughout the sequence, and you will still recover with valid data.
:=- Uses only three extra EEPROM locations total.
:=
:=Drawbacks:
:=- The three EEPROM locations are used every time there's an EEPROM write, so, depending on your application, you may reach the chip's maximum Erase/Write cycles quickly. (Microchip guarantees them for 100k cycles.) If your app needs to write more often, you may consider doing some sort of round-robin approach.
:=
:=Let us know what you decide. I'm curious to see what works well.
:=
:=
:=:=Dear,
:=:=
:=:=PCWH 3.110 and 18F452
:=:=
:=:=I am writing to the internal EEPROM, in case of a supply voltage drop during a write operation the written data will be garbage. If this happens, the valid data that has been stored before the write operation must be restored. I think this is only possible by writing data redundant to the EEPROM and after reading corrupted data to decide which of them are valid.
:=:=
:=:=Has anyone a sophisticated idea or algorithm to do this with few redundancy ?
:=:=
:=:=regards nilsener </font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11945
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group