I am designing a circuit, which can use either 5V from USB, or some higher voltage (7-12V) from a battery. If both power sources are connected at the same time, I want some kind of electrical switch, that would disconnect the battery and power the circuit just from the 5V USB. But the circuit still has to work, when only one of the sources is present. I tried to design a switch using two mosfets, but I was not able to figure out a working circuit.
Can such a circuit be build by only using two mosfets? Also, do not worry about the voltage regulation, that is taken care of.