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


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.

  • 1
    \$\begingroup\$ Is there a brownout reset circuit that is a) present b) active c) set to appropriate voltages ? \$\endgroup\$ Commented Aug 15, 2019 at 21:44
  • 1
    \$\begingroup\$ No. None. The PSU, as seen on a multimeter, slowly decreases in voltage over the span of about a minute. I have a UPS-style shut-off circuit in mind (brownout off circuit), but I'd like to confirm if undervoltage or a ripple can cause this effect. \$\endgroup\$
    – Drakes
    Commented Aug 15, 2019 at 21:47
  • \$\begingroup\$ @Drakes Thanks for coming back with the outcome after a long time! You should post this is an answer and mark it as accepted :) \$\endgroup\$
    – awjlogan
    Commented Mar 16, 2021 at 20:19

1 Answer 1


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.

  • 1
    \$\begingroup\$ @Drakes ATtiny85 doesn't have a brownout circuit? It does according to the datasheet. \$\endgroup\$
    – DKNguyen
    Commented Aug 15, 2019 at 22:58
  • 1
    \$\begingroup\$ It does. Setting fuses is new to me though. I’m in the process of setting the BOD fuses as we speak. Then I’ll monkey-test cycling the power supply and report the results. \$\endgroup\$
    – Drakes
    Commented Aug 15, 2019 at 23:00
  • 1
    \$\begingroup\$ This was the right direction. By setting the high fuse on the ATtiny85 to 0xDD the BOR/BOD circuit is activated and set to a 2.7V threshold. \$\endgroup\$
    – Drakes
    Commented Aug 16, 2019 at 3:47
  • 2
    \$\begingroup\$ @DKNguyen Is isn't because what level should it default to? \$\endgroup\$
    – Jeroen3
    Commented Aug 16, 2019 at 6:15
  • 2
    \$\begingroup\$ Enabling the Brown-Out Detector is correct here. Back in the days when AVRs did not have internal BODs, EEPROM corruption and especially the addresses starting from zero was a problem, since chip reset while writing would also set the EEPROM write address register to 0. One solution was to avoid the first page starting from 0, and after each write operation, set the address register to 0 for safety, so that accidental erase operations happen there. \$\endgroup\$
    – Justme
    Commented Aug 16, 2019 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.