AVR AD 采集转换程序,带数字滤波 1
//本例使用内部参考电压,ADc0 输入,采集的信号通过LED 显示
//ICC-AVR application builder : 2006-9-3 11:42:36 4
// Target : M32 5
// Crystal: 7
3728Mhz 6
56v 片内基准电压,输入a1:即 adc0 7
// 误差为: 连续测量模式
// 精度 8,输出左对齐 ADLAR=1 9
// 注意:参考电压一定要高于被测电压
#include 11
#include 12
//数字滤波 13
#define a 0xF4 14
// a=0
#define b 0x0D 16
// b=1-a=0
const led_table[16]={0xa0,0xfc,0xc1,0xd0,0x9c,0x92,0x82,0xf8,0x80,0x90,0x88,0x86,0xc7,0xc4,0x83,0x8b};// 0~~f 18
typedef unsigned char uint8; 19
uint8 value,value1=0; 20
int x; //最终的值 10 位 21
volatile uint8 i,j=0; 22
//delay 24
/***********************************/ 25
void Delay100us(uint8 n) 26
uint8 i; 28
for(i=36;n
=0;n--) 29
while(--i); 30
void Delay1s(uint8 n) 33
n=n*10; 35
for (;n