What's the reference voltage of ADC_P02

4 posts / 0 new
Last post
RandyYu
Offline
Last seen:2 years 10 months ago
加入:2015-01-28 08:49
What's the reference voltage of ADC_P02

the voltage I using multimeter measured is 0.716V,but the ADC value is 0x185,no matter which of reference voltage it is(1.2v,1.8v.3.3v,3.6v),the gap is a little big.
Also I find a question,when I connect the pin(which will be measure) to P02,the voltage will be decrease about 0.08V.what's wrong with it?

the code is
uint16_t adc_get_ther_sample(void)
{
volatile uint32_t adc_sample, adc_sample1,adc_sample2;
/*Single ended mode*/
/*Conversion with opposite sign at input and output to cancel
out the internal offset of the ADC and low-frequency */
/*Input voltages up to 3.6V allowed by enabling 3x attenuator.*/
adc_init(GP_ADC_SE, GP_ADC_SIGN, GP_ADC_ATTN3X);
adc_usDelay(20);
adc_enable_channel(ADC_CHANNEL_P02);

adc_sample1 = adc_get_sample();

adc_usDelay(1);

adc_init(GP_ADC_SE, 0, GP_ADC_ATTN3X );
adc_enable_channel(ADC_CHANNEL_P02);
adc_sample2 = adc_get_sample();
/ /我们必须把以下结果by 2 if
//the 10 bit accuracy is enough
adc_sample = (adc_sample2 + adc_sample1);
adc_disable();

return adc_sample;
}

Device:
MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi RandyYu,

Hi RandyYu,

The reference voltage of the 580 is 1.2V volts or 3.6 when using the attenuator regardless of the operating voltage of your device (in buck or boost mode). In the code you ve pasted i see that you are summing up the two values that you get from the ADC. Regarding the fact that you get a lower value when connected to the P02 pin, i can't tell why this is happening, i ve tested the adc on all pins i didn't have different values over the P02 with and without the attenuator.

Thanks MT_dialog

RandyYu
Offline
Last seen:2 years 10 months ago
加入:2015-01-28 08:49
I am not very understand the

Q1: I am not very understand the 'attenuator',how did I know if I using attenuator or not?
the code I pasted is I modified from adc_get_vbat_sample(bool sample_vbat1v) in adc.c
can you give me a code about sampling.

*************************************************************************************************
now I have modifed the sampling as the below
uint16_t adc_get_ther_sample(void)
{
uint32_t adc_sample;
/*Single ended mode*/
/*Conversion with opposite sign at input and output to cancel
out the internal offset of the ADC and low-frequency */
/*Input voltages up to 3.6V allowed by enabling 3x attenuator.*/
adc_init(GP_ADC_SE, 0, GP_ADC_ATTN3X );
adc_usDelay(20);
adc_enable_channel(ADC_CHANNEL_P02);
adc_sample = adc_get_sample();

adc_disable();

return adc_sample;
}
the result seem right ,
but also the calculated votlage is a little lower(about 0.02V) than the value I measured by multimeter.
And the offset is a little big.
Q2:does the sampling code right?or if there have another better method to get more accuracy result

MT_dialog
Offline
Last seen:2 months 4 weeks ago
Staff
加入:2015-06-08 11:34
Hi RandyYu,

Hi RandyYu,

The attenuator can be enabled when you are initializing the ADC, its the 3rd paramater in the adc_init(), you can check either the comments in the function's implementation or the documentation in UM-B-051 at section 10.4. You can use the same code for reading the adc as the adc example instructs, you just have to divide the result that you get by 2 in order to get a proper value. Regarding the offset that you see you will have to calibrate the adc before using it. And also you wont be able to match the value of the ADC with the value of the multimeter, are you absolutely sure that the multimeter you are using is calibrated and that it has perfect accurancy?

Thanks MT_dialog

Topic locked