SLAA475A October 2010 – March 2019 MSP430L092
For ADC conversions that use the ADC ramp mechanism, it can make sense to use the internal digital filter to get more stable values. To do so, the digital filters must be triggered each time the measurement method is changed. Similar to the comparator function, the application must provide an additional write to LCMP of the APCNF register. The following code shows how this can be done.
#include "msp430l092.h"
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
APCNF = CMPON+DBON+CONVON+APREFON+DFSET_1;
// Enable comparator on +
// Enable DAC buffer +
// Enable conversion +
// Enable reference +
...
.
...
_BIS_SR(GIE); // Switch on global interrupts
APCTL = APPSEL0+APPSEL2+OSEL+CBSTP+SBSTP;
// Set DAC buffer output to PSEL +
// Enable DAC buffer +
// Enable conversion +
// Enable reverence +
// Select output buffer +
// Enable Comparator based stop +
// Enable Saturation based stop +
APCNF |= LCMP; // Trigger filter again
APCTL |= RUNSTOP; // Start conversion
_BIS_SR(LPM0); // Go to LPM0
...
As a side effect, the filter can increase the deviation of the measured values depending on the selected filter settings. This must be taken into account when using these measured values. These filter methods also manage any possible deviation from the filter itself.
When the SAR logic is used for measurement, filtering is not useful, because of the way the SAR logic works. Wrong measurement values are the consequence of using filters in combination with the SAR logic.