Role of Pull-Up/ Pull-Down Resistors in Microcontroller Interfacing

Thread Starter

MTech1

Joined Feb 15, 2023
161
Microcontrollers operate using logic high (usually 5 volts) and logic low (zero volts).

I've observed that these resistors are necessary when interfacing with external devices like push buttons or I2C devices.

I've come across information about pull-up and pull-down resistors in various sources, but I still don't grasp why they are necessary in certain situations with microcontrollers and external devices.

Updated : speling mistakes
 
Last edited:

MaxHeadRoom

Joined Jul 18, 2013
28,692
MCUs usually don't have actual pull-up resistors but rather MOSFETs sinking a small current, so their equivalent resistance value can vary wildly depending on the signal you apply to the pin.
The Mosfet takes up less space than a Resistor equivalent.
 

Ya’akov

Joined Jan 27, 2019
9,169
If you leave a GPIO pin floating on an MCU the state of that pin can be influenced by environmental noise and other stray fields. Pull ups and downs force the pin into a definite default state when the external device is not asserting anything.

Many MCU have internal pull ups/downs under software control so you won’t see a resistor on pins where that is being used. Some devices will take definite control of the pin state and not float, so you wouldn’t need one in that case either.

It’s all about making sure the pin is definitely in a known state when the signal from the device it is connected to is not present. Those pins could be active high where the logical high operates the function (notated with an overbar, e.g. \( \over \mathsf{ENABLE} \) for an active high ENABLE pin) or active low where the pin must be pulled down below the logical low threshold.

In each case, were you to connect the pin directly to VCC or 0V, you wouldn’t be able to change the state. The resistor limits the current so that a connection you make can overcome the bias it creates.
 

Xenon02

Joined Feb 24, 2021
500
Hello !

About pull up and pull down resistors they are quite handy in some applications.
What do I mean is like if you have a logic gate like OR gate. One leg of that logic gate is connected to "1" and the other one is unconnected.
Now the question is what will the OR gate do ? Usually if there are two high signals then it returns a high output, if we have two low signals input then we have 0 output, and if we have High and low signal input we then have High output.

In this situation if input is unconnected it is not "0"/Low state, or "1"/High state, it is uncertain state/unknown. That's why we add pull up/pull down resistor to give a certain logic state on the input of the devices.
 

Ya’akov

Joined Jan 27, 2019
9,169
By the way, this isn‘t correct:

Microcontrollers operate using logic high (usually 5 volts) and logic low (zero volts).
A logical high will be some voltage ranging from a certain percentage of VCC—which might be 5V, but could also be 3.3V or 1.8V—up to VCC + some amount. Similarly, logical low will be some range lower than high down to 0V - some amount (as understood by the device). The datasheet for your device will have the information.

Here’s an example from Microchip’s ATTiny85:

1705687058425.png
 

Papabravo

Joined Feb 24, 2006
21,225
Pullup resistors are used when a device has open collector(drain) outputs to define the logic high value if it is different than the Vcc for the device. Pulldown resistors are seldom used in TTL designs because TTL inputs will source current when they are low. CMOS inputs do not suffer from this condition. In most cases, for inputs, they are there to avoid floating inputs.
 

geekoftheweek

Joined Oct 6, 2013
1,218
One important pin is the Reset/MCLR This pin has no internal pull-up and must not be left unconnected.
There is a weak pull up on many of the PICs I have worked with although they still recommend an external pull up to combat slow power up ramps. 18(L)F2x/4xK22, 18(L)F1xK50, 18F24/25Q10, and I'm sure if I glance through the datasheets I have on hand I'll find more. It's usually mentioned in the first paragraph in the MCLR section of the datasheet if it has the pull up.
 

MrChips

Joined Oct 2, 2009
30,819
Pullup and pulldown resistors are not just for MCU inputs or outputs. It applies to gates, particularly to meet the input requirements of the input.

1705703308152.png

1705703339593.png


What you need to know is the input current required to satisfy proper logic LOW and logic HIGH levels. This information is contained the device datasheet.

For example in the top schematic, closing the switch presents a logic HIGH at the input. When the switch is not closed the pulldown resistor has to sink current and bring the input voltage below the VIL threshold voltage.

Conversely, in the bottom schematic, the pullup resistor has to source current and bring the input voltage above the VIH threshold voltage.

To determine the value of the resistance,

Rpulldown = VIL / IIL

Rpullup = (Vin - VIH) / IIH

Then select a resistance lower than the calculated value to provide a margin of error.
 
Top