31.5 Computation Operation

The ADC module hardware is equipped with post conversion computation features. These features provide data post-processing functions that can be operated on the ADC conversion result, including digital filtering/averaging and threshold comparison functions.

Figure 31-11. Computational Features Simplified Block Diagram
The operation of the ADC computational features is controlled by the ADMD 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 (ADDSEN = 0) or double (ADDSEN = 1) samples. ADIF is set after each conversion is complete.
  • Accumulate: With each trigger, the ADC conversion result is added to the accumulator and ADCNT increments. ADIF is set after each conversion. ADTIF is set according to the calculation mode.
  • Average: With each trigger, the ADC conversion result is added to the accumulator. When the ADRPT number of samples have been accumulated, a threshold test is performed. Upon the next trigger, the accumulator is cleared. For the subsequent tests, additional ADRPT samples are required to be accumulated.
  • Burst Average: At the trigger, the accumulator is cleared. The ADC conversion results are then collected repetitively until ADRPT 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 ADRPT 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-4. Computation Modes
Register Clear EventValue after Cycle(2) CompletionThreshold OperationsValue at ADTIF Interrupt
ModeADMDADACC and ADCNTADACC(1)ADCNTRetriggerThreshold TestInterruptADAOVADFLTRADCNT
Basic0ADACLR = 1UnchangedUnchangedNoEvery SampleIf threshold=trueN/AN/Acount
Accumulate1ADACLR = 1S1 + ADACC

or

(S2-S1) + ADACC

If (ADCNT=FF): ADCNT, otherwise: ADCNT+1NoEvery SampleIf threshold=trueADACC OverflowADACC/2ADCRScount
Average2ADACLR = 1 or ADCNT>=ADRPT at ADGO or retriggerS1 + ADACC

or

(S2-S1) + ADACC

If (ADCNT=FF): ADCNT, otherwise: ADCNT+1NoIf ADCNT>=ADRPTIf threshold=trueADACC OverflowADACC/2ADCRScount
Burst

Average

3ADACLR = 1 or ADGO set or retriggerEach repetition: same as Average

End with sum of all

samples

Each repetition: same as Average

End with ADCNT=ADRPT

Repeat while ADCNT<ADRPTIf ADCNT>=ADRPTIf threshold=trueADACC OverflowADACC/2ADCRSADRPT
Low-pass Filter4ADACLR = 1S1+ADACC-ADACC/
2ADCRS

or

(S2-S1)+ADACC-ADACC/2ADCRS

If (ADCNT=FF): ADCNT, otherwise: ADCNT+1NoIf ADCNT>=ADRPTIf threshold=trueADACC OverflowFiltered Valuecount
Note:
  1. S1 and S2 are abbreviations for Sample 1 and Sample 2, respectively. When ADDSEN = 0, S1 = ADRES; When ADDSEN = 1, S1 = ADPREV and S2 = ADRES.
  2. When ADDSEN = 0 then Cycle means one conversion. When ADDSEN = 1 the Cycle means two conversions.