|
有ad采样程序 怎么写数码管显示程序
#include//AD信号采样
char adh,adl;
int chanel0,chanel1,chanel2;
int x;
void interrupt AD_int()//中断服务程序
{
wait: if(ADIF==0) goto wait;//等待AD转换结束
adh=ADRESH;adl=ADRESL;
ADIF=0;//PIR1.6
return;
}
void DELAY()
{
unsigned int i;
for(i=999;i>0;i--);
}
void main()
{
TRISA=0XFF;//A口输入
TRISC=0X00;
TRISB=0X00;
PEIE=1;GIE=1;ADIE = 1;
T1CON=0X30;
INTCON = 0X00;
DELAY();
ADCON1=0b00000100;//AN3 AN1 AN0模拟输入
ADCON0=0b01000001;//左对齐
DELAY();
ADGO = 1;
x=(int)adh<<8;
chanel0=x+(int)adl;
ADCON0=0b01001001;
DELAY();
ADGO = 1;
x=(int)adh<<8;
chanel1=x+(int)adl;
ADCON0=0b01011001;
DELAY();
ADGO = 1;
x=(int)adh<<8;
chanel2=x+(int)adl;
}
|
|