Hi

I'm trying to get my LM336BZ-5.0 reference chip to work with my 16f877 micro and have a question regarding setting up the adcon1 register if anyone can help me. I'm using RA0 (pin 2) for an analog input of a varying voltage from a CMOS circuit & RA1 (pin 3) to read my battery voltage. I'm trying to figure out how to set the adcon1 register so I can use RA3 as a positive input from my reference chip and for the two AN0 & AN1 for my adc in's?

I'm using a pic pin so I will have the ability to turn the reference chip on/off in my code when needed via a 1.2K resistor to supply the +volts from the pic pin to the cathode of my reference chip which is also connected to RA3. I searched the archives for code to turn on the positive reference for RA3 and found the following example below:

> As an example, lets say you want to have a positive only reference on AN3 with the 7 other analog inputs useable and have a 10 bit result. You would set the adcon1 register as adcon1=%10000001 <

I read the data sheet and can't make head nor tail on setting the bits I need to accomplish this, below is the code that I'm using to read my adc inputs. I tried using adcon1=10000001 in place of ADCON1 = 2 but my 2 adc inputs won't function properly. Could someone please tell me how to set up the adcon1 to be able to do this? I'm assuming I need to turn on my ad converters as they seem to be off when I just use adcon1=%10000001.

Check_The_CMOS_Output_Voltage:
ADCON1 = 2 'turn on the AD Converters
ADCON0 = $41'Set A/D to Fosc/8, Channel 0, On
Gosub getad
Moist = ADRESH
ADCON1 = 7 'shut off (Disable) ADC
Return

Read_The_Battery_Voltage:
ADCON1 = 2 'turn on the AD Converters
ADCON0 = $49 ' Set A/D to Fosc/8, Channel 1, On
Gosub getad
Battery_Voltage = ADRESH
ADCON1 = 7 'shut off (Disable) ADC
Return

Any help would be greatly appreciated.
Thanks
jessey