As you use a 16F877, why spending time and extra capacitor when life can be sooo much easier by using internal ADC on PORTA?

Look for ADCIN in the PBP manual and Section 11 of the datasheet.