31.4 Computation Operation

The ADC module hardware is equipped with post-conversion computation features. These features provide post-processing functions such as digital filtering/averaging and threshold comparison. Based on computation results, the module can be configured to take additional samples or stop conversions and an interrupt may be asserted.

Figure 31-6. Computational Features Simplified Block Diagram
The operation of the ADC computational features is controlled by the MD bits.

The module can be operated in one of five modes:

  • Basic: This is a Legacy mode. In this mode, ADC conversion occurs on single (DSEN = 0) or double (DSEN = 1) samples. ADIF is set after each conversion is complete. ADCHxIF is set according to the Calculation mode.
  • Accumulate: With each trigger, the ADC conversion result is added to the accumulator and ADCNT increments. ADIF is set after each conversion. ADCHxIF is set according to the Calculation mode.
  • Average: With each trigger, the ADC conversion result is added to the accumulator. When the RPT number of samples have been accumulated, a threshold test is performed. Upon the next trigger, the accumulator is cleared. For the subsequent tests, additional RPT samples are required to be accumulated.
  • Burst Average: At the trigger, the accumulator is cleared. The ADC conversion results are then collected repetitively until RPT samples are accumulated and finally the threshold is tested.
  • Low-Pass Filter (LPF): With each trigger, the ADC conversion result is sent through a filter. When RPT samples have occurred, a threshold test is performed. Every trigger after that, the ADC conversion result is sent through the filter and another threshold test is performed.

The five modes are summarized in the following table.

Table 31-2. Computation Modes
ModeMDRegister Clear EventValue after Cycle(1) CompletionThreshold OperationsValue at ADCHmIF Interrupt
ADACC and CNTADACCADCNTRetriggerThreshold TestInterruptAOVADFLTRADCNT
Basic0ACLR = 1UnchangedUnchangedNoEvery SampleIf threshold=trueN/AN/Acount
Accumulate1ACLR = 1S1 + ADACC or (S2-S1)(2) + ADACCIf (ADCNT = 0xFF): ADCNT, otherwise: ADCNT+1NoEvery SampleIf threshold=trueADACC OverflowADACC/2CRScount
Average2ACLR = 1 or ADCNT ≥ ADRPT at GO set or retriggerS1 + ADACC or (S2-S1) + ADACCIf (ADCNT = 0xFF): ADCNT, otherwise: ADCNT+1NoIf ADCNT ≥ ADRPTIf threshold=trueADACC OverflowADACC/2CRScount
Burst Average3ACLR = 1 or at GO set or retriggerEach repetition: same as Average End with sum of all samplesEach repetition: same as Average End with ADCNT = ADRPTRepeat while ADCNT < ADRPTIf ADCNT ≥ ADRPTIf threshold=trueADACC OverflowADACC/2CRSADRPT
Low-pass Filter4ACLR = 1S1 + ADACC-ADACC/
2CRS or (S2-S1) + ADACC-ADACC/2CRSIf (ADCNT = 0xFF): ADCNT, otherwise: ADCNT+1NoIf ADCNT ≥ ADRPTIf threshold=trueADACC OverflowADACC/2CRS (Filtered Value)count
Note:
  1. When DSEN = 0, Cycle means one conversion. When DSEN = 1, Cycle means two conversions.
  2. S1 and S2 are abbreviations for Sample 1 and Sample 2, respectively. When DSEN = 0, S1 = ADRES; when DSEN = 1, S1 = ADPREV and S2 = ADRES.