求助xmega ADC 无符号转换结果偏大
本帖最后由 Cortex_M3 于 2014-6-17 17:47 编辑再用xmega32a4 做ADC 无符号AD转换时,测量结果存在误差
具体配置函数如下
void ADC_Port_Configuration_Init(void)
{
struct adc_config adc_conf;
struct adc_channel_configadcch_conf;
// Clear the configuration structures.
// 清除配置结构
memset(&adc_conf, 0, sizeof(struct adc_config));
memset(&adcch_conf, 0, sizeof(struct adc_channel_config));
/* Configure the ADC module:
* - unsigned, 12-bit results
* - VCC/1.6 voltage reference
* - 200 kHz maximum clock rate
* - manual conversion triggering
*/
/*
12位无符号模式,基准电压Vcc/1.6=2.06V
200KHz时钟频率
*/
adc_set_conversion_parameters(&adc_conf, ADC_SIGN_OFF, ADC_RES_12, ADC_REF_VCC);
adc_set_clock_rate(&adc_conf, 200000UL);
adc_set_conversion_trigger(&adc_conf, ADC_TRIG_MANUAL, 3, 0);
adc_write_configuration(&ADCA, &adc_conf);
/* Configure ADC channel 0, 1 and 2:
* - single-ended measurement from configured input pin
* - interrupt flag set on completed conversion
*/
adcch_set_input(&adcch_conf, ADCCH_POS_PIN0, ADCCH_NEG_NONE, 1); // PA0VU_L
adcch_set_interrupt_mode(&adcch_conf, ADCCH_MODE_COMPLETE);
adcch_disable_interrupt(&adcch_conf);
adcch_write_configuration(&ADCA, 0, &adcch_conf); // 配置到通道0
adcch_set_input(&adcch_conf, ADCCH_POS_PIN1, ADCCH_NEG_NONE, 1); // PA1VU_R
adcch_write_configuration(&ADCA, 1, &adcch_conf); // 配置到通道1
adcch_set_input(&adcch_conf, ADCCH_POS_PIN7, ADCCH_NEG_NONE, 1); // PA7Temp
adcch_write_configuration(&ADCA, 2, &adcch_conf); // 配置到通道2
// Enable the ADC and do one dummy conversion.
adc_enable(&ADCA);
}
uint16_t Get_ADC_Vol(uint8_t ch)
{
unt16_t value=0;
adc_start_conversion(&ADCA, ch);
adc_wait_for_interrupt_flag(&ADCA, ch);
value = adcch_get_result(&ADCA, ch);
return (uint16_t) value ;
}
麻烦各位坛友给看看。
PS:开发环境AVR studio
输入端接地,竟然还有150多的输出
In unsigned mode, the negative input is connected to half of the voltage reference (VREF) voltage minus a fixed offset.
The nominal value for the offset is:
_V = Vref x 0.05
楼主这个你减掉没。。 hell-prototypes 发表于 2014-6-18 09:43
In unsigned mode, the negative input is connected to half of the voltage reference (VREF) voltage mi ...
这个我知道
Vref = VCC/1.6 =2.06V
换算过去为RES = 204
直接减去会出现负的情况,因为我对地 大概是输出RES = 150
会有50 res 偏差
页:
[1]