mc9s12xep100 adc

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mc9s12xep100 adc

854 Views
chenchenchen
Contributor II

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.

0 Kudos
Reply
3 Replies

642 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

How do you read the results?

ATD0CTL2 = 0x80 is a typo, I suppose.

I have attached two examples for your reference.

 

Regards,

Daniel

0 Kudos
Reply

642 Views
chenchenchen
Contributor II

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);

}

0 Kudos
Reply

642 Views
danielmartynek
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply