I was wondering how reliable it would be to drive a P-channel MOSFET directly from a micro-controller pin like this:


simulate this circuit – Schematic created using CircuitLab

When I want the FET to be ON I make the pin output low (connecting the gate to the ground).
When I want the FET to be OFF I make the pin input (high impedance), pulling the gate to 12V through R1.
The only problem I see is that when OFF, the MCU pin will "see" 12V through R1, but I am thinking it shouldn't really be a problem, since R1 is quite high and the impedance of the pin itself is much higher, so there shouldn't really be any danger for the pin. Or am I wrong?
Obviously, we're not talking high switching speeds here, just turning stuff on and off from an MCU.
I know it is usually done with a BJT or N-channel MOSFET acting as "gate driver" for the P-channel MOSFET. The question is, what will go wrong if I try to skip it?
I don't have a specific MCU in mind, could be an ATTiny monitoring the input voltage and deciding whether or not to pass it to the rest of the circuit or an ESP8266 turning stuff on and off over the internet and whatnot.

  • \$\begingroup\$ Oh, I was under the impression that MCU pins are high impedance when set as inputs. \$\endgroup\$
    – Mishony
    Apr 26, 2016 at 5:47
  • \$\begingroup\$ Right, missed that part. But you still have the protection diodes to worry about. \$\endgroup\$ Apr 26, 2016 at 5:48
  • 1
    \$\begingroup\$ Look for the ESD clamping diode spec for your MCU, and see if it is cool with 1.2mA continuous current. You could change that pull-up to 47k or 100k possibly, and that would likely be safe for most MCUs and their protection diodes, but as a few folks have said, the "conventional" way of doing this involves adding another N-channel device to act as the level shifter. \$\endgroup\$ Apr 26, 2016 at 6:07
  • 2
    \$\begingroup\$ This will not work.. Believe me.. I have tried and know. When the microcontroller's gate driving pin is high impedance, there will always be a clamping diode from the pin to the VCC which will never let the gate voltage of the MOSFET rise to +12V.. \$\endgroup\$ Apr 26, 2016 at 6:41

2 Answers 2


Good question. You are wise to ask.

This is not recommended. Sometimes MCU inputs specify that a certain amount of current can be injected through the protection diodes. You will have to check the MCU you eventually settle on. Select a pullup that will insure you stay under the maximum allowable current. But it would probably just be easier to add an additional NPN or N-channel (BSS138) to pull down the gate of the PMOS. Then there is no problem and you are free to choose any MCU, because it will never "see" 12 V.

Edit: I was only thinking about damage to the MCU. But @abdullah kahraman raises another equally important point. The diode current will also cause the PMOS to turn on. So this just plain won't work.


What will happen is that the pull-up will pull up the MCU pin to 12V! Can your MCU handle 12V on IO pins? If so, no problem, if not, well it probably won't do it any good unless the protection diodes kick in and limit the voltage on the pin to a diode drop above the MCU's VCC (not all MCUs have protection diodes by the way), and even if the diodes do kick in, the MCU voltage is probably less than 12V so the fet won't actually turn off as the protection diodes will stop the gate being pulled all the way up to 12V. Would you be able to use an N-ch fet in a low side switching configuration instead? Or an N fet/NPN transistor to pull down the gate as Mkeith suggested?


This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .