I’m developing software for embedded systems for medical supposes. In my latest project, I need to read the ADC value for 6 channels of LPC1768 ADC unit.
I’m having some problems though. The ADC gives me some random conversions even when I connect the ADC pin to ground.
Here is my code:
Is your problem similar to this:
I think Pekka’s advice may be a little to the point, however the LPC1768 ADC function instability has been reported several times over the years.
If you are using the original Mbed LPC1768 board, the Vdda supply does not have the best filtering circuit and the design of the board itself could have an issue with adjacent component RFI noise, chips on both sides of the board and multi layer PCB is not a good thing here.
Depending on how accurate/stable you need the ADC function, it may pay to design your board with a separate ADC converter chip.
But first I would recommend to try a different platform, I have had good results with the ADC on Freescale(NXP) targets, KL25z,K22F and K64F do work well. Also the ST’s work well particularly I have used the STM32L476 with good ADC results.
Also taking an average of a series of ADC measurements, removing the highest and lowest values first, will give a more accurate reading.