资源简介
ADF4351寄存器写入参考程序,里面描述了详细的细节说明
代码片段和文件信息
#include“config.h“
INT8U TxStringFreq[2]={00};
void delay( INT8U length );
void WriteToADF4351( INT8U count INT8U *buf INT8U LoadPath );
//******************************************************************************
// Function : WriteToADF4351
// Input : count,字节数,*buf,寄存器数据 LoadPath:0x01:F1
// 0x02:F2
// 0x03:LO
// Output :
// Description : 根据SPI时序,向4350发送数据
//******************************************************************************
void WriteToADF4351( INT8U count INT8U *buf INT8U LoadPath )
{
INT8U ValueToWrite = 0;
INT8U i = 0;
INT8U j = 0;
FreqClkL;
switch( LoadPath )
{
case 0x01:
FreqF1LeL;
break;
case 0x02:
FreqF2LeL;
break;
case 0x03:
FreqLoLeL;
break;
}
for( i = count; i > 0; i-- )
{
ValueToWrite = *( buf + i - 1 );
for( j = 0; j < 8; j++ )
{
if( 0x80 == ( ValueToWrite & 0x80 ))
{
FreqDataH;
}
else
{
FreqDataL;
}
FreqClkH;
ValueToWrite <<= 1;
FreqClkL;
}
}
switch( LoadPath )
{
case 0x01:
FreqF1LeH;
break;
case 0x02:
FreqF2LeH;
break;
case 0x03:
FreqLoLeH;
break;
}
FreqDataL;
}
//******************************************************************************
// Function : GetRegister
// Input : Freq*10
// Output : INT,FRAC,R,MOD,div
// Description : 根据频率,计算INT,FRAC,MOD,div
//******************************************************************************
void GetRegister(volatile struct Freq *STR)
{
INT16U Fre_temp;
INT8U N_Mul = 1;
INT8U Mul_Core = 0;
INT16U INT_Fre;
INT16U Frac_temp;
INT16U Mod_temp;
INT8U i;
if( STR->Ffreq < 350 )
{
STR->Ffreq = 350;
}
if( STR->Ffreq > 44000 )
{
STR->Ffreq = 44000;
}
N_Mul = 0x01;
Fre_temp = STR->Ffreq;
for( i = 0; i < 10; i++ )
{
if((( Fre_temp * N_Mul ) >= 21999 ) && (( Fre_temp * N_Mul ) <= 44001 ))
break;
Mul_Core++;
N_Mul = N_Mul * 2;
}
Mod_temp = REF * 10 / N_Mul;
INT_Fre = STR->Ffreq * N_Mul / REF / 10 ;
Frac_temp = (INT32U)STR->Ffreq * N_Mul * Mod_temp / ( REF * 1
评论
共有 条评论