void SYS_Read_Elcnt(void)
{
unsigned char i;
unsigned int xdata a1[172],a2[172],a3[172],a4[172],a5[172],a6[172];
ADC_CONTR = 0xc0;
CLK_DIV=0x20;
TF0 = 0; //清除TF0标志
ET0 = 0; //关闭定时器0中断
TR0 = 0; //定时器0关闭计时
TH0 = 0x00; //初始化计时值
TH0 = 0x70; //初始化计时值 定时20毫秒@22.1184M外置晶振
TF0 = 0; //清除TF0标志
ET0 = 1; //使能定时器0中断
TR0 = 1; //定时器0开始计时
READ_Elcnt_EN=1;//将定时时间到置1
while(READ_Elcnt_EN)//到达20毫秒后,此变量通过定时器1中断置0,退出采样
{
a1[i]=READ_ADC_Dat(0xc8);//P1.0
a2[i]=READ_ADC_Dat(0xc9);//P1.1
a3[i]=READ_ADC_Dat(0xca);//P1.2
a4[i]=READ_ADC_Dat(0xcb);//P1.3
a5[i]=READ_ADC_Dat(0xcc);//P1.4
a6[i]=READ_ADC_Dat(0xcd);//P1.5
if(i<169)//22.1184M 时钟,CLK_DIV=0x20;实际每通道采样次数为166次
{
i++;
}
}
}
问题程序。
|