ADC returns incorrect values


I am getting odd samples from TSC_ADC, definitely I am missing something. Can you help me to figure out what I am missing, please?

I am using a beagle bone black industrial by element14, debian 8.6, code composer studio v7, and this header. Sampling is done in this code, which send data to an ARM task counterpart which displays values on stdout.
The aim is to understand how to sample via TSC_ADC. :slight_smile:

Currently, I am sampling a channel (i.e. inp = AIN6 = 1.6V, double checked with multimeter and oscilloscope) via TSC_ADC. This channel is sampled in single-ended mode and in differential mode (i.e. inm = AIN0 = GND ADC ).
In order to do that, I am using 2 steps of TSC_ADC (i.e. from STEP1 and STEP2): the first step has differential mode enabled (i.e. STEP1 ), while the other step has single-ended mode enabled (i.e. STEP2). All steps averaging is set to 4 (i.e. 16 samples).

The resulting samples expressed as decimals are about:

  • 1600 from STEP1;
  • 1950 from STEP2.

These samples should be converted as 1.6V, but they do not by using official “formula”. For example, 1.6 / 4095 * 1.8 = 3640.

What I am doing wrong? : \

In order to enable the sampling, the following setps are done in such order in this code: CTRL register is set to 6, STEP1 & STEP2 Averaging is set to 4, STEP 1 Diff_CNTRL is set to 1, STEP1 & STEP2 SEL_INP_SWC_3_0 is set to 6, STEP1 SEL_INM_SWC_3_0 is set to 0, STEPENABLE register is set to 6, and CTRL register is set to 7.

Best regards,

P.S. I double checked samples values by using BB-ADC as described here. However, values are still incorrect. For example, AIN0 returns 3870-ish, which should be instead 0 (as single-ended on GND ADC); AIN6 returns 3150-ish.

Finally, I figured out what was the issue… I thought that it was the ADC which had some damage, but actually ADC and software were fine; there were two issues in the 1.8V scaling circuit… ouch!