SNIU028D February 2016 – September 2020 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138A , UCD3138A64
It is possible to average 2, 4, and 8 EADC samples. There are two modes of EADC Averaging – consecutive and spatial. It is true averaging – the samples are added and then divided by the number of samples. There is also a weighted average available.
Consecutive mode takes the specified number of samples immediately after the sample trigger, at the EADC sample rate of 16 or 8 MHz. It then triggers the Filter and provides the average of the samples as the filter input.
Spatial mode takes one sample for each sample trigger, and sends averaged data to the filter after the specified number of sample triggers.
The average error value can also be read from the EADC Value register:
eadc_error = FeCtrl0Regs.EADCVALUE.bit.ERROR_VALUE;
This value will reflect the averaging value if averaging is enabled. Otherwise it will be the same as the raw EADC value mentioned earlier.
Averaging is controlled with the EADC control register. To select Averaging mode, write a 1 into the EADC_MODE bits:
FeCtrl0Regs.EADCCTRL.bit.EADC_MODE = 1; //averaging mode
There are 3 bits, giving a total of 8 modes, all of which will be discussed later in this section.
The simplest mode is mode 0 – 1 sample, no averaging.
To select spatial mode, write a 1 to the AVG_SPATIAL_EN bit:
FeCtrl0Regs.EADCCTRL.bit.AVG_SPATIAL_EN = 1; //spatial averaging mode
A 0 in this bit will select continuous mode.
To select which number of samples to average, use the AVG_MODE_SEL bits. They work as follows:
0 = 2x Averaging (Default)
1 = 4x Averaging
2 = 8x Averaging
FeCtrl0Regs.EADCCTRL.bit.AVG_MODE_SEL = 2; //select 8X averaging
There is also a weighted average control bit available, which gives more weight to the most recent samples. See Section 3.8 for details.