#define ADC_SAMPLE_NUM 10
u16 adc_value[5*ADC_SAMPLE_NUM];//ADC采集值存放缓冲区
void ADC_Filter(u16* adc_val)
{
u16 i=0;
u32 sum[5]={0,0,0,0};
for(;i<ADC_SAMPLE_NUM;i++)
{
sum[0]+=adc_value[5*i+0];//adc_value是ADC采集出来的数据
sum[1]+=adc_value[5*i+1];
sum[2]+=adc_value[5*i+2];
sum[3]+=adc_value[5*i+3];
sum[4]+=adc_value[5*i+4];
}
adc_val[0]=sum[0]/ADC_SAMPLE_NUM;
adc_val[1]=sum[1]/ADC_SAMPLE_NUM;
adc_val[2]=sum[2]/ADC_SAMPLE_NUM;
adc_val[3]=sum[3]/ADC_SAMPLE_NUM;
adc_val[4]=sum[4]/ADC_SAMPLE_NUM;
}
|