Preventing data corruption in EEPROM by software

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

 

I am using external eeprom to save data periodically. I use a data_pointer to point present memory location . But some time I facing problem that if power is failed during write cycle then data is lost.

For this I use two memory location for pointing the last location.one is for memory pointer and other is for backup pointer. I calculate the CRC for both location. If crc of one is failed then program use back up location for addressing.and if CRC of both failed then I reset both location.I put this reset because I assume that it never happen because I keep delay of 20ms between storing memory_pointer and back up pointer along with crc . I want to know is this is correct method for error handling or there is some better way???

 

 

 

 

     

 

This topic has a solution.
Last Edited: Tue. Mar 19, 2019 - 09:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Two points often recommended:

 

1. Use the brownout detector

 

2. Avoid data in EEPROM address 0x0000

 

Those are, in my mind, a MUST. But nothing can prevent the loss of data when power is removed during a write. 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
1. Use the brownout detector 2. Avoid data in EEPROM address 0x0000

 

Well said.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can't use brownout. I am using a external eeprom. And as you say I am not using 0x000 address. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Moved to AVR for now, unless a different chips is used.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samic45mit1 wrote:

But some time I facing problem that if power is failed during write cycle then data is lost.

 

 

Then you have to fix this problem first. try to add some protections to avoid this problem not only by software but also by HW.

 

HW:

- I suppose you are using a custom PCB. is you chip working at the specified voltage ?, Do you have an LDO or whatever stabilizing power unit before feeding power to your chip ? rising and falling and transient noise maybe a cause to the EEPROM data corrupt.

 

Regards,

Moe

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

We had a product years ago that sort of did the reverse...If it detected that the input power was dropping/being removed, it would quickly write the system settings & some parameters to the EEPROM.

The logic supply was designed to have enough hold up time (Vout available after input removed), to get the writes finished before the brownout kicked in.

It used the 68HC11, the first processor with built in EEPROM...that was big news and I seem to remember getting a free lunch to listen about it around 1986.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any standard algo to deal such problems ??

 

I am using 512Kb eeprom with atmega128 so internal is not enough for me. and I am using 7805 with 100uf capacitors but it can't hold because of GLCD in the circuit. That's why I try to use above aglo(in my first post). And there is no power supply fluctuations. This happen when someone turn off the switch. I am saving data at 10 minute interval and I can effort to lose some readings so I want to go with software based algo.  

Last Edited: Tue. Mar 19, 2019 - 08:05 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samic45mit1 wrote:
I can't use brownout. I am using a external eeprom.
External EEPROM with bi-directional POR (power-on, brownout)

NV25512WF: EEPROM Serial 512-Kb SPI - Automotive Grade 1 (+125°C), Wettable Flank UDFN Package

25LC512 - Memory

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd use diode and bigger capacitor for MCU + EEPPROM power rail, it should hold the voltage much longer. But you have to disable all outputs as fast as you can detect power loss (or set them LOW). Maybe slow down MCU clock and disable everything you don't need.

Computers don't make errors - What they do they do on purpose.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Sorry

 

I not mensition my part no 24LC512. This is a I2C based eeprom. And my clock is 100Khz and pull up of 4.9K(But I think this is not problem). But I want to go with the algo I mention (changing part is not a good option for me).  Thank's

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samic45mit1 wrote:
I am using 512Kb eeprom with atmega128 so internal is not enough for me.
MRAM has bi-directional POR though for XMEGA128A1U; an XMEGA has a CRC generator.

MR0A08B | Everspin

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

samic45mit1 wrote:
... my part no 24LC512.
24LC512 - Memory

 

"Dare to be naïve." - Buckminster Fuller