# Do we need a resistor to discharge capacitor of MOSFETs while connected to MCU?

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?

• 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? – Capn Jack Aug 24 '17 at 14:46
• 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. – Tut Aug 24 '17 at 15:03
• R2 is a pull down resistor, but what is R1 for? – Cano64 Aug 24 '17 at 18:58
• @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. – Zac Faragher Aug 25 '17 at 5:45

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)

• 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! – duskwuff Aug 24 '17 at 17:20
• @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. – Curd Aug 24 '17 at 19:42
• @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. – marcelm Aug 25 '17 at 8:40
• @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). – Curd Aug 25 '17 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.