The 16F690 has an internal 0.6V reference that can be turned ON/OFF from the VRCON register.
With VREF+ set to VDD, you can use the 0.6V reference to measure the PIC's VDD voltage. Which goes something like this ...The variable VDD now holds the VDD voltage *10 (3.3V = 33).Code:VDD VAR WORD VRCON.4 = 1 ; Turn 0.6V reference ON PAUSEUS 100 ; Allow VP6 to settle ADCIN 15, VDD ; get VP6 analog reading (10-bit) VRCON.4 = 0 ; Turn 0.6V reference OFF VDD = 6138 / VDD ; convert to voltage
The formula is the same for any VDD voltage.
Then ...This then tells you when the battery voltage has gone below the LDO's "Drop-Out".Code:IF VDD < 32 THEN GOSUB LowVoltage ; if less than 3.2V
Or you can set it to any other voltage (lower than normal VDD) as required.
hth,




Bookmarks