ADF4113输入配置程序及频率设定
0赞
发表于 7/6/2012 10:39:24 PM
阅读(2781)
void adf4113_data_input(unsigned long int data)//输入配置
{
unsigned long int temp;
unsigned int i;
temp=0x800000;
pll4113_clk=0;
pll4113_le=0;
delay100us(1);
for(i=0;i<24;i++)
{
pll4113_clk=0;
if(data&temp)
{
pll4113_data=1;
}
else
{
pll4113_data=0;
}
temp=temp>>1;
delay100us(1);
pll4113_clk=1;
delay100us(1);
}
pll4113_le=1;
delay100us(1);
pll4113_le=0;
}
void pll4113_init(void)
{
adf4113_data_input(0xdf8003); //init
adf4113_data_input(0xdf8002); //function.
// 10.7mhz ref.
adf4113_data_input(a_ref); // r
adf4113_data_input(ab_counter);
}
void pll4113_setfreq(unsigned long int freq)//设定频率
{
unsigned long int value = 0;
float pdf = 10000;
float b,a;
unsigned long int b_int, a_int;
b = (float)freq/pdf/(float)(64);
b_int = (unsigned long int)(b);
a = (float)freq/pdf - (64*(float)b_int);
a_int = (unsigned long int)(a);
value = b_int<<8;
value += a_int<<2;
value += 1;
adf4113_data_input(0xdf8006); //function. reset counter.
adf4113_data_input(a_ref); // r
adf4113_data_input(value); // ab 003e81
adf4113_data_input(0xdf8002); //function.
}
