LMX2581部分频点无法锁定
Dear Everybody
用LMX2581做一个宽带扫频信号源,
我现在遇到一个很奇怪的问题,
用MCU写LMX2581,PLL_N设置在94~188,寄存器配置值是由coderloader生成的。
PLL_N在几个值会出现无法锁定,比如135~139,还有当PLL_N大于 164就无法锁定,而且需要复位配置PLL_N小于164,LMX2581才恢复正常工作。
但是用coderloader 连接到我的板子上,怎么配置PLL_N都没问题。
无法锁定的频点,测量Vtune的电压, 小于 1V或着是3.12V。
求解。
此外,我的环路滤波器,配置和EVK板是一样的。
自己搞定了,
被coderloader给坑了。
还是有就是初始化完,要延时20ms才能操作。
大家可以参考下初始化。
///////////////////////////////////////////////////////////////////////宏定义文件/////////////////////////////////////////////
//Roy Ye @2016/10/17
#define LMX2581_REG_R15 0x0F
#define LMX2581_REG_R14 0x0E
#define LMX2581_REG_R13 0x0D
#define LMX2581_REG_R12 0x0C
#define LMX2581_REG_R11 0x0B
#define LMX2581_REG_R10 0x0A
#define LMX2581_REG_R9 0x09
#define LMX2581_REG_R8 0x08
#define LMX2581_REG_R7 0x07
#define LMX2581_REG_R6 0x06
#define LMX2581_REG_R5 0x05
#define LMX2581_REG_R4 0x04
#define LMX2581_REG_R3 0x03
#define LMX2581_REG_R2 0x02
#define LMX2581_REG_R1 0x01
#define LMX2581_REG_R0 0x00
//R15
#define LMX2581_VCO_CAPCODE(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_VCO_CAP_MAN(DAT) (uint32_t)((DAT)<<8)
#define LMX2581_R15_DEFBIT (uint32_t)0x021FE00
//R13
#define LMX2581_R13_DEFBIT (uint32_t)0x0000410
#define LMX2581_DLD_TOL(DAT) (uint32_t)((DAT)<<11)
#define LMX2581_DLD_PASS_CNT(DAT) (uint32_t)((DAT)<<14)
#define LMX2581_DLD_ERR_CNT(DAT) (uint32_t)((DAT)<<24)
//R10
#define LMX2581_R10_DEFBIT (uint32_t)0x210050C
//R9
#define LMX2581_R9_DEFBIT (uint32_t)0x03C7C03
//R8
#define LMX2581_R8_DEFBIT (uint32_t)0x207DDBF
//R7
#define LMX2581_LD_PINMODE(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_LD_INV(DAT) (uint32_t)((DAT)<<3)
#define LMX2581_LD_SELECT(DAT) (uint32_t)((DAT)<<4)
#define LMX2581_MUX_PINMODE(DAT) (uint32_t)((DAT)<<9)
#define LMX2581_MUX_INV(DAT) (uint32_t)((DAT)<<12)
#define LMX2581_MUX_SELECT(DAT) (uint32_t)((DAT)<<13)
#define LMX2581_FL_INV(DAT) (uint32_t)((DAT)<<18)
#define LMX2581_FL_PINMODE(DAT) (uint32_t)((DAT)<<19)
#define LMX2581_FL_SELECT(DAT) (uint32_t)((DAT)<<22)
//R6
#define LMX2581_UWIRE_LOCK(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_RDADDR(DAT) (uint32_t)((DAT)<<1)
#define LMX2581_RD_DIAGNOSTICS(DAT) (uint32_t)((DAT)<<7)
#define LMX2581_R6_DEFBIT (uint32_t)0x0000020
//R5
#define LMX2581_RESET(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_PWDN_MODE(DAT) (uint32_t)((DAT)<<1)
#define LMX2581_MODE(DAT) (uint32_t)((DAT)<<4)
#define LMX2581_0_DLY(DAT) (uint32_t)((DAT)<<6)
#define LMX2581_OUTA_MUX(DAT) (uint32_t)((DAT)<<7)
#define LMX2581_OUTB_MUX(DAT) (uint32_t)((DAT)<<9)
#define LMX2581_VCO_SEL_MODE(DAT) (uint32_t)((DAT)<<11)
#define LMX2581_BUF_EN_DIS(DAT) (uint32_t)((DAT)<<16)
#define LMX2581_OSC_FREQ(DAT) (uint32_t)((DAT)<<17)
#define LMX2581_OUT_LD_EN(DAT) (uint32_t)((DAT)<<20)
#define LMX2581_R5_DEFBIT (uint32_t)0x0000000
//R4
#define LMX2581_CPG_BLEED(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_FL_CPG(DAT) (uint32_t)((DAT)<<7)
#define LMX2581_FL_TOC(DAT) (uint32_t)((DAT)<<12)
#define LMX2581_FL_FRCE(DAT) (uint32_t)((DAT)<<24)
#define LMX2581_PFD_DLY(DAT) (uint32_t)((DAT)<<25)
//R3
#define LMX2581_OUTA_PD(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_OUTB_PD(DAT) (uint32_t)((DAT)<<1)
#define LMX2581_OUTA_PWR(DAT) (uint32_t)((DAT)<<2)
#define LMX2581_OUTB_PWR(DAT) (uint32_t)((DAT)<<8)
#define LMX2581_VCO_div(DAT) (uint32_t)((DAT)<<14)
#define LMX2581_R3_DEFBIT (uint32_t)0x2000000
//R2
#define LMX2581_PLL_DEN(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_CPP(DAT) (uint32_t)((DAT)<<23)
#define LMX2581_OSC_2X(DAT) (uint32_t)((DAT)<<25)
#define LMX2581_R2_DEFBIT (uint32_t)0x0400000
//R1
#define LMX2581_PLL_R(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_FRAC_ORDER(DAT) (uint32_t)((DAT)<<8)
#define LMX2581_PLL_NUM_H(DAT) (uint32_t)((DAT)<<11)
#define LMX2581_VCO_SEL(DAT) (uint32_t)((DAT)<<21)
#define LMX2581_CPG(DAT) (uint32_t)((DAT)<<23)
//R0
#define LMX2581_PLL_NUM_L(DAT) (uint32_t)((DAT)<<0)
#define LMX2581_PLL_N(DAT) (uint32_t)((DAT)<<12)
#define LMX2581_NO_FCAL(DAT) (uint32_t)((DAT)<<24)
#define LMX2581_FRAC_DITHER(DAT) (uint32_t)((DAT)<<25)
#define LMX2581_ID(DAT) (uint32_t)((DAT)<<27)
#define FREQ_VCO1_MIN 1800
#define FREQ_VCO1_MAX 2270
#define FREQ_VCO2_MIN 2135
#define FREQ_VCO2_MAX 2720
#define FREQ_VCO3_MIN 2610
#define FREQ_VCO3_MAX 3220
#define FREQ_VCO4_MIN 3075
#define FREQ_VCO4_MAX 3880
//Map of lmx2581E's register
typedef struct Lmx2581_reg_map
{
uint32_t r15;
uint32_t r14;
uint32_t r13;
uint32_t r12;
uint32_t r11;
uint32_t r10;
uint32_t r9;
uint32_t r8;
uint32_t r7;
uint32_t r6;
uint32_t r5;
uint32_t r4;
uint32_t r3;
uint32_t r2;
uint32_t r1;
uint32_t r0;
}Lmx2581_register_type;
#define FOSC 20000000
extern Lmx2581_register_type Lmx2581_register_lo;
extern Lmx2581_register_type Lmx2581_register_rf;
//codeLoader 产生的配置
#define R5_INT 0x40870010
#define R15 0x021FEFFF
#define R13 0x4082C10D
#define R10 0x210050CA
#define R9 0x03C7C039
#define R8 0x207DDBF8
#define R7 0x00086337
#define R6 0x000004C6
#define R5 0x00008885
#define R4 0x00000004
#define R3 0x204A5BE3
#define R2 0x0C04E202
#define R1 0xC4000011
#define R0 0x606F0000
uint8_t Lmx2581Initial(void);
void Lmx2581PowerDown(void);
void Lmx2581PowerOn(void);
void lmx2581writeonedata(uint32_t rf_dat,uint32_t lo_dat,uint8_t reg_addr);
uint32_t Lmx2581SetRfFrequency(uint32_t freq);
uint32_t Lmx2581SetLoFrequency(uint32_t freq);
void Lmx2581ReadBack(uint32_t reg_rf,uint32_t reg_lo);
///////////////////////////////////////////////////////////////////////程序文件/////////////////////////////////////////////
uint8_t Lmx2581Initial(void)
{
uint32_t regdat;
Lmx2581GpioInitial();
regdat=Lmx2581_register_rf.r5=Lmx2581_register_lo.r5=LMX2581_OUT_LD_EN(0)|LMX2581_OSC_FREQ(0)|LMX2581_BUF_EN_DIS(1)|
LMX2581_VCO_SEL_MODE(1)|LMX2581_OUTB_MUX(1)|LMX2581_OUTA_MUX(1)|LMX2581_0_DLY(1)|LMX2581_MODE(0)|
LMX2581_PWDN_MODE(4)|LMX2581_RESET(1)|LMX2581_R5_DEFBIT;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R5);
///**************************************************************/
//
for(uint32_t i=0;i<0xfffff;i++){}; //ÑÓʱ
regdat=Lmx2581_register_rf.r15=Lmx2581_register_lo.r15=LMX2581_VCO_CAPCODE(128)|LMX2581_VCO_CAP_MAN(0)|LMX2581_R15_DEFBIT;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R15);
/**************************************************************/
regdat=Lmx2581_register_rf.r13=Lmx2581_register_lo.r13 =LMX2581_DLD_ERR_CNT(4)|LMX2581_DLD_PASS_CNT(32)|LMX2581_DLD_TOL(5)|LMX2581_R13_DEFBIT;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R13);
regdat=Lmx2581_register_rf.r10=Lmx2581_register_lo.r10=R10>>4;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R10);
regdat=Lmx2581_register_rf.r9=Lmx2581_register_lo.r9=R9>>4;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R9);
regdat=Lmx2581_register_rf.r8=Lmx2581_register_lo.r8=R8>>4;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R8);
/**************************************************************/
regdat=Lmx2581_register_rf.r7=Lmx2581_register_lo.r7=LMX2581_LD_PINMODE(3)|LMX2581_LD_INV(0)|LMX2581_LD_SELECT(3)|
LMX2581_MUX_PINMODE(3)|LMX2581_MUX_INV(0)|LMX2581_MUX_SELECT(6)|
LMX2581_FL_PINMODE(0)|LMX2581_FL_INV(0)|LMX2581_FL_SELECT(0);
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R7);
/**************************************************************/
regdat=Lmx2581_register_rf.r6=Lmx2581_register_lo.r6= 0x000004C;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R6);
/**************************************************************/
regdat=Lmx2581_register_rf.r5=Lmx2581_register_lo.r5=LMX2581_OUT_LD_EN(0)|LMX2581_OSC_FREQ(0)|LMX2581_BUF_EN_DIS(1)|
LMX2581_VCO_SEL_MODE(1)|LMX2581_OUTB_MUX(0)|LMX2581_OUTA_MUX(1)|LMX2581_0_DLY(0)|LMX2581_MODE(0)|
LMX2581_PWDN_MODE(4)|LMX2581_RESET(0)|LMX2581_R5_DEFBIT;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R5);
/**************************************************************/
regdat=Lmx2581_register_rf.r4=Lmx2581_register_lo.r4=LMX2581_PFD_DLY(0)|LMX2581_FL_FRCE(0)|
LMX2581_FL_TOC(0)|LMX2581_FL_CPG(0)|LMX2581_CPG_BLEED(0);
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R4);
/**************************************************************/
regdat=Lmx2581_register_rf.r3=Lmx2581_register_lo.r3=LMX2581_VCO_div(18)|LMX2581_OUTB_PWR(15)|LMX2581_OUTA_PWR(15)|
LMX2581_OUTA_PD(0)|LMX2581_OUTB_PD(1)|LMX2581_R3_DEFBIT;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R3);
/**************************************************************/
regdat=Lmx2581_register_rf.r2=Lmx2581_register_lo.r2=LMX2581_PLL_DEN(4000000)|LMX2581_CPP(1)|
LMX2581_OSC_2X(0)|LMX2581_R2_DEFBIT;
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R2);
/**************************************************************/
regdat=Lmx2581_register_rf.r1=Lmx2581_register_lo.r1=LMX2581_CPG(24)|LMX2581_VCO_SEL(2)|
LMX2581_PLL_NUM_H(0)|LMX2581_FRAC_ORDER(3)|LMX2581_PLL_R(1);
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R1);
/**************************************************************/
regdat=Lmx2581_register_rf.r0=Lmx2581_register_lo.r0=LMX2581_ID(0)|LMX2581_FRAC_DITHER(2)|LMX2581_NO_FCAL(0)|
LMX2581_PLL_N(96)|LMX2581_PLL_NUM_L(5);
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R0);
for(uint32_t i=0;i<0xfffff;i++){}; //ÑÓʱ
lmx2581writeonedata(regdat,regdat,LMX2581_REG_R0);
}