Roger, for this to work you need to get rid of the LDO and feed a 4,5Volt battery pack to the PIC. That way you will measure the Vdd voltage in respect with the VP6 input to the ADC. There is no other way to do it.
Your configuration would be:
Code:
ADCON0=%10110101 ' Here we drive the 0,6 volts to the ADC
ADCON1=%00110000 ' I prefer to be sure to have FRC for the beginning at least
VRCON= %00010000 ' Enable the VP6 reference
Now if you want to measure the Vdd, just do this:
Code:
ADCON0.1=1
while ADCON0.1: wend
Bat_Value.Byte1=ADRESH:Bat_Value.Byte0=ADRESL
But remember, you have to drop the LDO and supply your circuit from the battery directly.
Ioannis
Bookmarks