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?
Hi Chris Pflieger,
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
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.