Hi! I want to use a P-channel MOSFET as a switch for my charger. The source terminal of the P-MOSFET is connected to the source of 20v, the drain is connected with a 14V battery and the gate terminal is controlled by Microcontroller PWM. I am thinking of using the voltage divider configuration , I am trying to simulate first but then I can't make the MOSFET turns off. What should I do? Any suggestion guys? Thanks.
A P-device has its bias referenced to the more positive terminal, or positive supply rail. To turn it off, you must apply positive supply voltage. Try a pullup resistor (10k is reasonable) at the gate. This automatically turns it off.
I'm describing the simple basic arrangement. You need to adapt the concept to your own project, of course.
You did not say if the negative terminal of the battery is the Microcontroller ground. If it is then you need a level shifter:
Microcontroller= +5V, Mosfet gate= 20V (it is turned off).
Microcontroller= 0V, Mosfet gate= +10V (it is turned on).