急求AD9832改变频率控制字时输出时准时不准解决办法
void SendData(unsigned int d)
{
unsigned int i;
SY9832 = 0;
SDA9832=0;
for(i=0;i <16;i++)
{
SDA9832 =(bit)(d&0x8000);
SCLK9832=1;
SCLK9832=0;
d < <=1;
}
SCLK9832=1;
SY9832 = 1;
SCLK9832=0;
}
void ad9832()
{
void SendData(unsigned int x);
unsigned long f;
unsigned int x;
unsigned char y[4];
unsigned char i,*px;
void *pf;
f=(long )(hz*69.905*256);
px=y;
pf=&f;
if(~fhag)
{
for (i=0;i <4;i++)
{
*(px+i)=*((char*)pf+3-i);
x=(unsigned int)(*(px+i));
switch (i)
{
case 0: x&=0x30ff;x|=0x3000;break;
case 1: x&=0x21ff;x|=0x2100;break;
case 2: x&=0x32ff;x|=0x3200;break;
case 3: x&=0x23ff;x|=0x2300;break;
}
SendData(x);
}
SendData(0x5000);
fhag=1;
}
else
{
for (i=0;i <4;i++)
{
*(px+i)=*((char*)pf+3-i);
x=(unsigned int)(*(px+i));
switch (i)
{
case 0: x&=0x34ff;x|=0x3400;break;
case 1: x&=0x25ff;x|=0x2500;break;
case 2: x&=0x36ff;x|=0x3600;break;
case 3: x&=0x27ff;x|=0x2700;break;
}
SendData(x);
}
SendData(0x5800);
fhag=0;
}
}
void ad98320()
{
void SendData(unsigned int x);
SY9832 = 1;
SendData(0xf800);
SendData(0xb000);
SendData(0xc000);
}
发表时间:2006年6月14日17:15:11