我根据官网例程模拟SPI通信方式与AD7730通信,RDY脚一直是高,哪位高手指点一下,看看什么情况?void SPI_WriteByte(unsigned char TxData)
{
unsigned char tmp,i;
tmp=0x80;
AD7730_CLK_1();
for(i=0;i<8;i++)
{
AD7730_CLK_0();
if((tmp & TxData)==0x00)
{
AD7730_DIN_0();
}
else
{
AD7730_DIN_1();
}
SPI_delay();
AD7730_CLK_1();
tmp>>=1;
SPI_delay();
}
}
void writetoreg(unsigned char byteword)
{
CS_DISABLE();
SPI_WriteByte(byteword);
CS_ENABLE();
}
void Ad7730_Init(void)
{
//Reset7730();
writetoreg(0x03);
writetoreg(0x80);
writetoreg(0x00);
writetoreg(0x10);//
writetoreg(0x04);
writetoreg(0x20);//
writetoreg(0x02);
writetoreg(0xB1);
writetoreg(0x80);
while(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_4))
writetoreg(0x02); // Writes to Communications Register Setting Next Operation as Write to Mode Register
writetoreg(0x91);
writetoreg(0x80);
while(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_4));// Wait for RDY pin to go low to indicate end of calibration cycle
writetoreg(0x02);
writetoreg(0x31);
writetoreg(0x80);
// while(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_4));// Wait for RDY pin to go low to indicate end of calibration cycle
writetoreg(0x21);
}
|