I have I device with USB. When connected to USB it is powered from the USB port (an LDO to adjust from 5V to 3.3V), and when not connected to USB it is powered from a CR2032 battery. Below is the schematic with a P-MOSFET to switch between battery and USB power. The output from the LDO is 3.6 V, since it will drop slightly over D1.
The problem I'm having is that on USB disconnect, there is a rapid drop in voltage. See the oscilloscope image below. When connected to USB the voltage is 3.28 V, and on USB disconnect the voltage rapidly drops to 2.1 V, before stabilizing at 2.5 V for approx. 60 ms before rising to battery voltage of 3.08 V. The duration at 2.5 V can be anything from 1 ms to, as in this case about 60-70 ms.
On a previous version of the device, the exact same components and schematic layout is used, just a different PCB/board layout. Below is an oscilloscope image for that version. The same behavior is observed, but the "in-between voltage" is 2.75 V instead of 2.5. The duration at 2.75 V can be anything from 1 ms to 60-70 ms in this case as well.
But how come the difference (2.5 V vs. 2.75 V) with the exact same components, just different board layout? And how do I go about fixing this problem? There are components in the device that does not survive (loses settings) when forced to run on 2.5 V for as long as 60 ms, and maybe the rapid drop to 2.1 V is a problem as well.
How do I fix this?
UPDATE: The circuit load (across C1) is a low-power microcontroller, and some LEDs and buttons.
What I refer to as "USB disconnect", i.e. removing the USB power source and switching to battery power is accomplished through removing the device from the computer USB port. I.e., the LDO input disappears, and hence the LDO output 3.6 V.