ADC strange behaviour

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Genesy on Fri Nov 15 10:21:05 MST 2013
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) {


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

uint32_t count=0;

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

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