已回答假定已回答

ADF4355快速锁频失败

KC_CEC 在 2016-1-20 詢問的問題
最後回覆由Coney於2017-2-13提供

因为4355自动校准锁频需要的时间太长,所以参考手册ADF4355-AN-1381,以希望实现快速锁频。

但是反复尝试了很多次都不能输出一个单一的频率,希望指点一下!

 

在获取校准数据的过程中就出现了问题:

根据手册说明,可以得出3个校准值的理论范围如下:

             最小         最大

Core       1               4

Band      0               255

Bias       0               8

 

但实际读取过程中Core值最大为7,Bias值最大为10!

这导致我在写入这些值,无法完全和寄存器里面值对应!


以下为读取校准数据流程:

4355内部为3400MHz~6800MHz,所以以1M为步进读取3401组数据保存。

1.REG4  ->DB[27:29]=7,DB[4]=1

2.REG6

3.REG2

4.REG1

5.REG4  ->DB[4]=0

6.REG10 ->DB[28:26]=1

7.REG7  ->DB[14:12]=6

8.REG0  ->DB[21]=1

9.等待锁定

10.REG7 ->DB[14:12]=7

11.读取Core和Band

12.REG10->[28:26]=3

13.读取Bias

14.重复到步骤1

 

以下为具体代码:

/*
功能:得到VCO校准数据
参数:strChip->VCO器件选择,
         pBuf->存储缓存
            x,y->显示地址
*/
void ADF4355_GetCal(ADF43553Str *strChip,VcoValStr *pBuf,uint16_t x,uint16_t y)
{
    uint32_t u32Reg11Val=0;
    uint32_t u32Reg10Val=0;
    uint32_t u32Reg7Val=0;
    uint32_t u32Reg6Val=0;
    uint32_t u32Reg4Val=0;
    uint32_t u32Reg2Val=0;
    uint32_t u32Reg1Val=0;
    uint32_t u32Reg0Val=0; 
    //判断频率
    if((strChip->u64Freq<53125000ULL)||\
        (strChip->u64Freq>6850000000ULL))
    {
        return;
    } 
    ADF43553_ChangeChip(strChip);

    uint64_t u64StrFreq=3400000000;
    uint64_t u64Step=1000000;
    uint64_t u64OutFreq=0;

    for(uint32_t cnt=0;cnt<3401;cnt++)
    {
        u64OutFreq=u64StrFreq+u64Step*cnt;
     
        strChip->u64Freq=u64OutFreq;
        /*
        计算参数
        */
        ADF4355_TRACE("*****Outfreq=%llu\r\n",strChip->u64Freq);
     
        if((strChip->u64Freq>=53125000)&&(strChip->u64Freq<106250000))                            u8OutDiv=64;
        else if((strChip->u64Freq>=106250000)&&(strChip->u64Freq<212500000))                u8OutDiv=32;
        else if((strChip->u64Freq>=212500000)&&(strChip->u64Freq<425000000))                u8OutDiv=16;
        else if((strChip->u64Freq>=425000000)&&(strChip->u64Freq<850000000))                u8OutDiv=8;
        else if((strChip->u64Freq>=850000000)&&(strChip->u64Freq<1700000000))                u8OutDiv=4;
        else if((strChip->u64Freq>=1700000000)&&(strChip->u64Freq<3400000000))            u8OutDiv=2;
        else                                                                                                                                                u8OutDiv=1;
     
        uint16_t u16Int=0;
        uint32_t u32Frac1=0;
        uint16_t u16Frac2=0;
        uint16_t u16Mod2=0;
     
        double     f64Vco=strChip->u64Freq*u8OutDiv;
        double   f64N=f64Vco/PFD;
     
        u16Int=(uint16_t)f64N;
     
        double     f64Frac=f64N-u16Int;
     
        u32Frac1=(uint32_t)(MOD1*f64Frac);
     
        double     f64Remainder=MOD1*f64Frac-u32Frac1;
     
        u16Mod2=PFD/u32Gcd;
        u16Frac2=u16Mod2*f64Remainder;
        /*
        reg4
        */
        u32Reg4Val=(7<<27)|(D<<26)|(T<<25)|(R<<15)|(1<<14)|\
        (u8ChargePimpCur<<10)|(0<<9)|(1<<8)|(1<<7)|(0<<6)|(0<<5)|(1<<4)|(4<<0);

        ADF43553_WriteData(u32Reg4Val);
        /*
        reg6
        30:门控
        29:低噪声控制(仅在整数模式有用)
        24:反馈模式
        21:输出分频
        11:1->锁定中静音
        9:0->辅助输出关闭
        7:辅助输出强度
        6:1->输出使能
        4:输出强度
        */
        switch(u8OutDiv)
        {
            case 1:{u8OutDiv=0;}break;
            case 2:{u8OutDiv=1;}break;
            case 4:{u8OutDiv=2;}break;
            case 8:{u8OutDiv=3;}break;
            case 16:{u8OutDiv=4;}break;
            case 32:{u8OutDiv=5;}break;
            case 64:{u8OutDiv=6;}break;
            default:break;
        }
        if(strChip->Chip==RF)
        {
            u32Reg6Val=(0<<30)|(1<<29)|(10<<25)|(1<<24)|((uint32_t)u8OutDiv<<21)|\
            (0X0A<<12)|(1<<11)|(1<<10)|(0<<9)|(1<<7)|(1<<6)|((uint32_t)strChip->Lev<<4)|(6<<0);         
        }
        else
        {
            u32Reg6Val=(0<<30)|(1<<29)|(10<<25)|(1<<24)|((uint32_t)u8OutDiv<<21)|\
            (0X0A<<12)|(1<<11)|(1<<10)|(1<<9)|((uint32_t)strChip->Lev<<7)|(1<<6)|((uint32_t)strChip->Lev<<4)|(6<<0);         
        }

        ADF43553_WriteData(u32Reg6Val);
     
        /*
        reg2
        18:FRAC2
        4:MOD2
        */
        u32Reg2Val=((uint32_t)u16Frac2<<18)|((uint32_t)u16Mod2<<4)|(2<<0);
        ADF43553_WriteData(u32Reg2Val); 
        /*
        reg1
        4:FRAC1
        */
        u32Reg1Val=(u32Frac1<<4)|(1<<0);
        ADF43553_WriteData(u32Reg1Val);
     
//        u32Reg0Val=(0<<21)|(0<<20)|((uint32_t)u16Int<<4)|(0<<0);
//        ADF43553_WriteData(u32Reg0Val);

        u32Reg4Val=(7<<27)|(D<<26)|(T<<25)|(R<<15)|(1<<14)|\
        (u8ChargePimpCur<<10)|(0<<9)|(1<<8)|(1<<7)|(0<<6)|(0<<5)|(0<<4)|(4<<0);
        ADF43553_WriteData(u32Reg4Val);

        for(uint16_t i=0;i<6000;i++);

        /*
        reg10
        4:1->打开温度补偿
        5:1->打开ADC
        6:ADC频率分频值1~255
        */
        uint8_t u8AdDiv=0;
     
        //求最接近整数的值
        u8AdDiv=((float)PFD/100000-2)/4+0.5f;
     
        u32Reg10Val=(1<<26)|(3<<22)|((uint32_t)u8AdDiv<<6)|(1<<5)|(1<<4)|(10<<0);
        ADF43553_WriteData(u32Reg10Val); 
     
        u32Reg7Val=(1<<28)|(1<<25)|(6<<12)|(2<<8)|(0<<7)|(3<<5)|(0<<4)|(7<<0);
        ADF43553_WriteData(u32Reg7Val); 

        u32Reg0Val=(1<<21)|(0<<20)|((uint32_t)u16Int<<4)|(0<<0);
        ADF43553_WriteData(u32Reg0Val);
     
        for(uint32_t i=0;i<600000;i++);
     
        uint32_t u32Over=0;
     
        u32Over=0XFFFFFF;
        while((SET!=RBDEV_MISO_DATA)&&\
            (u32Over--));
     
        if(0==u32Over)
        {
            if(cnt)
            {
                cnt-=1;
            }
         
            ADF4355_TRACE("Re Freq!!\r\n");
         
            continue;
        }
     
        u32Reg7Val=(1<<28)|(1<<25)|(7<<12)|(2<<8)|(0<<7)|(3<<5)|(0<<4)|(7<<0);
        ADF43553_WriteData(u32Reg7Val);
     
        uint16_t u16CoreBand;
        uint8_t u8Core,u8Band;
     
        ADF43553_ReadCalData(&u16CoreBand);
     
        u8Core=(u16CoreBand&0x3800)>>11;
        u8Band=(u16CoreBand&0x7f8)>>3;
     
        ADF4355_TRACE("u16CoreBand=%#x,Core=%#x,Band=%d\r\n",u16CoreBand,u8Core,u8Band);
     
        switch(u8Core)
        {
            case 3:
            {
                u8Core=4;
            }break;
            case 4:
            {
                u8Core=8;
            }break;
            default:break;
        }
     
        pBuf[cnt].u8Core=u8Core;
        pBuf[cnt].u8Band=u8Band;

     
        u32Reg10Val=(3<<26)|(3<<22)|((uint32_t)u8AdDiv<<6)|(1<<5)|(1<<4)|(10<<0);
        ADF43553_WriteData(u32Reg10Val); 
             
        uint16_t u16Bias;
        uint8_t u8Bias;
     
        ADF43553_ReadCalData(&u16Bias); 
     
        u8Bias=(u16Bias&0x78)>>3;
     
        ADF4355_TRACE("u16Bias=%#x,Bias code=%d\r\n",u16Bias,u8Bias);     
     
        pBuf[cnt].u8Bias=u8Bias;
     
        uint8_t u8_DisBuf[20];
     
        sprintf((char *)u8_DisBuf,"Plan:%.2f%%",(float)(cnt+1)*100/3401);
        LCD_DisString(x,y,(const char*)u8_DisBuf,GUI_BLUE,GUI_WHITE,FONT8x16IN);
        IWDG_ReloadCounter();//喂狗
    }
}



 

 

另外再附上调用此函数后得到的串口输出结果,详情请查看附件。

附件

結果