• 大小: 5.67MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-03
  • 语言: 其他
  • 标签: LMX2572  TICS  

资源简介

程序配置参考时钟,输出,自动配置寄存器 int lmx2572_set_ref(uint32_t ref_freq, bool doubler, int pre_R, int multiplier, int R); int lmx2572_set_freq(float freq);

资源截图

代码片段和文件信息

#include “LMX2572.h“
#include “LMX2572_default.h“
#include 
#include 

uint32_t pfd_freq;
uint16_t regs[126];

void lmx2572_write_reg(uint8_t address uint16_t data)
{
// cs->write(0);
// spi->txrx(address&0x7f);
// spi->txrx((data>>8)&0xff);
// spi->txrx(data&0xff);
// cs->write(1);
}
uint16_t lmx2572_read_reg(uint8_t address)
{
uint16_t value;
// cs->write(0);
// spi->txrx((address&0x7f) | 0x80);
// value = spi->txrx(0) << 8;
// value |= spi->txrx(0);
// cs->write(1);

return value;
}

bool lmx2572_is_locked()
{
uint16_t reg110 = lmx2572_read_reg(110);
return ((reg110>>9)&0x3) == 0x02;
}


int LMX2572_init(void)

memcpy(regs LMX2572_default_regs sizeof(regs));
for(int i=0; i<=126; i++)
lmx2572_write_reg(i regs[i]);
return 0;
}

int lmx2572_set_ref(uint32_t ref_freq bool doubler int pre_R int multiplier int R)
{
// note:multiplier *8-31 is allowed but not recommended
// also use doubler instead of multiplier 2 

// 
if(doubler)
ref_freq *= 2;

pre_R &= 0xfff; // 12bit pre-R;
multiplier &= 0x1f; // 5bit multiplier
R &= 0xff; // 8bit R

pfd_freq = ref_freq * multiplier / pre_R / R;

regs[11] = 0xB008 | (R<<4);
regs[10] = 0x1078 | (multiplier<<7);
regs[9] = 0x4;
if (doubler)
regs[9] |= 0x1000;
if (pfd_freq > 100000000)
regs[9] |= 0x4000;

for(int i=9; i<=11; i++)
lmx2572_write_reg(i regs[i]);

return 0;
}

int lmx2572_set_output(bool enable int power)
{
// B disabled

power &= 0x3f;
regs[44] = 0xA2 | (power << 8);
if (!enable)
regs[44] |= 0x40;
lmx2572_write_reg(44 regs[44]);

return 0;
}

int lmx2572_set_freq(float freq)
{
int div = 0;
uint32_t denum = 1000;
int divider_tbl[9] = {0 0 1 3 5 7 9 12 14};// strange divider table of R75
uint64_t vco_freq = (uint64_t)(freq*1000000);// allowed vco range: 3.2G to 6.4G

while (vco_freq<3200000000)
{
div ++;
vco_freq *= 2;
}

if (div > 8)
return -1;

int N = vco_freq/pfd_freq;
int FRAC = (vco_freq - N * (uint64_t)pfd_freq) * denum / pfd_freq;

printf(“vco :%ld\r\n“pfd_freq);
printf(“div :%d\r\n“div*2);
printf(“vco :%lld\r\n“vco_freq);
printf(“N   :%d\r\n“N);
printf(“FRAC:%d\r\n“FRAC);

regs[34] = ((N>>16)&0x7) | 0x10;
regs[36] = N;
regs[38] = denum>>16;
regs[39] = denum;
regs[42] = FRAC>>16;
regs[43] = FRAC;
regs[45] = (div == 0) ? 0xCE22 : 0xC622;
regs[75] = 0x0800 | (divider_tbl[div]<<6);

lmx2572_write_reg(75 regs[75]);
lmx2572_write_reg(45 regs[45]);
lmx2572_write_reg(39 regs[39]);
lmx2572_write_reg(38 regs[38]);
lmx2572_write_reg(43 regs[43]);
lmx2572_write_reg(42 regs[42]);
lmx2572_write_reg(36 regs[36]);
lmx2572_write_reg(34 regs[34]); // write N last
lmx2572_write_reg(0 regs[0]); // FCAL_EN

return 0;
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      35328  2020-11-04 20:54  LMX2572LP\Debug\LMX2572LP.exe

     文件     257824  2020-11-04 20:54  LMX2572LP\Debug\LMX2572LP.ilk

     文件     568320  2020-11-04 20:54  LMX2572LP\Debug\LMX2572LP.pdb

     文件       1130  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\cl.command.1.tlog

     文件      21186  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\CL.read.1.tlog

     文件       1326  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\CL.write.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link-cvtres.read.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link-cvtres.write.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link-rc.read.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link-rc.write.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.1212-cvtres.read.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.1212-cvtres.write.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.1212-rc.read.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.1212-rc.write.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.1212.read.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.1212.write.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.6300-cvtres.read.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.6300-cvtres.write.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.6300-rc.read.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.6300-rc.write.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.6300.read.1.tlog

     文件          2  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.6300.write.1.tlog

     文件       1336  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.command.1.tlog

     文件       2652  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.read.1.tlog

     文件        648  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\link.write.1.tlog

     文件      13556  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\LMX2572.obj

     文件         74  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\LMX2572LP.lastbuildstate

     文件       2069  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\LMX2572LP.log

     文件      26980  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\main.obj

     文件     510976  2020-11-04 20:54  LMX2572LP\LMX2572LP\Debug\vc110.idb

............此处省略17个文件信息

评论

共有 条评论