Enable PIC16F877A PORTB internal pull-ups with CCS C compiler

Each of PIC16F877A microcontroller PORTB pins has an internal weak pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit RBPU (OPTION_REG<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on Power-on Reset.
This small article shows how to enable PIC16F877A PORTB internal pull-ups using CCS C compiler.

The following CCS C compiler line can enable all the internal pull-ups of PORTB:
port_b_pullups(true) ;
And the following line can disable all the internal pull-ups of PORTB:
port_b_pullups(false) ;

Enable PIC16F877A PORTB internal pull-ups example:
This is a simple example shows how to enable and use of the internal pull-ups of PIC16F877A. This example was done using external pull-ups resistors in the following topic:
PIC16F877A PORTB interrupt on change with CCS C compiler
In this example the same circuit is used without the external pull-up resistors as shown in the following circuit schematic:
Enable PIC16F877A PORTB internal pull-ups circuit
As we can see in the circuit above there are no external pull-up resistors connected with the microcontroller inputs.
Note that only PORTB has weak internal pull-ups.

Enable PIC16F877A PORTB internal pull-ups CCS C code:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.