Electronic – Atmel ATtiny EEPROM partially erased on power cycle

attinyeeprompower supply

I have a Digistump with an Atmel ATtiny85 MCU. I can flash the MCU's EEPROM with an ISP programmer no problem. The chip works fine, the bootloader runs and the user program executes correctly.

Occasionally on power cycling a 200W Meanwell PSU the ATtiny will stop working. I dumped the EEPROM and compared it to the original Intel hex file. I noticed that the first handful of bytes are erased. See below. This doesn't happen all the time, just occasionally. I can reflash the chip but eventually this happens again.

If you think this is a defective chip, know that I have 30 of them from different suppliers and many of them exhibit this behavior.

Also, the Digistump is directly powered by the PSU. There are no USB data connections.

Question: Why does this happen?

Could a ripple from the PSU being shut off initiate a partial erasure?

enter image description here

Solved:

The ATtiny85 has a Brown-Out Detect (BOD) circuit but it is disabled by default. There is a fuse calculator for AVR chips here. By setting the high fuse to 0xDD it activates the BOD threshold to 2.7V. With this enabled, EEPROM integrity seems to survive repeated power-cycling.

Best Answer

Such a slow decrease allows many possibilities for the MCU to "go nuts" and corrupt the EEPROM. It has enough supply voltage to do bad things (like write to EEPROM), but not enough supply voltage to operate reliably.

The same thing could happen with a relatively fast decrease, just less often, so you may be lucky to have caught it before it caused field failures.

A BOR circuit is the answer, hold it in reset whenever the supply voltage is out of spec for the clock speed and chip that you're using.

I don't recall if that particular chip has an on-board BOR and if it does, whether it works well enough, but external reset chips such as ADM805/809 variants work well provided you have the reset pin available.