Preventing EEPROM Corruption. HOW???????

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

Hi there, I have a serious problem. Can anybody help me please?
I try a project using the ATMega16 uC. Once per day I want save 41 datas in the EEPROM. Typicaly the write cycle is 8.5 ms. So saving 41 datas the time is 41x 8.5 ==350 ms. The problem is what is gonna be hapen when Pablic AC Voltage stops (it means low Vcc) at a write cycle.

-------Atmel suggests: Keep the AVR RESET active (low) during periods of isufficient power supply voltage. This can be done by enabling the internal Brown-out Detector (BOD). If the detectionlevel does not match the needed detection level, an external low Vcc reset protection circuit can be used.--------

The ATMega16 BOD is at 4.0V but it operates for Vcc higher than 4.5 V. So how can I build a low Vcc reset protection circuit?
My only idea is to put a pull up (to Vcc) on the pin reset and connect it (with a resistor) to the mains supply and put a capacitor between Vcc and Gnd. So when the mains supply stops the chip goes to Reset, but the energy in the caracitor keeps the EEPROM internal regulator active to finish the write cycle.....
Does it works????

Please, Help

-------------------------------------------------------------------------------------------------------
Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

If you want to garuntee that the entire write occurs without errors regardless of external voltage the brown out detect will not suffice for this purpose. What you need to use is a very large value capacitor (Carbon Aerogel Capacitors work well due to their low voltage and extremely high capacitance. Set up an ADC pin on the Supply side of the VCC connection it needs to be protected with a diode to avoid the capacitor on the AVR side from sourcing to the ADC line. If primary power is cut your ADC pin will pick up the voltage drop WELL before the capacitor drains and you can act before the capacitor discharges bellow a EEPROM safe state. This is basically a software brownout detector, but with a large value capacitor in the way you can finish up ANY code you want before the power dips bellow operational levels. I've played around with 5volt 1 farrad aerogels before and as long as you're not sourcing a lot of I/O pins is more than enough to complete a 350ms. The Digikey part number for the caps I used is 283-2514-ND. They have a full line of large value capacitors rated for various voltages. They have an excell spreadsheet which allows you to input the voltage charactorsistics (min voltage, max voltage, and run time required within that range) to find wich product will suit your particular need. A properly designed circuit and code can be made completly immune to power failure.

-Curiosity may have killed the cat
-But that's why they have nine lives

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

Thanks alot for your reply. This is what exactly I was thinking to do. There is no need to use so big capacitance because one EEPROM write cycle lasts typicaly 8.5ms. There is no need to write all 41 datas in the EEPROM (350ms). The only thing I want to be sure is that when the mains power falls down during a write cycle, the data in the EEPROM is writen correct. So I can use a smaller capacitance, that can give me power for at least 10 ms, when there is no supply.
But I did not found in the AVR Data Sheets the lower EEPROM internal regulator voltage level. I mean the lower operating EEPROM voltage value. If I knew it I could calculate the Cap. Do you know something???

Thanks you very much Mr. < Sceadwian >
--------------------------------------------------------------------------------------------------
Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Im going to do much the same in detectinga mains failure.

Except i have a 12v battery as backup , and will be using the 50 hz from mains to trigger an interrupt.

That interrupt is clearing a variable that i count up in my 10ms timer interrupt.

So if my timer interrupt variable is inceasing , then i get no 50Hz interrupt and mains is out.

Atmel has an app note on Zero crossing using 2 resistors for the mains connection

/Bingo

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

Bingo600 wrote:
Atmel has an app note on Zero crossing using 2 resistors for the mains connection

Personally, I wouldn't do a direct mains connection. Instead, I'd use an AC adapter and a bridge rectifier to generate VCC and connect the EXT INT pin to the low voltage AC side.

Don

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

He..He

Im actually doing that , with a 12v transformer (allready in there , and are going to use 47K resistors instead of the 1M.

/Bingo