欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
AD9854原理圖與單片機驅動程序設計
[打印本頁]
作者:
thf123
時間:
2017-7-22 14:39
標題:
AD9854原理圖與單片機驅動程序設計
AD9854原理圖如下(pdf文檔清晰版請下載附件):
0.png
(93.08 KB, 下載次數: 93)
下載附件
2017-7-22 18:46 上傳
0.png
(34.87 KB, 下載次數: 82)
下載附件
2017-7-22 18:45 上傳
AD9854單片機源程序如下:
//=====================================================================
// AD9854 驅動程序設計
//AD9854.c
//說明:10MHZ 有源晶振
//=====================================================================
#include <reg52.h>
#include <lcd1602.h>
#include <intrins.h>
sfr P4 = 0xC0; //1111,1111 端口4
sbit KEY1 = P3^5;
sbit KEY2 = P3^4;
sbit KEY3 = P3^3;
sbit KEY4 = P3^2;
unsigned char FreqWord[6]; //6個字節頻率控制字
/*
CLK_Set為時鐘倍頻設置,可設置4~20倍倍頻,但最大不能超過300MHZ
Freq_mult_unsigned long和Freq_mult_doulle均為2的48次方除以系統時鐘,一個為長整形,一個為雙精度型
*/
#define CLK_Set 20
const unsigned long Freq_mult_ulong = 1407375;
const double Freq_mult_doulle = 1407374.88355328;
//**************************修改硬件時要修改的部分********************************
#define AD9854_DataBus P2
#define AD9854_AdrBus P0
sbit AD9854_RST = P3^6; //AD9854復位端口
sbit AD9854_UDCLK = P3^7; //AD9854更新時鐘
sbit AD9854_WR = P4^1; //AD9854寫使能,低有效
sbit AD9854_RD = P4^2; //AD9854讀使能,低有效
sbit AD9854_FDATA = P4^3; //AD9854 FSK,PSK控制
sbit AD9854_OSK = P4^4; //AD9854 OSK控制端
unsigned char flag = 1;
unsigned int fc = 1000;
unsigned long LFerq = 750;
unsigned long HFerq = 1250;
void AD9854_WR_Byte(unsigned char addr,unsigned char dat);
void AD9854_Init(void);
void Freq_convert(long Freq);
void AD9854_InitFSK(void);
void AD9854_SetFSK(unsigned long Freq1,unsigned long Freq2);
//void delay (unsigned int us);
void UpDisplay()
{
unsigned char disbuf[5];
LCD_Write_String(0, 0, "BaseFerq M");
LCD_Write_String(0, 1, "Now Ferq M");
disbuf[0] = fc / 1000 + '0';
disbuf[1] = '.';
disbuf[2] = fc % 1000 / 100 + '0';
disbuf[3] = fc % 100 / 10 + '0';
disbuf[4] = fc % 10 + '0';
disbuf[5] = 0;
LCD_Write_String(9, 0, disbuf);
disbuf[0] = HFerq / 1000 + '0';
disbuf[1] = '.';
disbuf[2] = HFerq % 1000 / 100 + '0';
disbuf[3] = HFerq % 100 / 10 + '0';
disbuf[4] = HFerq % 10 + '0';
disbuf[5] = 0;
LCD_Write_String(9, 1, disbuf);
}
void DownDisplay()
{
unsigned char disbuf[5];
LCD_Write_String(0, 0, "BaseFerq M");
LCD_Write_String(0, 1, "Now Ferq M");
disbuf[0] = fc / 1000 + '0';
disbuf[1] = '.';
disbuf[2] = fc % 1000 / 100 + '0';
disbuf[3] = fc % 100 / 10 + '0';
disbuf[4] = fc % 10 + '0';
disbuf[5] = 0;
LCD_Write_String(9, 0, disbuf);
disbuf[0] = LFerq / 1000 + '0';
disbuf[1] = '.';
disbuf[2] = LFerq % 1000 / 100 + '0';
disbuf[3] = LFerq % 100 / 10 + '0';
disbuf[4] = LFerq % 10 + '0';
disbuf[5] = 0;
LCD_Write_String(9, 1, disbuf);
}
void AD9854_SetSine(unsigned long Freq,unsigned int Shape)
{
unsigned char count;
unsigned char Adress;
Adress = 0x04; //選擇頻率控制字地址的初值
Freq_convert(Freq); //頻率轉換
for(count=6;count>0;) //寫入6字節的頻率控制字
{
AD9854_WR_Byte(Adress++,FreqWord[--count]);
}
AD9854_WR_Byte(0x21,Shape>>8); //設置I通道幅度
AD9854_WR_Byte(0x22,(unsigned char)(Shape&0xff));
AD9854_WR_Byte(0x23,Shape>>8); //設置Q通道幅度
AD9854_WR_Byte(0x24,(unsigned char)(Shape&0xff));
AD9854_UDCLK=1; //更新AD9854輸出
AD9854_UDCLK=0;
}
void main()
{
LCD_Init();
LCD_Clear();
/*LCD_Write_String(0,0,"BaseFerq 0.875 M");
LCD_Write_String(0,1,"Now Ferq 1.125 M");*/
UpDisplay();
AD9854_Init();
AD9854_SetSine(HFerq * 1000,4000);
// AD9854_SetSine(1000000,4000);
// while(1);
// AD9854_InitFSK();
//
// AD9854_SetFSK(HFerq * 1000, LFerq * 1000);
// AD9854_SetFSK(1000000,1000000);
// AD9854_FDATA = 1;
// while(1);
while(1)
{
if(!KEY1)
{
if (flag == 1)
{
AD9854_SetSine(0,0);
//AD9854_InitFSK();
flag = 0;
}
else
{
// AD9854_InitFSK();
// AD9854_SetFSK(HFerq * 1000, LFerq * 1000);
AD9854_SetSine(HFerq * 1000,4000);
flag = 1;
}
while (!KEY1);
}
if (flag == 1)
{
if (!KEY2)
{
AD9854_SetSine(0,0);
fc += 100;
if (fc == 7900) fc = 7800;
LFerq = fc * 3 / 4;
HFerq = fc * 5 / 4;
UpDisplay();
AD9854_SetSine(HFerq * 1000,4000);
// AD9854_InitFSK();
// AD9854_SetFSK(HFerq * 1000, LFerq * 1000);
while (!KEY2);
}
if (!KEY3)
{
AD9854_SetSine(0,0);
fc -= 100;
if (fc == 300) fc = 400;
LFerq = fc * 3 / 4;
HFerq = fc * 5 / 4;
UpDisplay();
AD9854_SetSine(HFerq * 1000,4000);
// AD9854_InitFSK();
// AD9854_SetFSK(HFerq * 1000, LFerq * 1000);
while (!KEY3);
}
if (!KEY4)
{
//AD9854_FDATA = 1;
AD9854_SetSine(LFerq * 1000,4000);
DownDisplay();
while (!KEY4);
AD9854_SetSine(HFerq * 1000,4000);
//AD9854_FDATA = 0;
UpDisplay();
}
}
}
}
//====================================================================================
//函數名稱:void AD9854_WR_Byte(unsigned char addr,unsigned char dat)
//函數功能:AD9854并行口寫入數據
//入口參數:addr 6位地址
// dat 寫入的數據
//出口參數:無
//====================================================================================
void AD9854_WR_Byte(unsigned char addr,unsigned char dat)
{
AD9854_AdrBus = (addr&0x3f) | (AD9854_AdrBus&0xc0);
AD9854_DataBus = dat;
AD9854_WR = 0;
AD9854_WR = 1;
}
//====================================================================================
//函數名稱:void AD9854_Init(void)
//函數功能:AD9854初始化
//入口參數:無
//出口參數:無
//====================================================================================
void AD9854_Init(void)
{
AD9854_WR=1;//將讀、寫控制端口設為無效
AD9854_RD=1;
AD9854_UDCLK=0;
AD9854_RST=1; //復位AD9854
AD9854_RST=0;
AD9854_WR_Byte(0x1d,0x10); //關閉比較器
AD9854_WR_Byte(0x1e,CLK_Set); //設置系統時鐘倍頻
AD9854_WR_Byte(0x1f,0x00); //設置系統為模式0,由外部更新
AD9854_WR_Byte(0x20,0x60); //設置為可調節幅度,取消插值補償
AD9854_UDCLK=1; //更新AD9854輸出
AD9854_UDCLK=0;
}
//====================================================================================
//函數名稱:void Freq_convert(long Freq)
//函數功能:正弦信號頻率數據轉換
//入口參數:Freq 需要轉換的頻率,取值從0~SYSCLK/2
//出口參數:無 但是影響全局變量FreqWord[6]的值
//說明: 該算法位多字節相乘算法,有公式FTW = (Desired Output Frequency × 2N)/SYSCLK
// 得到該算法,其中N=48,Desired Output Frequency 為所需要的頻率,即Freq,SYSCLK
// 為可編程的系統時鐘,FTW為48Bit的頻率控制字,即FreqWord[6]
//====================================================================================
void Freq_convert(long Freq)
{
unsigned long FreqBuf;
unsigned long Temp=Freq_mult_ulong;
unsigned char Array_Freq[4]; //將輸入頻率因子分為四個字節
Array_Freq[0]=(unsigned char)Freq;
Array_Freq[1]=(unsigned char)(Freq>>8);
Array_Freq[2]=(unsigned char)(Freq>>16);
Array_Freq[3]=(unsigned char)(Freq>>24);
FreqBuf=Temp*Array_Freq[0];
FreqWord[0]=FreqBuf;
FreqBuf>>=8;
FreqBuf+=(Temp*Array_Freq[1]);
FreqWord[1]=FreqBuf;
FreqBuf>>=8;
FreqBuf+=(Temp*Array_Freq[2]);
FreqWord[2]=FreqBuf;
FreqBuf>>=8;
FreqBuf+=(Temp*Array_Freq[3]);
FreqWord[3]=FreqBuf;
FreqBuf>>=8;
FreqWord[4]=FreqBuf;
FreqWord[5]=FreqBuf>>8;
}
//====================================================================================
//函數名稱:void AD9854_InitFSK(void)
//函數功能:AD9854的FSK初始化
//入口參數:無
//出口參數:無
//====================================================================================
void AD9854_InitFSK(void)
{
AD9854_WR=1; //將讀、寫控制端口設為無效
AD9854_RD=1;
AD9854_UDCLK=0;
AD9854_RST=1; //復位AD9854
AD9854_RST=0;
AD9854_WR_Byte(0x1d,0x10); //關閉比較器
AD9854_WR_Byte(0x1e,CLK_Set); //設置系統時鐘倍頻
AD9854_WR_Byte(0x1f,0x02); //設置系統為模式1,由外部更新
AD9854_WR_Byte(0x20,0x60); //設置為可調節幅度,取消插值補償
AD9854_UDCLK=1; //更新AD9854輸出
AD9854_UDCLK=0;
}
//====================================================================================
//函數名稱:void AD9854_SetFSK(unsigned long Freq1,unsigned long Freq2)
//函數功能:AD9854的FSK設置
//入口參數:Freq1 FSK頻率1
// Freq2 FSK頻率2
//出口參數:無
//====================================================================================
void AD9854_SetFSK(unsigned long Freq1,unsigned long Freq2)
{
unsigned char count=6;
unsigned char Adress1,Adress2;
const unsigned int Shape=4000; //幅度設置. 為12 Bit,取值范圍為(0~4095)
Adress1=0x04; //選擇頻率控制字1地址的初值
Adress2=0x0a; //選擇頻率控制字2地址的初值
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
63535281AD9854-msk-for-stm32.zip
(125.05 KB, 下載次數: 125)
2017-7-22 14:39 上傳
點擊文件名下載附件
123
下載積分: 黑幣 -5
作者:
1213866
時間:
2018-7-11 11:11
很有用
作者:
qdneu
時間:
2019-1-9 13:57
垃圾東西,舍不得把原理圖源文件發出來,
作者:
DarkZer00o
時間:
2019-3-5 08:39
謝謝樓主分享
作者:
叭叭叭比巴卜
時間:
2019-4-6 21:41
很好用
作者:
13780387330
時間:
2019-7-21 08:54
感謝分享,收藏
作者:
BCWGTeam
時間:
2021-3-18 10:15
很好啊,學習到了
作者:
tutunust
時間:
2022-9-13 10:04
有些不太清楚,需要下載附件看看,謝謝分享
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1