application uses the ADC in a wide variety of configurations, the configuration for whichthe highest accuracy is required should be selected, or multiple calibrations can be donefor the different configurations. For best calibration results:• Set hardware averaging to maximum, that is, SC3[AVGE]=1 and SC3[AVGS]=11for an average of 32• Set ADC clock frequency fADCK less than or equal to 4 MHz• VREFH=VDDA• Calibrate at nominal voltage and temperatureThe input channel, conversion mode continuous function, compare function, resolutionmode, and differential/single-ended mode are all ignored during the calibration function.To initiate calibration, the user sets SC3[CAL] and the calibration will automaticallybegin if the SC2[ADTRG] is 0. If SC2[ADTRG] is 1, SC3[CAL] will not get set andSC3[CALF] will be set. While calibration is active, no ADC register can be written andno stop mode may be entered, or the calibration routine will be aborted causingSC3[CAL] to clear and SC3[CALF] to set. At the end of a calibration sequence,SC1n[COCO] will be set. SC1n[AIEN] can be used to allow an interrupt to occur at theend of a calibration sequence. At the end of the calibration routine, if SC3[CALF] is notset, the automatic calibration routine is completed successfully.To complete calibration, the user must generate the gain calibration values using thefollowing procedure:1. Initialize or clear a 16-bit variable in RAM.2. Add the plus-side calibration results CLP0, CLP1, CLP2, CLP3, CLP4, and CLPS tothe variable.3. Divide the variable by two.4. Set the MSB of the variable.5. The previous two steps can be achieved by setting the carry bit, rotating to the rightthrough the carry bit on the high byte and again on the low byte.6. Store the value in the plus-side gain calibration register PG.7. Repeat the procedure for the minus-side gain calibration value.When calibration is complete, the user may reconfigure and use the ADC as desired. Asecond calibration may also be performed, if desired, by clearing and again settingSC3[CAL].Functional descriptionKL27 Sub-Family Reference Manual , Rev. 5, 01/2016376 Freescale Semiconductor, Inc.