ADC strange behaviour

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

ADC strange behaviour

1,067 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Genesy on Fri Nov 15 10:21:05 MST 2013
Hi,
as the title, I have a strange behaviour with ADC.
The program is this:
static uint32_t ADCChannelAcquisition(uint8_t channel){
ADCRead( channel );
while ( !ADCIntDone );
ADCIntDone = 0;
return ADCValue[channel];
}

int main(void) {

SystemInit();
ADCInit( ADC_CLK );

int i;
uint32_t val=0;
uint32_t acquisition[10];

uint32_t count=0;

//for (i=0; i<100000; i++){
//count++;
//}

for (i=0; i<10; i++){
acquisition = ADCChannelAcquisition(0);
}

for (i=0; i<10; i++){
val += acquisition;
}

uint32_t valRif = (uint32_t)(((float)val  / 10.0) + 0.5);


return 0 ;
}

The behaviour is different if I insert a breakpoint in the first acquisition as you can see in the attached images.
In the first case the values ​​are higher than in the second case. What is the reason?
What values ​​are reliable?

I tried to insert a delay before making ADC readings, but nothing has changed.

Thank you very much
标签 (1)
0 项奖励
回复
4 回复数

1,043 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Genesy on Tue Nov 19 01:37:01 MST 2013
Ok, I will try with your suggestions.
The ADC input is a voltage divider from a hall effect sensor.

Thank you very much Marc.

0 项奖励
回复

1,043 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Mon Nov 18 12:11:47 MST 2013
Have you tried with a long delay in the seconds range (like your breakpoint does)?
100*1000 loops isn't that much nowadays ;-)

Also, are you sure, the loop is executes as expected? I believe so, too. But to be 100% sure, declare count 'volatile'.
What is the input circiut to your ADC? Voltage divider?
0 项奖励
回复

1,043 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Genesy on Mon Nov 18 01:51:54 MST 2013
Yes, I also thought that it could be a matter of timing and I inserted a short delay but wasn't enough.
Than it should be this late?
0 项奖励
回复

1,043 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Sat Nov 16 06:26:50 MST 2013
Just a guess: before Init the port pin is GPIO with pullup.
The you switch to ADC input and start sampling within a few us. Pretty short time!
Can your excess reading be the removed pullup-current + low-pass behaviour?
0 项奖励
回复