⚠️
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
MintCandy5
Offline
Last seen:11 months 1 week ago
加入:2017-05-03 09:26
ADC sample with GP_ADC_ATTN3X

We're trying to read the voltage from a resistor divider (NTC thermistor and a fixed R). We use P01(single end) and the reference voltage is 3.6V. We set GP_ADC_ATTN3X, we find the result is different from what we suppose. We find Figure 55 of the datasheet, but we have some problems. When we set GP_ADC_ATTN3X to 1, how does the above switch connect? If we set it to 1, can we think P01 always parallel 300KOhm resistance ( 200K + 100K )? If we set it to 0, dose P01 connect to the ADC module directly (no any parallel resistance)?

Attachment:
Device:
PM_Dialog
Offline
Last seen:1 day 18 hours ago
工作人员
加入:2018-02-08 11:03
Hi MintCandy5,

Hi MintCandy5,

Could you please share the ADC configuration and initialization? Did you set the GP_ADC_ATTN3X bitfield to 1 and GP_ADC_SE to 0?

Thanks, PM_Dialog

MintCandy5
Offline
Last seen:11 months 1 week ago
加入:2017-05-03 09:26
Hi, thank you for your

Hi, thank you for your response. We sample it as the ADC example in SDK, which samples the battery voltage. They're as below:

temp_en( true ); // set P07 to high, which we use as the power of the sample circuit

adc_calibrate();
adc_init(GP_ADC_SE, GP_ADC_SIGN, ADC_REF_VOLTAGE);
adc_usDelay(20);

adc_sum = 0;
for(i = 0; i<2; i++) {
adc_init(GP_ADC_SE, GP_ADC_SIGN, ADC_REF_VOLTAGE);
adc_enable_channel(ADC_CHANNEL_P01);
adc_sample = adc_get_sample();
adc_usDelay(1);

adc_init(GP_ADC_SE, 0, ADC_REF_VOLTAGE );
adc_enable_channel(ADC_CHANNEL_P01);
adc_sample2 = adc_get_sample();
adc_usDelay(1);

adc_sample = (adc_sample2 + adc_sample);
adc_sum += adc_sample;
}
adc_sample = (uint16_t)(adc_sum/(2*2));

adc_disable();
temp_en(假);

The attachment is the circuit and the wave (P01) we see in the oscilloscope. The wave confuses us. It becomes lower and has four curves, which we think should keep a stable level. PS, we sample four times. Does the ADC modlue change the signal?

Attachment:
PM_Dialog
Offline
Last seen:1 day 18 hours ago
工作人员
加入:2018-02-08 11:03
Hi MintCandy5,

Hi MintCandy5,

Please take look at the “battery level” example of the SDK adc_get_vbat_sample() function. Could you please try to initialize it with the same way like in the SDK example?

Thanks, PM_Dialog