The key is in this function:
void readVOUT()Specifically
readDiff is the result of the ADC reading. Its a 12bit value that is then adjusted depending on the reference - either full or half of the 3.3V VDDANA. You will see several places in code doing something like this, calculating the actual VOUT based on the assumed reference value:
VOUT = readDiff*ldoOptimized*(BIAS?1:OUTPUT_CALIB_FACTOR);Here the
readDiff is the value from the ADC, then it is multiplied by ldoOptimized which is the 3300 (represents LDO value 3.3v adjusted by calibration and stored in EEPROM), or roughly half of that if the ADC reference is half VDDANA. This ldoOptimized is adjusted during the operation of CR, based on the mode and reference, in this function:
void ldoOptimizeRefresh() {
if (analog_ref_half)
ldoOptimized = (ldoValue*500)/ADCFULLRANGE;
else
ldoOptimized = (ldoValue*1000)/ADCFULLRANGE;
}
I hope this helps you, but make sure you know what you are doing
Also since this is qualifies as hacking .. while cool and interesting to watch ... no real support or warranty can be offered against any issues
Of course,
always save your current.uf2 firmware from the bootloader before you change anything (see guide)! Then you can revert if things go wrong.