I have a small circuit which is normally powered by a CR2032 coin cell but also has a SWD header for programming. I made a simple power path switch so that when I am programming, VDD is supplied by the programmer.
The schematic looks like this:
I found that the CR2032 coin cell gets severely degraded after unplugging the 3.3v power. Oscilloscope showed a huge influx of current from the decoupling capacitors (~200uF) in the circuit, caused by the Q1 becoming "reverse conductive" immediately after the 3.3v is removed and the voltage difference causes the current to flow back into the battery.
I'm stuck in trying to resolve this, adding a capacitor in parallel with R1 doesn't solve the issue because the current consumption of the circuit (MCU + Radio) powered by VDD isn't constant (varies between 5uA and 50mA). Thus, you cannot select a single time constant to work for this.
I do not want to add a diode between VBAT and VDD because there cannot be any significant voltage drop during normal operation.
How can I prevent current from flowing back into the coin cell while at the same time not dropping VDD when the switch from 3.3v to VBAT power is made?
Update: I am targeting a quiescent current in the single-digit uA range when the power is supplied by VBAT.
Update: Here is the OP-AMP based circuit based on Andy's suggestion:
Update: Here is improved version of the OP-AMP circuit which adds D2 to eliminate current inrush from VDD to the coin cell when VCC is connected (caused by the limited slew rate of OA1). Note that OPA349 should be used as OA1 and low-leakage schottky diode should be used for D2 (this was the best I could find in CircuitLab).
I'm not happy with the BOM cost of this solution but it might be the best I am able to achieve here.
simulate this circuit – Schematic created using CircuitLab