4.5.5.1 Low-Pass Filter Operation

The LPF can be considered as having two main processes that work in succession: an initial averaging process followed by a continuous filtering operation.

The initial averaging process begins by accumulating samples until the ADC Count register (ADCNT) is equal to the ADRPT register. During this initial accumulation process, each new sample is added into the accumulator. After each sample is added, the accumulator right-shifts (divides) its current value by the value of the ADC Accumulated Calculation Right Shift Selection (CRS<2:0>) bits of the ADCON2 register. The new right-shifted value appears in the ADFLTR registers. When ADCNT = ADRPT, a threshold comparison test is performed on the ADFLTR value. During this initial averaging process, the ADRPT value acts as an RC time constant, allowing the computed average to reach a steady state before performing a threshold comparison. This prevents threshold tests on each sample until after an average has been established, which helps to reduce 'false alarm' threshold violations due to random variations of a single sample.

Once the initial averaging process completes, the module moves into continuous filtering operation. The figure below explains what happens during continuous filtering operation.
Figure 4-17. Continuous Filtering Operation Flowchart

Equation 4-1 explains the ADFLTR calculation in mathematical terms. It is important to note that the accumulator is not cleared after the initial averaging process, or after any subsequent conversion, but instead continues to accumulate samples until software disables the module. During continuous filtering operation, ADRPT is ignored, ADCNT continues to count until ADCNT = 0xFF (ADCNT is ignored after reaching 0xFF), and the CRS value continues to act as the accumulator divider.

Equation 4-1. ADFLTR Calculation in LPF Mode
A D F L T R = A C C N E W 2 A D C R S

Where:

A C C N E W = ( A C C P R E V + A D R E S ) A C C P R E V 2 A D C R S

ACCPREV – Previous accumulator result

ADRES – Current conversion result