15
\$\begingroup\$

I am working with STM32 micro-controllers. These micro-controllers have the option to set the input pin as pull up or pull down:

enter image description here

Earlier I used to give external pull up or pull down resistor wherever required but now I am wondering whether I can do away with external components and use the pull down feature of the micro-controller itself.

Will that be a good thing to do?

Is there some use case where I should take extra precaution or not use this feature at all?

\$\endgroup\$
8
  • 2
    \$\begingroup\$ I use the internal pu/pd whenever I can and had no problems sofar. So unless you have a valid reason not to use the build-in pull up/down you can just use them. A reason not to rely on the internal pu/pd could be that the input has a long wire connected to it which might couple to other lines causing unexpected behavior. The internal pu/pd is quite weak (to save current) and is more easily disturbed than for example a 10 kohm resistor. \$\endgroup\$ Commented Nov 22, 2016 at 9:46
  • 25
    \$\begingroup\$ A little note: it may not function as a pullup while the microcontroller is resetting. So if there's external circuitry depending on it being pulled down all the time, you may have a problem at startup. If it's just being read by the micro, this is not a problem. \$\endgroup\$
    – pjc50
    Commented Nov 22, 2016 at 10:18
  • 1
    \$\begingroup\$ @pjc50 you should have posted that as an answer, I didn't notice your comment until after I posted my answer. \$\endgroup\$
    – Jason S
    Commented Nov 22, 2016 at 13:48
  • 1
    \$\begingroup\$ If you can't trust the pull up resistor in a microcontroller, you can't trust anything in that controller. What you want to know is if it's useful though \$\endgroup\$
    – Passerby
    Commented Nov 22, 2016 at 18:23
  • 1
    \$\begingroup\$ @Whiskeyjack: You should consider changing the questions title. Maybe "Considerations when using internal pull-up/down resistors" or something like that. \$\endgroup\$
    – Rev
    Commented Nov 23, 2016 at 19:15

5 Answers 5

18
\$\begingroup\$

Yes... You can... It's a proven feature. If you see pin structure in STM32 Reference manual, you can see that it has required components --

STM32 Pin structure

If this satisfies your requirements, then, you can do away with external components.

Edit Remember that at Power up, Pins will be tristated. If it does not hamper your application, it is good! That's why it's good practise to init IO section first and then go ahead with other peripherals.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Right, but still during reset it is tristated right? \$\endgroup\$ Commented Nov 23, 2016 at 6:15
  • 3
    \$\begingroup\$ I answered for question "Should I trust pull down feature of micro-controller?" and now question itself changed :-/ And with new question, Bence Kaulics answer is more accurate! \$\endgroup\$
    – Swanand
    Commented Nov 25, 2016 at 7:55
  • \$\begingroup\$ Question: will using a bunch of internal pullup/down resistors cause the chip to heat up? \$\endgroup\$ Commented Nov 26, 2016 at 8:01
18
\$\begingroup\$

In general, it is perfectly fine to use the internal pull-up or pull-down resistors.

Disadvantage is that you can forget to enable it from software, that can cause a little headache. The external pull-ups will always be there. So do not forget to enable the internal ones and save a lot of PCB area by reducing component number.

The STM32's internal pull-up and pull-down resistors usually have a value between \$ 30\small~k\Omega \$ and \$ 50\small~k\Omega \$.

enter image description here

You should always check if your application needs a certain pull-up or pull-down resistor value before using the internal resistors. For example do not use them with I2C, as these values will be too high for that.

\$\endgroup\$
14
\$\begingroup\$

Unless the pullup and pulldown resistors are active during reset (I suspect they aren't, but I'm not familiar with STM32 devices), there is an undefined pin state at reset. This is one major reason to use external pullup or pulldown resistors.

\$\endgroup\$
10
\$\begingroup\$

As others have said, internal pull-ups and pull-downs are fine as long as:

  • you remember to configure them,
  • they are strong enough,
  • you do not end up fighting them with an external pull, and
  • the voltage at start-up and reset is unimportant.

On the last point, remember that CMOS inputs at mid-voltage level can cause significant shoot-through current on their input pair. This can cause a problem in a low power system during start-up.

In general, external pull resistors will yeild a more conservative design.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ With regard to shoot-through currents, it might be helpful to put things in perspective by noting that for most microcontrollers the levels are generally far below anything that would cause damage to a device, but they may be orders of magnitude above a device's best-case sleep currents. In some cases, such currents don't matter; in others they're an absolute killer. \$\endgroup\$
    – supercat
    Commented Nov 22, 2016 at 15:41
  • 1
    \$\begingroup\$ +1 for "the voltage at startup and reset is unimportant". You need to guarantee that the rest of your circuit is in a safe and quiescent state while the micro is starting up. This is harder than it looks, when you consider that a reset or fast power-cycle may leave the rest of your circuit in an indeterminate state, or leave it powered up and running without the micro keeping an eye on it. \$\endgroup\$
    – Graham
    Commented Nov 23, 2016 at 12:09
5
\$\begingroup\$

In addition to the other fine exceptions listed in all the answers, the internal pull-up resistors are too weak for I²C in many cases.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ ... case in point: What happens if I omit the pullup resistors on I2C lines? \$\endgroup\$ Commented Nov 22, 2016 at 21:19
  • \$\begingroup\$ Of course, some (many?) microcontrollers have open-drain pins specifically for I2C that you can configure \$\endgroup\$
    – Thomas
    Commented Nov 23, 2016 at 8:02
  • 2
    \$\begingroup\$ I haven't seen anything but weak pull ups/downs, @Thomas \$\endgroup\$ Commented Nov 23, 2016 at 11:33

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.