Average Mode

Average mode is very similar to Accumulate mode in the sense that the ADACC register trio accumulates with each new conversion, increments ADCNT, and updates the ADFLTR register pair with the right shifted value of ADACC. In Average mode, the number of accumulated conversion results depends on the value of the ADC Repeat Setting Register (ADRPT). This register holds the number of samples that are to be accumulated.

The value of ADRPT should be set based on the number of right shifts that will be performed to get the average of the accumulator data (see Figure 1). Once ADCNT is equal to ADRPT, a threshold test is performed on the ADFLTR value, and ADTIF may be set depending on the threshold settings. The next trigger event clears ADCNT and ADACC, and the conversion result is recorded as sample number one.

Table 1 gives an Average mode example. In this case, the CRS<2:0> bits of ADCRS are set to a value of 2. Based on Figure 1, the RPT<7:0> bits of ADRPT should be loaded with the value of 4. This means that four samples will be taken, and the accumulated value after the four samples are taken will be right shifted by two places, or a divide by 4.

Figure 1. Number of Samples Calculation
ADRPT=2ADCRS
Table 1. Average Mode Example
ADCRS ADRPT ADCNT ADRES ADACC ADFLTR Threshold Test Performed?
2 4 1 500 500 125 No
2 4 2 500 1000 250 No
2 4 3 500 1500 375 No
2 4 4 500 2000 500 Yes
2 4 1 500 500 125 No