HI
I use mc9s12xep100 adc function, this my configuration for adc.
void ADC_Init()
{
ATD0CTL1 = 0x20;
ATD0CTL2 = 0x80;
ATD0CTL3 = 0x78;
ATD0CTL4 = 0xA3;
ATD0DIEN = 0x00;
ATD0CTL5 = 0x30;
}
now, when I read data from register ATD0DR1, ATD0DR2,ATD0DR3,ATD0DR8,ATD0DR9,ATD0DR10,ATD0DR11. I found that data result is fluctuant. ex: ATD0DR1 right value is 450,but I read value that is 15 occasionally.
HI
void ADC_Init()
{
ATD0CTL0 = 0x0F;
ATD0CTL1 = 0x20;
ATD0CTL2 = 0x40;
ATD0CTL3 = 0x00;
ATD0CTL4 = 0xA3;
ATD0DIEN = 0x00;
ATD0CTL5 = 0x30;
}
if(ATD0STAT0_SCF == 1) {
ad_data[0][cnt] = (UINT16)(ATD0DR1 >> 6);
ad_data[1][cnt] = (UINT16)(ATD0DR2 >> 6);
ad_data[2][cnt] = (UINT16)(ATD0DR3 >> 6);
ad_data[3][cnt] = (UINT16)(ATD0DR8 >> 6);
ad_data[4][cnt] = (UINT16)(ATD0DR9 >> 6);
ad_data[5][cnt] = (UINT16)(ATD0DR10 >> 6);
ad_data[6][cnt] = (UINT16)(ATD0DR11 >> 6);
}
Hi,
Please try discharging the internal sample capacitor before sampling (ATDCTL1[SMP_DIS]).
Also, if you select ATDCTL3[DJM = 1], the data in the result registers will be right-justified.
So, there is no need to shift the results.
Regards,
Daniel