This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541 ADC inaccuracy

Other Parts Discussed in Thread: CC2541, TPS62730

I'm trying to use the on board ADC for the CC2541 and I'm getting inaccurate results. I've included results at the end of this post. To test the device I used a potentiometer and a HP 34401A DMM. I tried taking measurements with the internal reference and the AVDD5 pin. I am using P0.6 as my ADC input

code:

ADCCON = 0x33;

ADCCFG |= 0x40;

ADCCON3 = 0x06 | 0x30 ;  OR ADCCON3 = 0x06 | 0x30 | 0x80 ; for using AVDD5 pin as a reff  

while (!(ADCCON1 & HAL_ADC_EOC));

ADCCFG = 0;

reading = (int16) (ADCL);
reading |= (int16) (ADCH << 8);

reading >>=4;

I calculate the result with result = reading/0x7ff*2.1 OR  result = reading/0x7ff*1.24 for using AVDD5 pin as a reff  

My Vcc is 2.116 from the TPS62730

My results:

Internal Vreff AVDD5
DMM ADC Reading Calculated V diff DMM ADC Reading Calculated V
1.23 1457 0.8821679688 0.3478320313 2 1828 1.888695313
1.09 1234 0.7471484375 0.3428515625 1.8 1546 1.597332031
1 1095 0.6629882813 0.3370117188 1.62 1293 1.335931641
0.94 998 0.6042578125 0.3357421875 1.4 1025 1.059033203
0.8 819 0.4958789063 0.3041210938 1.21 827 0.8544589844
0.7 685 0.4147460938 0.2852539063 1.1 718 0.7418398438
0.62 591 0.3578320313 0.2621679688 1.02 644 0.6653828125
0.5 470 0.2845703125 0.2154296875 0.81 474 0.4897382813
0.4 366 0.2216015625 0.1783984375 0.61 331 0.3419902344
0.3 273 0.1652929688 0.1347070313 0.41 212 0.2190390625
0.2 183 0.1108007813 0.08919921875 0.2 102 0.1053867188
0.1 110 0.0666015625 0.0333984375 0.1 57 0.05889257813
0 13 0.01343164063
  • I have recreated the issue on two of my own boards and TI's Keyfob Demo. TI was put extra test pins on a test header. The only modification I made was soldering on wires for Vbat, GND and P0.6 from the test header. I used the TI demo code with the code posted above in an infinite while loop after  HalDriverInit();

  • Hello Peter,

    Taking a single reading from the ADC will never give you an accurate result.  Your options would be to take at least 10 readings and then average them.  You can also implement a simple filter where you take three reading and discard the highest and lowest values.

    Thanks,

  • even if you average tens of samples, the on chip 14bit ADC never will be acurate as a MDD, unless you use an external 24 bit ADC.

  • I agree with ke fan on the accuracy of the on board ADC.  However, you can still get very good precision from it.  I have used it for a thermocouple temperature controller and the results were very good.

    The DMM may give you the true value, but the ADC will give you a value that if you add a correction factor, both measurements will be the same.  This is true for 0 to 3.3V.  The key is a large ground plain with minimal trace leads.

  • Like you said, the ADC is very precise. I get similar results every time. 

    The problem was the pull up/down setting was sabotaging my readings. After setting P0INP |= BV(6); (sets 3-state) my results were accurate. Using AVDD5 as a reference gave the best results. I feel quite silly about this mistake. 

    Thank you for sharing your insights with me.


    From the User's Guide "The settings in the APCFG register override the settings in P0SEL." I read this and assumed the APCFG took care of all GPIO settings. 

  • Here's the updated results. Still not very good, but they aren't as bad. The readings are almost 0.1V off in some places

    DMM intReff AVDD5
    0 0.001 0.003
    0.11 0.12 0.12
    0.2 0.21 0.21
    0.4 0.41 0.4
    0.6 0.62 0.6
    0.8 0.81 0.79
    1.01 1.01 0.98
    1.11 1.1 1.08
    1.3 1.26
    1.4 1.35
    1.61 1.54
    1.81 1.73
    2 1.93
    2.09 2.01
  • You would have to compare it with the calibration certificate for your DMM to really know how bad it is.  But like they say, it is good enough for government work!

  • The numbers make sense when you consider that the ADC has an input impedance. I was using a 50K pot to vary the voltage and I wasn't factoring in the parallel resistance to ground. It works :D