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 change interrupt
In this example the same circuit is used without the external pull-up resistors as shown in the following circuit schematic:
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:
// PIC16F877A enable RB weak internal pull-ups
// http://ccspicc.blogspot.com/
// electronnote@gmail.com
#include <16F877A.h>
#use delay(crystal=8000000)
byte i;
#INT_RB
void rb_isr(void)
{
i = input_b();
output_d(i >> 4);
}
void main()
{
set_tris_b(0xF0);
port_b_pullups(TRUE);
clear_interrupt(INT_RB);
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
while(TRUE) ; // Endless loop
}
Reference:
PIC16F877A datasheet