uint xdata AD_result=0,ch=0;
void ADC_init()
{
P1M0=0Xff; //P1.7 --- P1.0 高阻输入AD
P1M1=0x00;
ADC_DATA=0;
ADC_LOW2=0;
ADC_CONTR = ADC_POWER | ADC_SPEEDLL | ADC_START | ch;
Delay20ms();
AUXR|=0x10; //set EADCI
IE = 0xa0;
}
void ADC_ISR_Routine() interrupt 5
{
ADC_CONTR&=!ADC_FLAG;
AD_result=ADC_DATA;
if (++ch > 7) ch=0;
ADC_CONTR = ADC_POWER | ADC_SPEEDLL | ADC_START | ch;
}
void dyA_display()
{
if(ch==2)
U1=AD_result*5/1024;
ds_buff1[0]=U1/1000+0x30;
ds_buff1[1]=U1%1000/100+0x30;
ds_buff1[2]=U1%100/10+0x30;
ds_buff1[3]=U1%10+0x30;
ds_buff[0]|=0x80;
ds_buff[1]|=0x01;
ds_buff[3]=SMG[ds_buff1[0]];
ds_buff[4]=SMG[ds_buff1[1]];
ds_buff[5]=SMG[ds_buff1[2]];
ds_buff[6]=SMG[ds_buff1[3]]|0x08;
WriteAll_1621(0,ds_buff,7);
}
|