PIC Microcontroller – Internal Pullup for Input

picpullup

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…

Best Answer

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.