Comprehensive ADC driver with interrupts and burst mode

10 Feb 2010 . Edited: 10 Feb 2010

Hi,

I've just written an ADC driver to make full use of the facilities described in the UM10360 LCP17xx User manual document from NXP.

Features include

  • ADC channels referred to by pin number (like ADCpin driver)
  • Sample rate can be set up to and beyond (with warning) limit
  • Interrupts with built-in interrupt handler
  • Append to or replace interrupt handler
  • Append interrupt handler for just a particular ADC pin
  • Burst mode operation

Here is the URL...

ADC_test

Enjoy!

Next challenge is to get it to work the the DMA. Looks a bit hairy so far :-O

08 Mar 2011

Hi,

Examined your code (trying it now) and one define seems wrong.

According to the lpc manual (user.manual.lpc17xx.pdf at page 574):

#define CLKS_PER_SAMPLE 64

should read:

#define CLKS_PER_SAMPLE 65

Btw DMA Mode is already covered by Andy (see http://mbed.org/forum/mbed/topic/1798/) but is has some major drawbacks for me (although it works like charm).

  1. Due to the fact that DMA transfers cannot be hardware triggered you're stuck with the 65 cycles and a 96Mhz Clock. There is no exactly rounded sample-time that can be derived from 96Mhz and 65 Cycles.
  2. In my code derived from Andy's the channel numbers are swapped (i.e. channel 1 data has channel 0 and vice versa). I have not been able to find the root cause.
11 Mar 2011

Hi Simon,

Can you turn this in to a public library?

28 Jun 2012

Hi Simon, I've been following along your comments on ADC spikes and tried out you ADC_test library. I expected to see a stable ADC output with it but don't do you have any sample output on what you get with it to see if I can troubleshoot the use I'm giving to it? I'm testing with a simple voltage divider from 3.3V.

Thank you!