18
\$\begingroup\$

Are pull-up/down resistors (whether internal or external) only needed for MCU INPUT pins? In contrast, an MCU pin configured as an OUTPUT "knows what level it's at" because it does the driving - a "floating" MCU OUTPUT pin tied to some input of another circuit doesn't make sense, because the state of the MCU pin can only be high or low... do I have this right? Now, upon MCU bootup or failure, it may be beneficial to have a pull-up/down tied to this "MCU output to IC input" line to ensure that the input to some IC is never floating.

Maybe I just answered my own question here... pull-up/down resistors can be used on both input and output pins, depending on application?

\$\endgroup\$
21
\$\begingroup\$

Pull-up and Pull-downs are normally used to ensure a line has a defined state while not actively driven. They are used on inputs to prevent floating lines, rapidly switching between high and low and a middle "undefined" region. Outputs normally do not need them.

But most mcu pins are GPIO, and sometimes on startup are defined as inputs instead of outputs. As you said, sometimes you don't want an IC pin input floating on startup, especially like a reset pin that you would normally drive with your microcontroller's GPIO.

This is when you use a Weak Pull-up or Pull-down on the line. Because they are weak, and you choose the default state, they provide no interference with your circuit (If the input is supposed to be low at all times, then pulled high, you choose a weak pull-down, and vis versa), but they do consume a bit of current. This is why you choose a resistor weak (Higher the value, the weaker) enough for the job.

Another normal output setup that uses pull-ups (or pull-downs, rarer) is Open Drain or Open Collector connections. These only drive a connection low, or release the line, leaving it floating. The pull-ups are used to bring the line to a high logic state.

\$\endgroup\$
  • \$\begingroup\$ You mention Open Drain and Open Collector connections, these don't apply to microcontrollers do they? Merely Mosfets being used to set a logical level? I wanted to clarify whether or not a microcontroller can drive a line which has a pull down resistor high. \$\endgroup\$ – genericpurpleturtle Oct 16 '17 at 12:00
9
\$\begingroup\$

You have it about right; normally you don't need pullups on outputs, but they can be useful to maintain safety during boot time etc.

One other reason for using a pull-up on an output : if several outputs from several MPUs are connected to each other, you really don't want one driving VCC and another driving 0V on the same wire! So you either drive 0V on the output or turn the output off (perhaps by configuring it as an input). When all the outputs are off, the wire is pulled to '1' (Vcc) by the pullup. This is called a "wired AND" signal. (You can do the same driving '1' or off, with a pulldown R, then it is called a wired OR).

This pattern has several uses including allowing any one MPU to signal an error or turn an LED on, or allowing them all to take turns sending messages to each other on a single wire.

\$\endgroup\$
4
\$\begingroup\$

As you stated, using pullup/pulldown resistors on pins expected to be output pins can be there to guarantee an input state.

This is done to mitigate firmware/MCU failure, but will only work to protect against Hi-impedance state (basically the pin is configured as input by accident).

Most MCU's I am familiar with default IO pins to high-impedance input state on boot (but no guarantee, and I do not have experience with anywhere near all MCU families), which means it can take some time before the code to initialize the pin state is executed.

Sometimes this doesn't matter, other times it does.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the answer, which compliments the other answers as well! FYI, the PIC24F series defaults the GPIO pins to high-impedance (input) upon reset (I/O pin datasheet). \$\endgroup\$ – The_Ders Feb 19 '13 at 23:16
3
\$\begingroup\$

The answer is it depends on the microcontroller family, and what it's default behavior is on Power On Reset. If the microcontroller can only be configured for "output" or "input" on a pin, this usually means it is using a Totem-Pole driver for output - which is to say it's essentially the output of a CMOS gate, in which case the output is always driven to a rail, so there's no reason to passively influence it. The only case where it makes sense to use pull-ups / pull-downs on an output is when it is configured as Open Collector / Open Drain topology. It's far more common to see internal pull-up/pull-down options that are only applicable when a pin is configured as an input. If you can guarantee that in your system the input is always driven by something, this wastes a bit of power.

\$\endgroup\$
  • \$\begingroup\$ Great explanation at the hardware-level. Thank you! \$\endgroup\$ – The_Ders Feb 19 '13 at 23:13
2
\$\begingroup\$

You can have a pin which is an output some of the time, such as for doing I2C.

\$\endgroup\$
  • \$\begingroup\$ I'll keep this in mind when working with I2C in the future. I believe with the PIC24F series, the I2C module assumes full control over the pins and the lines require external pull-ups. Now I know why this is - the I2C module is essentially configuring the data pin as open-drain/collector output (requiring a pull-up resistor) or high-impedance input, depending on whether data is being outputted/inputted from/to the I2C module... do I have this right? I'm not that familiar with I2C. \$\endgroup\$ – The_Ders Feb 19 '13 at 22:52
  • \$\begingroup\$ That's exactly right. \$\endgroup\$ – pjc50 Feb 20 '13 at 9:48
  • \$\begingroup\$ I2C is one instance of the wired-AND pattern. Open collector makes it simple as you could with a GPIO pin. \$\endgroup\$ – Brian Drummond Feb 20 '13 at 10:44

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.