BATMON has a 75 millivolt resolution:
Code:
/* Bandgap can't be measured against supply voltage in this chip. */
/* Use BATMON register instead */
BATMON = 16; //give BATMON time to stabilize at highest range and lowest voltage
...
for ( i=16; i<31; i++) {
BATMON = i;
if ((BATMON&(1<<BATMON_OK))==0) break;
}
bat=2550-75*16-75+75*i; //-75 to take the floor of the 75 mv transition window
|