1
\$\begingroup\$

Might come off as a trivial question but when does one use Pull up and Pull down as PUPDR register of the GPIO? I'd guess it's used to define the default state of the pin.

The following includes the image the push button on STM32F401 nucleo board. It's apparent that PC13 IO is pulled high via a pull up resistor in case the button isn't pressed.

enter image description here

So the IO pin as shown below is already pulled high, isn't it? Does it matter if PC13 is configured to be in Pull up or Pull down mode event?

enter image description here

Secondly, for the LED (LD2) that's connected on PA5: if the PUPDR of this pin is set to pull down, there's a pull down resistor (as shown in the IO image above) that's connected to PA5 and for pull up, there's a pull up to VDD? Assuming that's the case, shouldn't LD2 be "on" on start of the program if PUPDR is set to PULL UP? (doesn't seem to be the case with me)

enter image description here

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

From the datasheet, the value of both the pull up and pull down resistors is nominally 40K. (Note that often pull up and down values may be different.)

For the case of PC13, note the value of the external pull up resistor - 4K7. This is much lower than the internal pull resistors.

  • If the pull up is enabled, the resultant value is 4K7 || 40K, which is 4K2.

  • If the pull down is enabled, then it forms a voltage divider. Because the pull down is much greater than the 4K7, the input voltage will be above the high threshold.

They have probably put a stronger pull up here as they know it's going to be used for a switch, and has potential to pick up external interference. The capacitor C15 also helps in this regard.

For PA5, the value of the pull up resistor is so high that there will not be enough current to light the LED.

\$\endgroup\$
7
  • \$\begingroup\$ Sorry, what's the value of the input impedance of the MCU though? It's usually in mega ohms (not sure about STM series) but if that's the case, your point about not generating enough current to lit up the LED makes sense. (assuming pull up is enabled, you've got 40K and MCU's input impedance in series). Not sure about your explanation on push button, and how's 4K7 greater than the internal pull which is 40K \$\endgroup\$
    – MKD
    Jun 11, 2020 at 21:47
  • \$\begingroup\$ @Pokloha Sorry, typo in 4K7 > 40k. Added some more information. The input impedance is so large, it doesn't matter. It will be in parallel with the pull resistor, so the effective value is going to be ~40K. Does that make sense? \$\endgroup\$
    – awjlogan
    Jun 12, 2020 at 8:56
  • \$\begingroup\$ 40K || 4k7 ~ 4k7 and not ~40K though unless you're referring to something else? isn't this what it pretty much looks with for push button (tinyurl.com/yddcgj6h)? \$\endgroup\$
    – MKD
    Jun 16, 2020 at 2:00
  • \$\begingroup\$ If pull up is set, I see they're in parallel resulting in ~4k7 input impedance. if pull down is set, you get ~3.3V at the input pulling it high. I'm uncertain what happens when pull up is set and when neither pull up nor pull down is set (floating). isn't R30 there to pull the pin high anyways? \$\endgroup\$
    – MKD
    Jun 16, 2020 at 2:06
  • \$\begingroup\$ @Pokloha - that's what I wrote - 40K || 4K7 ~ 4K2. In your linked schematic, the 40K pull down should not be connected. R30 always pulls the pin high - as I mentioned in my answer, the reason they have this stronger pull up is that is on a pin that interfaces to the "world" (not another IC), and is more likely to be affected by interference. The stronger 4K7 pull up mitigates against that, whereas the 40K alone might not be strong enough. Does that answer your query? \$\endgroup\$
    – awjlogan
    Jun 16, 2020 at 8:44

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.