5.2.5.14 Automatic Error Correction
The ADC features automatic error correction of conversion results. Offset and gain error corrections are available. The correction can be enabled for each channel and correction values (offset and gain) are the same for all channelsprogrammable per channel.
To enable error correction, the corresponding ECORRx bit must be set in the Channel Error Correction register (ADC_CECR). The offset and gain values used to compensate the results are the same for all correction-enabled channels and programmed in the Correction Values register (ADC_CVR) set on a ‘per channel’ basis using the Correction Select register (ADC_COSR) and the Correction Values register (ADC_CVR). ADC_COSR is used to select the channel to be displayed in ADC_CVR. This selection applies to both the read and the write operations in ADC_CVR.
ADC_EMR.ADCMODE is used to configure a running mode of the ADC Normal mode, Offset Error mode, or Gain Error mode (see ADC_EMR). ADCMODE uses two internal references (ADVREFP, GNDIN33) to be measured and to extract the offset and gain error from 3 point-measurement codes. If some references already exist on the final application connected to some input channel ADx, they can be used as a replacement of the ADCMODE to generate the 2 or 3 points of calibration and used to extract the GAINCORR and OFFSETCORR.
After a reset, the ADC running mode is Normal mode. Offset Error mode and Gain Error mode are used to determine values of offset compensation and gain compensation, respectively, to apply to conversion results. The following table provides formulas to obtain the compensation values, with:
- OFFSETCORR—the Offset Correction value. OFFSETCORR is a signed value.
- GAINCORR—the Gain Correction value
- GCi—the intermediate Gain Compensation value
- Gs—the value 15
- ConvValue—the value converted by the ADC (as returned in ADC_LCDR or ADC_CDR)
- Resolution—the resolution used to process the conversion (either RESOLUTION, RESOLUTION+1 or RESOLUTION+2).
Table 5-4. ADC Running Modes ADC_EMR.ADCMODE Mode Description 0 Normal Normal mode of operation to perform conversions 1 Offset Error For unsigned conversions: OFFSETCORR = ConvValue − 2(Resolution − 1) For signed conversions: OFFSETCORR = ConvValue 2 Gain Error GCi = ConvValue 3
The final conversion result after error correction is obtained using the following formula: