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)?
Device:
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
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?
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