# Microcontroller shutting off because of brief loss of power, can a capacitor fix this?

I have a microcontroller hooked up to a 5v supply which goes through a voltage regulator stepped down from 12v.

I'm assuming that it's rebooting because it's possible that the voltage drops quickly for a small fraction of time, which is enough to cause the chip to reboot.

Is this assumption correct?

Could adding a capacitor to the circuit solve this issue?

• I'm a bit surprised that the vendor's application notes didn't specify a couple of capacitors already... Jan 2, 2015 at 19:49
• Sure, but the capacitance needed for reliable operation under typical load variations is quite a bit short of what is needed to operate through brief supply failures. Jan 2, 2015 at 19:53
• Does the chip work fine on a reliable 5V supply? It could also be the watchdog resetting the chip, are you sure it's correctly setup or disabled?
– user17592
Jan 2, 2015 at 20:04
• Take an oscilloscope and look at the power supply voltage. Also look at the reset signal. This will give you more insight into your problem. The duration of the brownout (a dip or a downward spike in supply voltage) will help you size the capacitor, or to figure out what's causing the spike in the first place. If you catch the downward spike which causes the μC to reset, don't hesitate to post the screenshot here. Jan 2, 2015 at 22:19

There are possibly two things going on here, short glitches (ns to µs) and much longer supply dropouts (ms to s).

You always need a bypass capacitor accross power and ground of a microcontroller. This keeps the local supply steady despite quite large very short term variations in the current the microcontroller is drawing. These variations are too fast for the power supply to regulate away. Also, the traces back to the supply have enough impedance at the high frequencies of these fast current variations to cause local voltage fluctuations even if the main supply was totally steady.

The other problem of longer term power supply dropouts has to be handled with significant energy storage somewhere. After all, insufficient power is coming in for some period of time, and the local storage has to make up the difference temporarily. The best place to put this is before the regulator. Let's say your regulator requires 2 V headroom. That means it will continue to produce 5 V out as long as its input doesn't drop below 7 V. That's 5 V less than the nominal 12 V in. A large enough cap on the input can hold up the input voltage of the regulator for some time after the 12 V input suddenly goes away. Put a Schottky diode in series with the 12 V input, then the cap afterwards. That prevents the input going low from discharging the cap.

For example, let's say you put a 1 mF cap on the input of the regulator (in addition of course to the small high frequency caps required for basic regulator operation as specified in the datasheet). Since you didn't say what your current is, we'll arbitrarily pick 100 mA in this example. Let's also say the Schottky diode drops 500 mV at full current.

The cap is then charged to 11.5 V during normal operation, and can drop to 7 V before the 5 V supply starts to drop. (4.5 V)(1 mF)/(100 mA) = 45 ms, which is how long the cap can keep things running after the 12 V input suddenly goes away.

• If you're using higher supplies to power your MCU, then use a smaller capacitance. It will save resources when fabricated on an IC. Besides, look into the power supply. Modern voltage regulators (like LM723) almost never show this behaviour, and you should investigate your power supply circuit. Another reason for this behaviour is a short circuit somewhere. I cannot stress the importance of eliminating unintended shorts.
– xyz
Jan 3, 2015 at 13:20

If it's really power supply dropping, you'll do better with a capacitor in front of the voltage regulator (isolated with a diode, if necessary). That will allow the voltage to drop more before falling out of spec for the micro.

For example (picking numbers out of the air) suppose your micro needs 5V, your regulator supplies 4.75V and your micro is guaranteed to work at 4.5V. And further suppose you're feeding the regulator with 9V from a wall wart and the micro and other stuff draw 50mA. And suppose the regulator drops out at 1.5V.

If you put a 1000uF capacitor after the regulator, the time it will hold up the micro is:

t = 1000uF * (4.75V - 4.5V)/50mA = 5ms

If you put it before the regulator, the time it will hold up the micro is:

t = 1000uF * (9V - 6V)/50mA = 60ms (about 12x longer)

I kind of suspect that this may be an EMI issue causing disruption of the micro program unless you have a strong indication that the voltage is actually dropping.

It is mandatory to have ceramic capacitors close (~1cm) to the MCU supply pins. This is practically true for all integrated circuits.

But if you have doubts why the MCU resets, they usually have registers showing why a reset occured. Some MCUs have a brown-out circuit onboard and the trip point can even be set on some of them.

Which MCU do you use?

It is good practice to have some capacitance placed CLOSE to the power pins of the microcontroller. Typically a 1uF and a 0.1uF in parallel would do it. This is a general guideline though. It depends on how severe the voltage dip is (how much of a dip and for how long) that will tell you how much bulk capacitance.

In addition, for squelching conducted noise due to ESD, I would add a 470pF cap in parallel with the above.

That said, I would recommend you consult the datasheet for the microcontroller to see if there is a power fail bit that gets set in cases like this to see if it is a power failure at all.