LPC1778 ADC problem

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

LPC1778 ADC problem

652 Views
lorenzogalbiati
Contributor I

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.

Labels (3)
0 Kudos
1 Reply

475 Views
jeremyzhou
NXP Employee
NXP Employee

Hi  Lorenzo Galbiati,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.

I'd highly recommend you to operate the register directly instead of bit field way, please giving a try.

Have a great day,
TIC
 
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
0 Kudos