|
楼主 |
发表于 2019-8-29 09:10:47
|
显示全部楼层
你好程序在这里,这个程序是发送0xff0到AD5173的数据寄存器里,然后再发送0x0101f0 我的电路板上7715的DIN数据输入端子是经过反相器的所以送出的数据是反的数据手册在这里
#include<REG52.h>
sbit CS=P1^0;
sbit DIN=P1^2;
sbit SCLOCK=P1^1;
void Delay1ms() //@11.0592MHz
{
unsigned char i, j;
i = 2;
j = 199;
do
{
while (--j);
} while (--i);
}
void writetoreg(byteword) //The subroutine write byteword to the corresponding registers of AD7709
unsigned long byteword;
{
unsigned char i;
CS=0;
for(i=0;i<24;i++)
{
SCLOCK=1;
if(byteword&0x00800000)
DIN=0;
else DIN=1;
byteword<<=1;
Delay1ms();
SCLOCK=0;
Delay1ms();
}
Delay1ms();
CS=1;
}
void main()
{
CS=1;
DIN=1;
SCLOCK=1;
writetoreg(0x11fff0);
Delay1ms();
writetoreg(0x0101f0);
while(1);
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|