|
大家帮我看一下,AD采样值抖动严重,用什么办法解决?
[复制链接]
现在出现的情况是AD的显示结果后两位老是闪烁,我试过隆低系统频,加大AD采样定时器的分频,但问题依旧,这种方法对吗?还有别的好方法吗?
程序如下:
#include <msp430x13x.h>
#define vref 3300
void clock_init(void)
{
DCOCTL = 0x00;
//XT2晶振开启,高频模式,ALCK分频系数为8分频,选择内部电阻频率为最高.
BCSCTL1 =XT2OFF+XTS+DIVA_0+DIVA_1+DIVA_2+DIVA_0+RSEL2+RSEL1+RSEL0;
//MCLK的时钟为低速晶振
BCSCTL2=SELM_1+SELM_0+DIVM_1+DIVM_0+SELS+DIVS_3+DIVS_2+DIVS_1+DIVS_0;
}
/*ADC初始华*/
void adc_init(void)
{
ADC12CTL0=ADC12ON+MSC;
ADC12CTL1 =SHP+CONSEQ_1;
ADC12MCTL0 = INCH_0;
ADC12MCTL1 = INCH_1;
ADC12MCTL2 = INCH_2;
ADC12MCTL3 = INCH_3;
ADC12MCTL4 = INCH_4;
ADC12MCTL5 = INCH_5;
ADC12MCTL6 = INCH_6;
ADC12MCTL7 = INCH_7+EOS;
ADC12IFG=0xff;
ADC12IE = 0x80;
ADC12CTL0 |= ENC;
ADC12CTL0 |= ADC12SC;
}
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR (void)
{
adc_rel0 = ADC12MEM0;
adc_rel1 = ADC12MEM1;
adc_rel2 = ADC12MEM2;
adc_rel3 = ADC12MEM3;
adc_rel4 = ADC12MEM4;
adc_rel5 = ADC12MEM5;
adc_rel6 = ADC12MEM6;
adc_rel7 = ADC12MEM7;
adc_rel0 = (unsigned int)(((unsigned long)((unsigned long)adc_rel0*vref))/0xfff);
adc_rel1 = (unsigned int)(((unsigned long)((unsigned long)adc_rel1*vref))/0xfff);
adc_rel2 = (unsigned int)(((unsigned long)((unsigned long)adc_rel2*vref))/0xfff);
adc_rel3 = (unsigned int)(((unsigned long)((unsigned long)adc_rel3*vref))/0xfff);
adc_rel4 = (unsigned int)(((unsigned long)((unsigned long)adc_rel4*vref))/0xfff);
adc_rel5 = (unsigned int)(((unsigned long)((unsigned long)adc_rel5*vref))/0xfff);
adc_rel6 = (unsigned int)(((unsigned long)((unsigned long)adc_rel6*vref))/0xfff);
adc_rel7 = (unsigned int)(((unsigned long)((unsigned long)adc_rel7*vref))/0xfff);
}
|
|