基本信息
源码名称:锁相环AD4002配置.c
源码大小:1.83KB
文件格式:.c
开发语言:C/C++
更新时间:2021-01-08
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
#include <c8051f300.h> // SFR declarations
sbit clk_4002 = P0^5;
sbit data_4002 = P0^4;
sbit le_4002 = P0^3;
sbit LD = P0^2;
void OSCILLATOR_Init (void);
void PORT_Init (void);
void DelayNS(unsigned int dly)
{ unsigned int i;
for(; dly>0; dly--)
for(i=0; i<5; i );
}
void OSCILLATOR_Init (void)
{
OSCICN |= 0x03; // Configure internal oscillator for
// its maximum frequency (24.5 Mhz)
}
void PORT_Init (void)
{
P0MDIN |= 0x04; // P0.2 are digital
P0MDOUT = 0x38; // P0.2 is open-drain; others are push-pull
XBR2 = 0x40; // Enable crossbar and enable
// weak pull-ups
}
void Write_Data2(long data1)
{
unsigned char k;
le_4002=0;
DelayNS(1);
for(k=0;k<24;k )
{
if(data1&0x800000)
data_4002=1;
else
data_4002=0;
DelayNS(1);
clk_4002=1;
DelayNS(1);
clk_4002=0;
data1<<=1;
}
le_4002=1;
DelayNS(1);
le_4002=0;
}
void ADF4002_Ini()
{
Write_Data2(0x1f8093);
Write_Data2(0x1f8092);
Write_Data2(0x000004); // R=1 fpd=10MHz
Write_Data2(0x000c01); // N=12 RF=120MHz
}
void main (void)
{
PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog timer
// enable)
PORT_Init(); // Initialize Port I/O
OSCILLATOR_Init (); // Initialize Oscillator
DelayNS(50000);
ADF4002_Ini();
while (1)
{
;
}
}