I already have driver written, but the raw ADC count is differ in between 10-20 count.
So might be we are missing something in the logic.
If we have sample driver code,
We are using below configuration for ADC
- Single Shot
- Software trigger
You will always have a smaller or bigger fluctuation, first and foremost due to thermal noise which exists always.
You may also have other sources of noise as Hossein mentioned, and as a result there will be an overall error of the ADC.
On your device the overall error is ensured to be < 3.5 LSB and has a typical value of 1.2 LSB.
Also, please make sure you do not have any floating analog input as they can induce noise in an adjacent analog input. Please follow section 2.3 section on how to handle unused pins.
I can see P23 pin is floating, so if I set this pin to High by software, then does this will work?.
if you have instruction to set this pin to High then please provide me.
What pin is P23 ? If it is unused, then follow the instructions on section 2.3.
Is it the analog pin you are reading ?
Currently this pin is not connected to anything. That is just unused.
The Pin 23 is Analog pin
As per section 2.3 it is requesting to short with VSS or VDD with external circuitry.
But my question is, can we connect it to internal pull up register (by software) and does this will work ?
Please see section 2.3 for unused pins.
An analog pin should not be left floating. The difference of your ADC result is more than reasonable if it is left floating. You should connect this pin somewhere (ground, VDD, input voltage)