Hello all. I am very confused about how to use the ADC for a new board that I am putting together.
Whenever I use an ADC on a new design, I always ensure that my code is reading it properly, so I just setup the internal channels VrefH and VrefL channels to be read to verify that the 0x000 and 0x3FF (or thereabouts) are being read back consistently, and then I would change my code to switch between the various channels as necessary and go full-speed for my oversampling algorithms.
The problem I am having is that even though my voltage is steady (using a 5V switching supply for this part), my ADC inputs are all over the map, as low as 0x357 and upwards of 0x3FD. I have done something similar before with little jitter of perhaps 3-4 counts in a noisy environment.
Please let me know if there are any thoughts on this, as it is driving me nuts!
I have attached my code below.
APCTL1 = 0x04; //ADC2 is used as an ADC input.
ADCCFG = 0b00001000; //Clock Divide = Input Clock / 2, long sample time, 10-bit mode, input clock = bus-clock / 2.
ADCSC1 = 0x1D;