Im new in PIC world. I want to ask:

Do I need external pullup resistor for switches and encoders?

When I was using Atmel microcontrollers - I was just turning on internal pullup resistors in software.

In PIC18F25k50 datasheet I found information, that RB port pins are:

"Digital Output or Input with internal pull-up option"

So I assume that some ports may have internal pullups and I have to check datasheet. However I don't know what resistance is there and I can't find it in datasheet.

I'm asking because in many tutorials I see external pullups, so there must be some reason...

  • 2
    \$\begingroup\$ Why -1? What's wrong with my question? \$\endgroup\$ – Kamil May 3 '14 at 19:48
  • \$\begingroup\$ -[in many tutorials I see external pullups, so there must be some reason...]- Not all PICs have internal pull-ups. \$\endgroup\$ – Chris Johnson May 4 '14 at 9:49

It's not a resistance per se. Normally they would use a MOSFET rather than a resistor, since resistors take more area.

enter image description here

The minimum current (25uA at 5.0V or 3.3V Vdd) is pretty low, and the range is quite large (more than 10:1 at 5.0V Vdd). So nominally, it's about equivalent to a 39K resistor, but it could be as much as 200K equivalent at 3.3V, or as low as 16.5K. That will also mean that the time constant of an external capacitor connected to the input with pullup enabled can vary over a 10:1 range.

In some situations that might be insufficiently immune to noise, or the time constant insufficiently well-defined and you'd want to turn the pull-up off and use an external resistor (it's always preferable to use an external resistor alone rather than paralleling the two because any resistor you would likely buy will be at least 10 times more accurate than the built-in pullup).

See the answers here: Weak internal pullups on microcontrollers and EMI susceptibility

In other situations, the maximum current of 0.3mA could negatively affect battery life and you'd want to use a higher-value external resistor and turn off the pull-up.

  • \$\begingroup\$ I think it's more about low power consumption, not area needed for resistors. \$\endgroup\$ – Kamil May 4 '14 at 12:24
  • \$\begingroup\$ @Kamil The appropriate current or value of resistance is known- it's in the 10's of K ohms. Much lower and it will draw too much current for general purpose use. Much higher and it won't be an effective pullup (noise, leakage). There are tolerances and area costs with each method. The problem is that it has to be almost free since few users will use all the pull-ups and all users have to pay for all the pullups (and the value is maybe 0.002 cent per used pullup for a high-volume customer). Low-Idss MOSFETs are cheaper than relatively high-R resistors. \$\endgroup\$ – Spehro Pefhany May 4 '14 at 12:33

The answer is:


For SPST devices, having a pullup simplifies the circuit since all that is required externally is to tie the other end of the device to ground. When the contact closes the input is pulled low and the pin reads as 0. SPDT devices don't need a pullup since they switch between VCC and GND.

Parameter D158 in the "Electrical Characteristics" section specifies the pullup strength via current rather than resistance.


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.