40.5.5.2 Dedicated Digital Comparator

The ADC module has a dedicated Digital Comparator that can alert the application to the capture and conversion of input signals that match predefined criteria. When an input conversion produces a “hit” the flag INTFLAG.CMPHIT is set, which can optionally fire the interrupt if INTENSET.CMPHIT is set. The index, k, of the input channel that produce the “hit” is identified in the INTFLAG.CMPINTID field.

The Digital Comparator must be enabled by setting CMPCTRL.CMPEN. Recall that only input channels having the associated CHNCMPENk bit set are included in the comparator scans.

The CMPCTRL register supports these comparisons directly:

  • bit 29 IEHIHI: Enable Comparison - High Limit, Active High:

    Setting this bit compares if ADCMPHI ≤ ADC value

  • bit 28 IEHILO: Enable Comparison - High Limit, Active Low:

    Setting this bit compares if ADC value < ADCMPHI

  • bit 15 IEBTWN: Enable Comparison - Active Between Limits:

    Setting this bit compares if ADCMPLO ≤ ADC Value < ADCMPHI

  • bit 14 IELOHI: Enable Comparison - Low Limit, Active High:

    Setting this bit compares if ADCMPLO ≤ ADC Value

  • bit 13 IELOLO: Enable Comparison - Low Limit, Active Low:

    Setting this bit compares if ADC Value < ADCMPLO

Note:
  1. The Digital Comparator works on the final value of the filter data.
  2. When using channel using FRACT (16bits left justified) the lower 4 bits are ‘0, therefor in this mode 15:4 will be in 11:0 and user must account for the lower 4 bits of 0’s.
  3. When the results value is of greater resolution than 12 bits, the comparison is only performed on the upper 12 bits of the results value to the contents of CMPCTRL.*.

The user is responsible for formatting the data in ADCMPHI[11:0] as signed or unsigned to match the data format as specified by the SIGNy and FRACTy bits for all the analog input channels y which are enabled by CHNCMPENy. See Section “Output Data Formats” for a table of all 16-bit output data formats.

Setting more than one of the IE* bits creates the and of the selected conditions. This can cause ambiguity and may create undesired results. Select only a single condition to insure correct operation.