'TI CC2541 adc voltage divider wrong values

I am working on a project with TI CC2541 (placed on a jdy-08 BLE module). I try to get a lipo battery level by using adc interface. I refered this post https://sunmaysky.blogspot.com/2013/12/cc2530-adc-howto-in-ti-z-stack.html?m=1 . To read adc value i use this code:

        uint16 adc_ain2=0;
        HalAdcSetReference(HAL_ADC_REF_125V);
        adc_ain2=HalAdcRead(HAL_ADC_CHN_AIN2,HAL_ADC_RESOLUTION_10);

If i dont use voltage divider and directly connect a voltage source to P0_2 pin there is no problem. eg:

0,35V ==> adc 170 
0,70V ==> adc 310
1,17V ==> adc 498

But if i use a voltage divider i get wrong values (R1 = 820K, R2 = 820K). eg:

0,33V ==> adc 347
0,53V ==> adc 368 

Thank you in advance!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source