Charging lithium battery while at the same time trying to use circuit didn’t quite workout, with problems like the circuit not turning on and the battery never finish charging.

The battery is 3.7V and capacity of 300mAH.

However I found the microchip app note on same issue.

Here is circuit:-[![enter image description here][1]][1]


  [1]: https://i.sstatic.net/w94vD.png


When USB power is applied at `Vin` this circuit will turn off `Q1`, and then the load will instead use power from USB through `D1`. This allows the battery to charge normally without any outside disturbances.

 - The `Q1` is P channel MOSFET, but I am not able to understand the
   connection. Why source is connected to load and Drain connected to
   Vbat? It should be reverse.

 - Which MOSFET should I select for this circuit? If my Load Current is
   100mA max? What should be the Rd (on) and VGS(th) of the MOSFET which
   I can use in above circuit? Any suggestion for the part number

I am considering this P-Channel MOSFET DMP1045U http://in.element14.com/diodes-inc/dmp1045u/mosfet-p-ch-w-esd-12v-sot23/dp/2061526

Also D1 is to prevent current flowing from the battery into the charging power source. `D1` should be a schottky diode. The reverse leakage current of D1, which could be up to a few hundred microamp (schottky diodes are very leaky).

 - This leakage current will create a small voltage at the MOSFET gate
   which, if high enough, could cause the MOSFET to not turn back on
   properly when the main `Vin` power is removed. How to overcome this?

 - How to minimise the leakage current of `D1`?

 - What should be the Value of `Rpull` ?