65.6.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 channels.

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).

The error correction for channels used with the touchscreen is available in the ADC Touchscreen Correction Values register (ADC_TSCVR).

The ADC_EMR.ADCMODE field is used to configure a running mode of the ADC Normal mode, Offset Error mode, or Gain Error mode (see ADC_EMR). ADCMODE uses 3 internal references 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 running mode of the ADC 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 table below 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 13
  • 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 65-5. 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
    GAINCORR = 3584 GCi ConvValue × 2 Gs

The final conversion result after error correction is obtained using the following formula:

Corrected Data = Converted Data + OFFSETCORR × GAINCORR 2 Gs