I use the following code to test the voltage of P0/0 and P0/1,My purpose is to measure the P0/0 voltage first, then measure the P0/1 voltage, and finally measure the differential voltage between P0/0 and P0/1.
The results are as follows:
P0/0 = = = = = = = = P0/1 = = = = = = = = difference mode
0=========== 0 ============ 255
1023======== 0 ============ 1023
0 ========= 1023 =========== 0
1023======= 1023 ========== 511
My understanding is: 1023 is +1.2V, and 0 is -1.2V. 511 is 0V,But when P0/0 and P0/1 are both 0V, why is its difference value not 511, but 256?
When the pressure difference is 0V, shouldn't it be 511?
Test code:
adc_calibrate();
adc_init(GP_ADC_SE,GP_ADC_SIGN,0);
adc_usDelay(20);
adc_enable_channel(ADC_CHANNEL_P00);
adc_value1 = adc_get_sample();
adc_usDelay(1);
adc_calibrate();
adc_init(GP_ADC_SE,GP_ADC_SIGN,0);
adc_usDelay(20);
adc_enable_channel(ADC_CHANNEL_P01);
adc_value2 = adc_get_sample();
adc_usDelay(1);
adc_calibrate();
adc_init(0,0,0);
adc_usDelay(20);
adc_enable_channel(0x0000);
adc_value3 = adc_get_sample();
adc_usDelay(1);
Hi Wally,
Regarding how differential ADC mode works, please check the previous post on the forum.
https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-%E2%80%93-hardware-device-reference-designs/trying-make
Thanks, PM_Dialog
This article does not help me much. My main problem is that when two pins are all connected to 0V, why are the results 255, sometimes 768, and shouldn't it be 511?
Hi Wally,
I dont think that you will be able to measure values of zero voltages when using the differential functionallity of the ADC and having both adc ends set to zero, because you are operating the adc on his limits. Simply put, the internal comparator has too low voltage on both ends and is unable to determine which of the two voltages is higher. Even having one of the ends of the ADC in zero volts would result in inaccurate values.
Thanks PM_dialog