I have an STM32 MCU at home. I was thinking of controlling a load with this MCU and a MOSFET. Let's assume this is my circuit:


In this circuit, we use a resistor (R2) to discharge the gate of the MOSFET. Now let's look at the structure of the GPIO inside the STM32. Here is an image:


As you can see, there is an NMOS that when we change the output control to 0, the MCU will turn it on to connect the line to the ground. Now the question is: why should I use a resistor to discharge the capacitor of the MOSFET when there is an NMOS that can do it? Do I always need to put this resistor in?

  • \$\begingroup\$ Just a noob question totally unrelated: what would be the resulting impact if you were to remove R2, the 100k ohm one, from the circuit? \$\endgroup\$
    – Capn Jack
    Aug 24, 2017 at 14:46
  • \$\begingroup\$ One other point regarding a floating GPIO pin (commonly between reset and setting up the GPIO, but may also be common during programming and/or debug, or other): It is very possible for the floating pin to cause the MOSFET to be partially on which can cause many MOSFETs used for digital switching to fail. \$\endgroup\$
    – Tut
    Aug 24, 2017 at 15:03
  • \$\begingroup\$ R2 is a pull down resistor, but what is R1 for? \$\endgroup\$
    – Cano64
    Aug 24, 2017 at 18:58
  • \$\begingroup\$ @Cano64 R1 is a current limiting resistor. A mosfet gate is basically a capacitor, so it has 0 resistance when you first turn it on and will draw infinite current - in theory of course. This could burn out drivers (or MCU pins) if the current draw is too high. \$\endgroup\$ Aug 25, 2017 at 5:45

3 Answers 3


One good reason is to have this resistor to keep the gate low if the MCU pin is in high impedance state (e.g. during reset or after reset until the port is initialized).

(Otherwise during high impedance state it could act as an antenna and pick up some voltage that turns it on)

  • \$\begingroup\$ Or if an error in the MCU (either a software bug, or a hardware bit-flip error) happens to switch the pin to an input mode. Unlikely, but possible! \$\endgroup\$
    – user39382
    Aug 24, 2017 at 17:20
  • \$\begingroup\$ @duskwuff: basically agree, but if this is really your concern you should find additional protection mechanisms because such an error could also cause the MCU to turn the output high although it should be low. Probably just as (un-)likely, but possible. \$\endgroup\$
    – Curd
    Aug 24, 2017 at 19:42
  • 1
    \$\begingroup\$ @Curd That is not the main concern. With low MCU output, the FET is fully off, no current flows through, no power dissipated. With high MCU output, the FET is fully on with low Rds. Current flows but voltage drop over the FET is small, so power dissipation is in check. With a floating gate, the FET may be in its linear region with a moderate Rds. Depending on the load, this could cause high current to flow at a large voltage drop, dissipating far more power in the FET than the circuit accounts for, thermally destroying it. \$\endgroup\$
    – marcelm
    Aug 25, 2017 at 8:40
  • \$\begingroup\$ @marcelem: yes, protecting the MOSFET from beeing turned half way on can also be one concern; but if this is of higher concern than avoiding the MOSFET to turn completely on when it is supposed to be off depends much on the context (e.g. if the solenoid controls starting a nuclear missile ;-). In that case I'd rather just have the MOSFET destroyed; hopefully fails open). \$\endgroup\$
    – Curd
    Aug 25, 2017 at 9:04

During normal operation there is no need for the resistor.

However you may want it to put the FET into a known state during power up and reset. Otherwise on power up before the MCU starts to drive the pin the FET could turn on. This could cause glitches on the output or worst case (and this is very unlikely) depending upon what other current surges happen on startup it could cause the power supplies to brown out and crash the MCU.


MOSFET works on the principle of charging and discharging of the (effective) capacitance between the gate and source. Now when you charge the MOSFET and then introduce high impedance, the charge is retained (and this often happens in power MOSFETs). When the gate is tied to ground via a resistor, this ensures that the residual charge is grounded and the MOSFET will not conduct. Sometimes not using the ground resistor may cause erratic results in the system and may also lead to current surges due to shorting.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.