I'm trying to design a auto voltage selector circuit to prioritise USB voltage when the USB is plugged in. The power goes through some voltage regulators which then powers a MCU (ATMEGA32U). I have two circuits for this, one that goes to the 3.3V voltage regulator and another that goes to a 5V voltage regulator. VIN varies from 3.7V to 15V.
Voltage selector for 3.3V When there is no VUSB present the P-Channel MOSFET allows current to go through from VIN. When VUSB is present, it turns on the P-channel MOSFET which blocks the current from VIN and allows the current flow through via the diode. The switch is just there so that I can bypass this entire circuit if necessary.
Voltage selector for 5V Similar to before when no VUSB is present, the P-Channel MOSFET allows current to go through from VIN. When VUSB is present, it turns on the P-Channel MOSFET which block the current from VIN and allows current to flow through to the 5V rail bypassing the voltage regulator via the diode.
So my question is, is there any problem with this circuit and will it work? I know there are similar questions like this before but none has been exactly what I need. Thanks in advance.