I need to drive a MOSFET (IRFZ44N) with a microcontroller (dsPIC33FJ64MC202). The problem is, the PIC runs at 3.3V and the FET's Vgs(th) lies between 2V and 4V, so there will be times my PIC won't turn it on. But, the PIC has some 5V tolerant pins. How can I use them?

The datasheet says:

Up to 5.5V output with open drain configuration on 5V tolerant pins with external pull-up.


11.2 Open-Drain Configuration

In addition to the PORT, LAT and TRIS registers for data control, some port pins can also be individually configured for either digital or open-drain output. This is controlled by the Open-Drain Control register, ODCx, associated with each port. Setting any of the bits configures the corresponding pin to act as an open-drain output. The open-drain feature allows the generation of outputs higher than VDD (e.g., 5V) on any desired 5V tolerant pins by using external pull-up resistors. The maximum open-drain voltage allowed is the same as the maximum VIH specification.

It seems so obvious but I still don't get it... How do I wire this circuit? What code do I need to make this work?

Note: I can't change either of those components. That's what I've got to work with.

  • 1
    \$\begingroup\$ Even if you have a 5V supply available, I would suggest getting a better MOSFET, the one you have needs 10V drive to reach the guaranteed Rds(on) levels. Either that or use a driver to increase the gate voltage to >= 10V. \$\endgroup\$ Commented Sep 18, 2019 at 14:28
  • \$\begingroup\$ @SpehroPefhany it's ok, I've got all that covered. I just need to know how to use it. I didn't ask for anything else. Thanks anyway \$\endgroup\$
    – Iaka Noe
    Commented Sep 18, 2019 at 14:32
  • \$\begingroup\$ Sure, keep in mind that answers should be generally useful not just for specific special cases, and most folks generally want to do things properly. \$\endgroup\$ Commented Sep 18, 2019 at 14:38
  • \$\begingroup\$ @SpehroPefhany Exactly, that's why I'm asking about driving 5V and not about getting the best out of my MOSFET. (For everyone who reads this:) If you want to know which is the best MOSFET to use in this case scenario, you're at the wrong place. \$\endgroup\$
    – Iaka Noe
    Commented Sep 18, 2019 at 14:44

1 Answer 1



simulate this circuit – Schematic created using CircuitLab

R1 is a pull up resistor which you provide. M1 is the transistor within the PIC and the drain is internally not connected (thus open drain).

You need to choose R1 and the size will depend on how fast you need to switch your device on and off. A higher value resistor will lead to slower transition times (in particular output rise time). There will be a time constant formed by the resistor and the gate capacitance of your MOSFET. I suggest simulating as the choice of resistor is highly implementation dependent.

A typical good start for R1 in general purpose switching control is 10k.

To drive the pin high, set the pin to be an open drain output (as indicated in the text you have - the specifics will be in the reference manual) and write a '1' to that register bit.

What voltages are permitted at the pin will be in the device data sheet; you could simply bring up the 5V behind the 3.3V. A 5V tolerant pin will be 5V tolerant for input or output. Most microcontrollers have the pins set to inputs at reset.

  • \$\begingroup\$ But how can I program the PIC to output a logic 1 correctly as 5V? I came up with setting it as an input (and it'd go high impedance) but I don't think that's the method they're talking about in the datasheet. \$\endgroup\$
    – Iaka Noe
    Commented Sep 18, 2019 at 14:32
  • \$\begingroup\$ Answer updated to address pin configuration. \$\endgroup\$ Commented Sep 18, 2019 at 14:37
  • \$\begingroup\$ @IakaNoe, the PIC is either pulling the output to ground, or it isn't. When it's not being pulled to ground by the PIC, it will go to whatever level the resistor is connected to. Since the outputs are 5V-tolerant, I suggest you not connect it to anything over 5V. \$\endgroup\$ Commented Sep 18, 2019 at 14:42
  • \$\begingroup\$ @CristobolPolychronopolis probably there is some setup (something to do with the OCDx register?) to do this. Normally, if the pin is set to high, it will give out 3.3V and since it's connected to 5V through a resistor it'll just set some voltage drop through the resistor and that's it... \$\endgroup\$
    – Iaka Noe
    Commented Sep 18, 2019 at 14:45
  • \$\begingroup\$ @PeterSmith Thanks! I knew it was a bit obvious, but I wasn't sure about this "open-drain" thing. \$\endgroup\$
    – Iaka Noe
    Commented Sep 18, 2019 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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