⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
Wally
Offline
Last seen:6 days 22 hours ago
Joined:2016-06-21 01:23
ADC difference mode

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);

Device:
PM_Dialog
Offline
Last seen:1 day 11 hours ago
Staff
Joined:2018-02-08 11:03
Hi Wally,

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

Wally
Offline
Last seen:6 days 22 hours ago
Joined:2016-06-21 01:23
This article does not help me

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?

PM_Dialog
Offline
Last seen:1 day 11 hours ago
Staff
Joined:2018-02-08 11:03
Hi Wally,

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