15.4.14.1.2 Application of Error Compensation Coefficient

To compensate for the gain error, each ADC result should be multiplied by the calculated coefficient. The compensation can be done as either a fixed-point or floating-point multiplication. The floating-point calculation is shown in ADC Conversion Result Correction Using Floating-Point Calculations.

This operation may take up to 105 nS if the CPU clock is 200 MHz. The multiplication can be accelerated if the fix-point calculation is used as shown in 12-bit Unsigned ADV Conversion Result Correction Using Fixed-Point Calculations

ADC Conversion Result Correction Using Floating-Point Calculations

float coefficient = 3840.0/adc15div16result; // needed to be done once
……
// takes 21 instruction cycles or 105 nS @ 200 MHz CPU clock
long corrected_result_channel_0 = (long)(coefficient*((float)AD1CH0DATA));

12-bit Unsigned ADV Conversion Result Correction Using Fixed-Point Calculations


unsigned long coefficient = (unsigned long) ((1<<19)*3840.0/adc15div16result)); // needed to be done once
……
// takes 6 instruction cycles or 30 nS @ 200 MHz CPU clock
unsigned long corrected_result_channel_0 = (coefficient*AD1CH0DATA)>>19;