SOLUTION: Make sure your power input is 200mV over the reference power source (that's a typical bandgap reference voltage required). So, 3.2V is required for a 3V reference.
I'm finishing up a embedded design with an 8051 MCU, and coding up the ADC to function as a battery voltage detector.
I noticed a strange anomaly, I'm sure there is a very easy explanation.
I power the MCU & circuit with a 3.7v Lipo battery (so it fully charges up to 4.2v and discharges to say 3.5v with the protection IC on it... something like that).
I have a voltage divider from the circuit power, that turns the input voltage going into the ADC input from a max of 2.483v max to 1.848v min.
I set the ADC to use 4v as the internal reference voltage. I assumed this would be fine since since the inputs from the voltage divider are below 4v.
I got all kinds of funky readings that are not consistent from a adjustable power supply. It's not a software issue combining the 12 bit results. The hardware is just putting out flucating values.
I thought maybe my adjustable power supply has a really noisy output, but looking at it with a scope the output isn't flucating around like crazy.
On a lark, I changed the internal reference to 3v and all of a sudden the readings are totally stable and respond as you'd think.
Is there some reason that the 3v reference voltage works so much better? Is the 4v reference voltage just too far off?
Maybe this is obvious -- could it be that the 4v reference isn't possible if the Lipo is at 3.7v? This is some really cheap Asian 8051, they don't really spell out how the AD reference voltages work.
I'm not 100% on the arithmetic of an AD, I could sit and noodle the step values of the 12bit AD, but I really just am curious if there is something obvious here why the AD readings didn't work well with the 4v voltage reference?