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 |