Jessey
If you go look at the Datasheet Section 11-2 ADCON1 Register, you will find there's a table for bits 3 thru 1 (PCFG3 thru PCFG0). In the C/R column which shows the number of Analog Channels (C) viz Number of References (R). 2/1 fits your bill exactly (bit setting 0101), this gives you AN0 and AN1 for ADC, and your VRef on AN3 with everything else Digital.
Other things... bit 7 is the ADFM bit. 1=Right Justify for 10-bit ADC mode, 0=Left Justify for 8-bit mode.
For the 16F877A, bit 6 (along with two bits in ADCON0) set the Conversion Clock. Suppose you chose to use Fosc/8, you would leave this as zero. For the normal 16F877 (not the A version), this bit is unused and set to zero.
Bits 5 and 4 are unused, leave as zeros.
Therefore the setup for ADCON1 would be...
%10000101 for 10-bit ADC
%00000101 for 8-bit ADC
Bookmarks