I have a project with a slow rampup power supply. I am using an ATMEGA328P in a standalone configuration. When I program the chip it behaves just fine. If I power cycle quickly (a few seconds) after programming the part, it continues to behave. However, if I power it down and wait for reset lines and voltages to drop (a few minutes), power the project back up, the program behaves "differently" and does so forever regardless of power cycling. By differently I mean an algorithm in the program no longer computes the same result when given the same input. Using different parts gives the same behavior.
I have programmed these micros multiple times including the fuses. Is it possible for a fuse setting (perhaps a lock bits) to cause this type of behavior? You can assume that the lock bits had been programmed at one time since I've tried so many combinations.
I have tried using the brownout detector and a long startup time selection on CKSEL fuses to no avail.
Could this be flash/EEPROM corruption due to a slow rising power supply?
Hi, have you tried manually resetting the 328 after powerup to see if it performs correctly?
The spec for the ATMEGA328P says that the slowest ramp up to give a RESET on the reset pin is 0.01V/mS which is by my calculator 10V/Second, is your slow ramp up supply slower than this then you may not be getting a full RESET.
If you need the slow ramp up, you may have to make a separate circuit to reset the 328 when its supply is high enough.
TomGeorge:
Hi, have you tried manually resetting the 328 after powerup to see if it performs correctly?
The spec for the ATMEGA328P says that the slowest ramp up to give a RESET on the reset pin is 0.01V/mS which is by my calculator 10V/Second, is your slow ramp up supply slower than this then you may not be getting a full RESET.
If you need the slow ramp up, you may have to make a separate circuit to reset the 328 when its supply is high enough.
Tom....
TomGeorge,
When I manually reset the 328p after a long shutdown period, the part still misbehaves and does so regardless of power cycling or resetting. However, if I manually reset after reprogramming the same part and a short power cycle, the part acts just fine. I have tried multiple boards and they all behave identically.
Its as if flash or ROM is being corrupted or perhaps the clock selection is getting messed up after a long power cycle.
memotick:
I have a project with a slow rampup power supply. I am using an ATMEGA328P in a standalone configuration. When I program the chip it behaves just fine. If I power cycle quickly (a few seconds) after programming the part, it continues to behave. However, if I power it down and wait for reset lines and voltages to drop (a few minutes), power the project back up, the program behaves "differently" and does so forever regardless of power cycling. By differently I mean an algorithm in the program no longer computes the same result when given the same input. Using different parts gives the same behavior.
Somebody here linked to an interesting article recently about the ability for RAM to hold data after the Arduino had been nominally powered down. I wonder whether that could be exposing a latent bug where your code depends on the value of uninitialised data.
If you can reproduce the behaviour, and if it is tangibly wrong when the problem occurs, I would look for an explanation of how the wrong behaviour has occurred. This might lead you to inputs not being what you expect, or your data being in an unexpected state.
A very strange issue, a similar thing happened to me, however it was caused by large current draw from a battery supply . The strange thing is it should have never dropped the voltage low enough to upset anything. I thought it was because it was happening very fast, possibly. I haven't used the scope at that time and I was very happy to use a step-up to fix the problem.
But yes, it required reprogramming after every instance.
It would seem there is a voltage range that corrupts the flash is some situations.