# Atmel AVR cutting down the power

This might be a straight forward question: An AVR gets its power from a regulator which can be turned off with a digital low level input. However on a spike (digital high followed by digital low) the regulator will re-enable itself.

If I use a GPIO of the AVR to control this regulator enable input, the regulator will be turned off, hence the AVR powers off too. Kind of a suicide thing, I know but I need it.

What can I expect from the AVR ports after cutting down the power from it?

What shall I do to kill the spikes on the ports? I must be sure that on the AVR's port remains on GND after the specific suicide instruction.

Is there any hardware requirements which applies to this situation?

• To get better answers, please attach a schematic of your design, using either the Schematic editor button (best/preferred option) or Image button in your original question. – Huisman Jul 15 at 13:56

You can smooth out spikes with a capacitor. And a pull down resistor should keep the GND while powered off. Something like this:

simulate this circuit – Schematic created using CircuitLab

When the capacitor is empty and a spike hits it will start charging and hopefully the spike will be over before the voltage on the regulator leaves the low state. The pull down resistor R3will discharge the capacitor over time. R2 protects the AVR from drawing too much current from the GPIO pin when charging the capacitor while R1 protects the regulator from spikes (I assume you mean the AVR pin spikes).

You probably have to adjust the values of R1/2/3 and C1 to fit. You can connect an osciloscope and simulate spikes to check your math.

• Check to see what the AVR's behavior is in reset. Some processors set up GPIO pins to have weak pull-ups coming out of reset, until they're disabled. If the AVR does that, then R3 in this circuit needs to be stout enough to overpower the weak pull-up -- or you need a 1-gate inverter here. – TimWescott Jul 15 at 14:50
• Right. Forgot about that. Could even differ depending on which pin you choose. – Goswin von Brederlow Jul 15 at 15:16
• Won't work because you have no means to turn it on. – Jack Creasey Jul 15 at 16:13
• @JackCreasey or the OP just didn't tell us how it's turned on. You can make a pretty robust on/off switch for a $\mu$P-driven system by having a push button that forces the power to the $\mu$P on, and then set the $\mu$P up to hold power on when it comes out of reset. Make that button readable by the $\mu$P, and you can make the behavior as simple or complicated as your heart desires. – TimWescott Jul 15 at 16:24
• @TimWescott No, the person answering the OPs question did not show any way to turn it on. It has to be part of the solution, no? – Jack Creasey Jul 15 at 19:41

In general this type of 'suicide' turn off will not work. As the power is disconnected the AVR will power fail and eventually all the I/O ports reset to inputs ...so your signal goes away.

Not amount of RC delays or clever tricks will help you. You need to be able to either store the state of power (on/off) or provide a relay (which itself is the logical state storage).

simulate this circuit – Schematic created using CircuitLab

Here you have a manual pushbutton to turn ON.
The MCU then takes over and holds the relay ON.
If the MCU code turn OFF the relay the supply to the MCU drops. Though you need to consider the timing for this since there is lots of capacitance on the supply.

You certainly could make this work, but timing is the detail.

• Or a simple pull down resistor so once the pin goed off on suicide and turns to input it remains low and off. So your answer is wrong. There is a trivial solution to this and that was exactly the Ops question. – Goswin von Brederlow Jul 18 at 15:02