AnsweredAssumed Answered

LPC1778 ADC problem

Question asked by Lorenzo Galbiati on Mar 21, 2018
Latest reply on Mar 21, 2018 by jeremyzhou

Hello,

I'm a newbie with LPC1778 and I'm facing a problem with ADC.

I have set ADC in single conversion mode and my acquisition routine is:

 

WORD ADC_GetSample(BYTE channel)
{
  WORD result;
  ADC_Init();
  AD0CR_bit.SEL=(1<<channel);                //one-hot code
  AD0CR_bit.START=1;                              //start conversion
  while (AD0GDR_bit.DONE==0);               //wait for end of conversion
  result=(WORD)AD0GDR_bit.RESULT;
  return result;
}

 

This works correctly it runs fast but it fails when the routine it interrupted by an interrupt or when I do a step-by-step debug in IAR.

In this two situations the DONE bit is always 0 and the wile loop never ends.

 

Why?

Has anyone found the same problem ?

 

Best regards.

Outcomes