Hi,
I'm experiencing problem with ADC2 internal calibration.
At initialisation of my program I start the calibration of both ADC, one after the other, and the ADC2 calib value seems always wrong. If I re-execute the calibration few seconds later I get another calibration offset for ADC2..
Here's the code I'm executing at initialization:
void DrvAdc::AdcCalibrate( )
{
// Enable calibration mode (When this bit is set, the analog input channel multiplexer
// is disconnected and the calibration reference voltage is connected to
// the ADC core input)
regADCPtr->calCR.bit.calEn = 1;
// Clear HILO
// Clear bridge enable
// => Voltage Reference = (ADRefHi*R1 + ADRefLo*R2) / (R1 + R2)
regADCPtr->calCR.bit.hilo = 0;
regADCPtr->calCR.bit.bridgeEn = 0;
// Value used to sum all result.
uint32_t calSum = 0;
// Calibration offset error...
//for( uint16_t acq = 0; acq < 8; acq++ )
{
// start calibration conversion (single conversion)
regADCPtr->calCR.bit.calSt = 1;
// Wait until calibration is finished
while( regADCPtr->calCR.bit.calSt != 0 );
// read back result
calSum += regADCPtr->calR.bit.adCalR;
}
// Calc mid-point calibration
// Set HILO
// => Voltage Reference = (ADRefLo*R1 + ADRefHi*R2) / (R1 + R2)
regADCPtr->calCR.bit.hilo = 1;
// Calibration offset error...
//for( uint16_t acq = 0; acq < 8; acq++ )
{
// start calibration conversion (single conversion)
regADCPtr->calCR.bit.calSt = 1;
// Wait until calibration is finished
while( regADCPtr->calCR.bit.calSt != 0 );
// read back result
calSum += regADCPtr->calR.bit.adCalR;
}
// Divide by 2 (1 volt ref + 1 volt ref) to get mid-point
// We add 0x1 to round up the value. (Ex: For 16 acq, add 8/16(0,5))
calSum = (calSum + 0x01) >> 1;
// Calculate the compensate offset and apply it
regADCPtr->calR.bit.adCalR = (0x800 - calSum);
// Disable calibration and write back to 0 all other calibration variables
regADCPtr->calCR.bit.calEn = 0;
regADCPtr->calCR.bit.hilo = 0;
regADCPtr->calCR.bit.bridgeEn = 0;
regADCPtr->calCR.bit.calSt = 0;
}
Here's the register adCalR values
After a power ON:
ADC1: adCalR = 4087
ADC1: adCalR = 854
If I re-execute the calibration after initialization:
ADC1: adCalR = 4087
ADC1: adCalR = 1189
Is it normal that both ADC calibration offset values are so different?
Is there a stabilisation time to wait before executing ADC calibration after a power-ON reset?
Thanks
David.