I am using the MCF52259 micro to sample 8 channels. The ADC results fluctuate (several hundred counts) even though the analog inputs are rock solid. The VDD have some ripples (~25mV) and VDDA and VREFH have <5mV ripples. So I don't think that problem lies with supply voltage. I am using the ADC in once sequential mode with auto power down. I re-arm the ADC every 250ms. Any idea why the results are unstable? Here is my ADC code:
void AdcInit(void) {
MCF_ADC_CTRL1 = MCF_ADC_CTRL1_SMODE(0); /* once sequential scan mode */
MCF_ADC_CTRL2 = MCF_ADC_CTRL2_DIV(47);
MCF_ADC_POWER = MCF_ADC_POWER_PUDELAY(13) | MCF_ADC_POWER_APD | MCF_ADC_POWER_PD2;
}
void AdcTask(void) {
for(;
{
MCF_ADC_CTRL1 |= MCF_ADC_CTRL1_STOP0;
/* start conversion */
MCF_ADC_CTRL1 &= ~MCF_ADC_CTRL1_STOP0;
MCF_ADC_CTRL1 |= MCF_ADC_CTRL1_START0;
delay for 250ms
}
}
I also played around with different ADC clock values (from 10 to 63). I found that different clock values yield different ADC results with the same input level. Shouldn't the ADC result be independent of the clock? I also noticed that the fluctuation worsen with higher clock frequency.
Any help is greatly appreciated.