ad9850-c程序-設(shè)計源代碼
#include
#include
float l,m,n,q,z;
double k;
//-----------------------定義管腳-----------------------------
#define data_OUT P1
sbit FQ_UD=P3^0; //AD9850信號更新申請
sbit W_CLK=P3^1;
sbit FESET="P3"^2; //寫控制字時鐘
unsigned char CON_word[5];
//Word data[7] data[6] data[5] data[4] data[3] data[2] data[1] data[0]
//W0 Phase b Phase b3 Phase b2 Phase b1 Phase b0 Power Down Control Control
//W1 Freq-b31 Freq-b30 Freq-b29 Freq-b28 Freq-b27 Freq-b26 Freq-b25 Freq-b24
//W2 Freq-b23 Freq-b22 Freq-b21 Freq-b20 Freq-b19 Freq-b18 Freq-b17 Freq-b16
//W3 Freq-b15 Freq-b14 Freq-b13 Freq-b12 Freq-b11 Freq-b10 Freq-b9 Freq-b8
//W4 Freq-b7 Freq-b6 Freq-b5 Freq-b4 Freq-b3 Freq-b2
//--------------------------------------------------------------------------------------------------
// 函數(shù)名稱: delay
// 入口參數(shù): N
// 函數(shù)功能:延時子程序,實現(xiàn)(16*N+24)us的延時
// 系統(tǒng)采用11.0592MHz的時鐘時,延時滿足要求,其它情況需要改動
//--------------------------------------------------------------------------------------------------
// void delay(unsigned int N)
// {
// int i;
//for(i=0;i // }
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
/*******************************************************/
void Freq_Adjust(long value_Freq)
{
unsigned int i;
long f;
unsigned char L4,L3,L2,L1,L0;
FQ_UD=0;
f="value"_Freq*86;
L0=0x28;
L4= f0x000000ff;
L3=(f>>8)0x000000ff;
L2=(f>>16)0x000000ff;
L1=(f>>24)0x000000ff;
CON_word[0]=L0;
CON_word[4]=L4;
CON_word[3]=L3;
CON_word[2]=L2;
CON_word[1]=L1;
FQ_UD=0;
W_CLK=0;
//delay(0);
_nop_(); _nop_(); _nop_(); _nop_(); _nop_();
CON_word[0]=CON_word[0]0xFC; //置工作方式選擇位為00
for(i=0;i5;i++)
{
FESET="1";
W_CLK=0;
data_OUT=CON_word[i]; //送控制字
// delay(0);
_nop_(); _nop_(); _nop_(); _nop_();_nop_();
FESET="0";
W_CLK=1; //上升延
//delay(0);
_nop_(); _nop_(); _nop_();_nop_();_nop_();
}
FQ_UD=1;
}
//-------------------------------------------------------------------------------
// 函數(shù)名稱:main
// 用戶主函數(shù)
// 函數(shù)功能:主函數(shù)
//-------------------------------------------------------------------------------
main()
{
BEGAIN:
LCD_Initial();
P2=0XF0;
GotoXY(0,0);
Print("Please Input :");
GotoXY(0,1);
Print(" ");
m=0;
k=0;
l=0;
//q=5;
FQ_UD=0;
Freq_Adjust(50000);
while(1)
{
while(1)
{
m="keynum"();
if(m>=0m=9||m==15||m==14)
{
z="m";
Delay1ms(150);
break;
}
}
if(m>=0m=9)
{
l++;
}
if(z==14)
{
goto BEGAIN;
}
if(z==15)
{
GotoXY(0,1);
Print(TempBuffer[0]);
GotoXY(9,1);
Print("OK!!");
Delay1ms(1000);
break;
}
if(l==1)
{k=z;}
if(l==2)
{
k="k"*10+z;
}
if(l==3)
{
k="k"*10+z;
}
if(l==4)
{
k="k"*10+z;
}
if(l==5)
{
k="k"*10+z;
}
if(l==6)
{
k="k"*10+z;
}
if(l==7)
{
k="k"*10+z;
&
評論