ads1230的Dout脚有时候正常,有时候就一直输出为高,这个有遇到吗?太奇怪了
unsigned long ReadAD(void)
{
unsigned char i=0;
unsigned long ADdatatemp=0; //设置AD转换的初始值为0
while(ADC_RDY1); //RDY = 0??等待AD转换完成
for(i = 0;i < 20;i ++) //获取20位数据
{
ADdatatemp = ADdatatemp << 1;
ADC_SCLK1 = 1; //CLK = 1
if(ADC_DOUT1 == 1)
ADdatatemp = ADdatatemp | 0x000001;
else
ADdatatemp = ADdatatemp & 0xFFFFFE;
ADC_SCLK1 = 0; //CLK = 0
}
for(i = 0;i < 4;i ++) //为下一次转换准备
{
ADC_SCLK1 = 1;
ADC_SCLK1 = 0; //CLK = 0
}
return(ADdatatemp);
} |