mc9s12xep100 adc

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

mc9s12xep100 adc

931 次查看
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 项奖励
回复
3 回复数

719 次查看
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 项奖励
回复

719 次查看
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 项奖励
回复

719 次查看
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 项奖励
回复