//-----------------------函数声明,变量定义------------------------------
#include<reg51.h>
#include<intrins.h>
#include<ABSACC.H>
//-----------------------定义管脚----------------------------------------
#definedata_OUTP1
sbitFQ_UD=P3^0;//AD9850信号更新申请
sbitW_CLK=P3^1;//写控制字时钟
unsignedcharCON_word[5];
//Worddata[7]data[6]data[5]data[4]data[3]data[2]data[1]data[0]
//W0PhasebPhaseb3Phaseb2Phaseb1Phaseb0PowerDownControlControl
//W1Freq-b31Freq-b30Freq-b29Freq-b28Freq-b27Freq-b26Freq-b25Freq-b24
//W2Freq-b23Freq-b22Freq-b21Freq-b20Freq-b19Freq-b18Freq-b17Freq-b16
//W3Freq-b15Freq-b14Freq-b13Freq-b12Freq-b11Freq-b10Freq-b9Freq-b8
//W4Freq-b7Freq-b6Freq-b5Freq-b4Freq-b3Freq-b2
//--------------------------------------------------------------------------------------------------
//函数名称:delay
//入口参数:N
//函数功能:延时子程序,实现(16*N+24)us的延时
//系统采用11.0592MHz的时钟时,延时满足要求,其它情况需要改动
//--------------------------------------------------------------------------------------------------
voiddelay(unsignedintN)
{
inti;
for(i=0;i<N;i++);
}
//--------------------------------------------------------------------------------------------------
//函数名称:WRITE_AD9850
//函数功能:将控制字写入AD9850
//--------------------------------------------------------------------------------------------------
voidWRITE_AD9850(void)
{
unsignedchari;
FQ_UD=0;
W_CLK=0;
delay(0);
CON_word[0]=CON_word[0]&0xFC;//置工作方式选择位为00
for(i=0;i<5;i++)
{
data_OUT=CON_word[i];//送控制字
W_CLK=0;
delay(0);
W_CLK=1;//上升延
delay(0);
}
FQ_UD=1;//上升延要求AD9850改变输出
}
//--------------------------------------------------------------------------------------------------
//函数名称:main
//用户主函数
//函数功能:主函数
//--------------------------------------------------------------------------------------------------
voidmain()
{
FQ_UD=0;
WRITE_AD9850();
}