Spurious ADC values

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

Spurious ADC values

746 Views
chrispflieger
Contributor IV

LPC 1227 running at 36 MHz and I need to sample a DC signal, so roughly 1/10 second will be fine, no IRQ required.

The problem is I see a lot of spurious values coming from the ADC - I have a buffer of 36 recent values, and nine are just way out of bounds - like should be ~24600 but some are ~32000 and some below 1000.

The setup code:

   LPC_IOCON->R_PIO0_30 = 0x00000003;
   LPC_SYSCON->PDRUNCFG      &= ~( 1ul <<  4 ); // Power up ADC block
   LPC_SYSCON->SYSAHBCLKCTRL |=  ( 1ul << 14 ); // Enable PCLK to ADC
   LPC_ADC->CR = 0x001010400 | (ENABLED_CHANNELS);     // set for burst mode with a 36MHz clock.

The sample code:

    while ((LPC_ADC->GDR & 0x80000000) == 0);
    result = (uint16_t)((LPC_ADC->GDR & 0x0000FFC0) >> 6);

I assume there's some weird sampling problem because of burst mode, but is there something I need to do to synchronize sampling?

Labels (1)
2 Replies

537 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Chris Pflieger,

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

To provide the fastest possible support, I've attached a ADC demo and please refer to it for details.

Have a great day,
TIC

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

537 Views
chrispflieger
Contributor IV

There's my problem. Even though I'm only looking at one channel, LPC_ADC->GDR gives wonky values, but LPC_ADC->DR[0] doesn't.

0 Kudos