本人用ATmega16 和 ad9851制作一个信号发生器,采用串行的方式输入40位控制字,但是就是没有波形输出,也不知道是不是
电路不对,所以也附上本人的电路图,麻烦有知道的高手帮忙看一下,附件是本人的ad9851的接口电路,麻烦看看有没有错:
下面是我参考网上写的串行输出驱动:
#define AD9851_SCLK_PORT PORTA //PORTA W_CLK
#define AD9851_LOAD_PORT PORTA //PORTA FQUD
#define AD9851_DATA_PORT PORTA //PORTA DATA
#define AD9851_SCLK_H 0x01 //PORTA0 out 程序中置位的方法,详细见本程序
#define AD9851_LOAD_H 0x02 //PORTA1 out 同上
#define AD9851_DATA_H 0x04 //PORTA2 out 同上
#define AD9851_LOW 0x00
/*************** AD9851驱动程序 ************/
void ad9851(float freq)
{
float fw;
unsigned char i,j,temp;
unsigned char s,6REF_ON;
unsigned char d[5];
6REF_ON=1;
fw="freq"*35.79139413; //d[4]中存放控制字最高位,即相位控制字
//Freq=MCLK*FW/2^32
d[4]=(unsigned long)6REF_ON;
d[0]=(unsigned long)fw;
d[1]=(unsigned long)fw>>8;
d[2]=(unsigned long)fw>>16;
d[3]=(unsigned long)fw>>24;
AD9851_LOAD_PORT =AD9851_LOW; //load=0;
AD9851_SCLK_PORT =AD9851_LOW; //sclk=0;
AD9851_SCLK_PORT|=AD9851_SCLK_H; //sclk=1;
AD9851_SCLK_PORT =AD9851_LOW; //sclk=0;
AD9851_LOAD_PORT|=AD9851_LOAD_H; //load=1;
AD9851_LOAD_PORT =AD9851_LOW; //load=0;
for(i=0;i<5;i++)
{
temp="d"
;
for(j=0;j<8;j++)
{
AD9851_SCLK_PORT =AD9851_LOW; //sclk=0;
if(temp 1)
AD9851_DATA_PORT|=AD9851_DATA_H; //sdata=1;
else AD9851_DATA_PORT =AD9851_LOW; //sdata=0;
AD9851_SCLK_PORT|=AD9851_SCLK_H; //sclk=1;
temp=temp>>1;
}
}
AD9851_LOAD_PORT|=AD9851_LOAD_H; //load=1;
AD9851_LOAD_PORT =AD9851_LOW; //load=0;
}