Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit RBPU (OPTION<7>). The weak pull-up of a pin is automatically turned off when the port pin is configured as an output. This post shows how to enable PIC16F84A microcontroller PORTB internal pull-ups.
The following CCS C compiler line can enable all the internal pull-ups of PORTB:
And the following line can disable all the internal pull-ups of PORTB:
PIC16F84A enable PORTB internal pull-ups example:
The following topic shows how to turn on and off 2 LED using 2 push buttons where two 10K resistors are used to pull-up the microcontroller input pins.
PIC16F84A LED blink using push button – CCS C compiler
Now let’s make the same example with the internal pull-ups are enabled and the external ones are removed as shown in the following circuit schematic:
The circuit is simple there 2 LEDs and 2 buttons each button toggles one LED for example when the first push button which is connected to RB0 is pressed, the first LED which is connected to RA0 turns ON, and when the same button pressed again the same LED turns OFF, and the same thing for the second button and the second LED.
Enable PORTB internal pull-ups CCS PIC C code:
// PIC16F84A enable PORTB internal pull-ups example
port_b_pullups(true); // Enable PORTB internal weak pull-ups
if(input(PIN_B0) == 0)
if(input(PIN_B1) == 0)