This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS8345返回的结果不是很准确

Other Parts Discussed in Thread: ADS8345

void ADS8345_start(void)
{
DCLK = 0;
CS = 1;
DIN1 = 1;
// DOUT = 0;
DCLK =1 ;
CS = 0;
// BUSY = 0;
}

void ADS8345_WR(uchar dat)
{
uchar count;

DCLK = 0;
for(count = 0; count < 8; count++)
{
dat <<= 1;
DIN1 = CY;
DCLK = 0;
_nop_();
_nop_();
_nop_();
DCLK = 1;
_nop_();
_nop_();
_nop_();
}
}

uint ADS8345_RD(void)
{
uchar count = 0;
uint dat = 0;


for(count = 0; count < 17; count++)
{
dat <<= 1;
DCLK = 1;
_nop_();
_nop_();
_nop_();
DCLK = 0;
_nop_();
_nop_();
_nop_();
if(DOUT == 1)
{
dat++;
}
}
return (dat);
}


void main()
{while(1)

{
ADS8345_start();
delay(2);
ADS8345_WR(0x87);
DIN1 = 0;
// delay(2);
DCLK = 0;
_nop_();
_nop_();
_nop_();
_nop_();
DCLK = 1;
_nop_();
_nop_();
_nop_();
_nop_();

//while(BUSY == 1);
result = ADS8345_RD();
CS = 1;
AD_result = (double)result * 5 / 65535;


}
}