With SC2[ACREN] =1, and if the value of CV1 is less than or equal to the value of CV2,then setting SC2[ACFGT] will select a trigger-if-inside-compare-range inclusive-of-endpoints function. Clearing SC2[ACFGT] will select a trigger-if-outside-compare-range, not-inclusive-of-endpoints function.If CV1 is greater than CV2, setting SC2[ACFGT] will select a trigger-if-outside-compare-range, inclusive-of-endpoints function. Clearing SC2[ACFGT] will select atrigger-if-inside-compare-range, not-inclusive-of-endpoints function.If the condition selected evaluates true, SC1n[COCO] is set.Upon completion of a conversion while the compare function is enabled, if the comparecondition is not true, SC1n[COCO] is not set and the conversion result data will not betransferred to the result register, Rn. If the hardware averaging function is enabled, thecompare function compares the averaged result to the compare values. The same comparefunction definitions apply. An ADC interrupt is generated when SC1n[COCO] is set andthe respective ADC interrupt is enabled, that is, SC1n[AIEN]=1.NoteThe compare function can monitor the voltage on a channelwhile the MCU is in Wait or Normal Stop modes. The ADCinterrupt wakes the MCU when the compare condition is met.34.4.6 Calibration functionThe ADC contains a self-calibration function that is required to achieve the specifiedaccuracy.Calibration must be run, or valid calibration values written, after any reset and before aconversion is initiated. The calibration function sets the offset calibration value, theminus-side calibration values, and the plus-side calibration values. The offset calibrationvalue is automatically stored in the ADC offset correction register (OFS), and the plus-side and minus-side calibration values are automatically stored in the ADC plus-side andminus-side calibration registers, CLPx and CLMx. The user must configure the ADCcorrectly prior to calibration, and must generate the plus-side and minus-side gaincalibration results and store them in the ADC plus-side gain register (PG) after thecalibration function completes.Prior to calibration, the user must configure the ADC's clock source and frequency, lowpower configuration, voltage reference selection, sample time, and high speedconfiguration according to the application's clock source availability and needs. If theChapter 34 Analog-to-Digital Converter (ADC)K22F Sub-Family Reference Manual, Rev. 4, 08/2016NXP Semiconductors 801