|
|
@@ -80,91 +80,85 @@ double ad9912_set_main_band(double lmx_freq,double f_pd) {
|
|
|
}
|
|
|
|
|
|
double ad9912_set_out_of_band(double lmx_freq,double f_pd) {
|
|
|
-
|
|
|
- printf("f_pd in out_of_band func = %f\n",f_pd);
|
|
|
- printf("freq in func = %f\n",lmx_freq);
|
|
|
- // if (freq >100e3 && freq <=1000e6) {
|
|
|
- // lmx_freq = 4000e6-freq;
|
|
|
- // }
|
|
|
- // else {
|
|
|
- // lmx_freq = freq;
|
|
|
- // }
|
|
|
+
|
|
|
double f_vco = 2*lmx_freq; // VCO frequency
|
|
|
double vco_div = 7.5e9/lmx_freq;
|
|
|
int chan_div = 2;
|
|
|
|
|
|
if (f_vco < 7.5e9) {
|
|
|
- if (vco_div > 2 && vco_div <= 4)
|
|
|
+ if (vco_div > 2 && vco_div <= 4) {
|
|
|
chan_div = 4; // 4
|
|
|
- f_vco = lmx_freq * chan_div;
|
|
|
- if (vco_div > 4 && vco_div <= 6) {
|
|
|
+ f_vco = lmx_freq * chan_div;
|
|
|
+ }
|
|
|
+ else if (vco_div > 4 && vco_div <= 6) {
|
|
|
chan_div = 6; // 6
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 6 && vco_div <= 8) {
|
|
|
+ else if (vco_div > 6 && vco_div <= 8) {
|
|
|
chan_div = 8; // 8
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 8 && vco_div <= 12) {
|
|
|
+ else if (vco_div > 8 && vco_div <= 12) {
|
|
|
chan_div = 12; // 12
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 12 && vco_div <= 16) {
|
|
|
+ else if (vco_div > 12 && vco_div <= 16) {
|
|
|
chan_div = 16; // 16
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 16 && vco_div <= 24) {
|
|
|
+ else if (vco_div > 16 && vco_div <= 24) {
|
|
|
chan_div = 24; // 24
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 24 && vco_div <= 32) {
|
|
|
+ else if (vco_div > 24 && vco_div <= 32) {
|
|
|
chan_div = 32; // 32
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 32 && vco_div <= 48) {
|
|
|
+ else if (vco_div > 32 && vco_div <= 48) {
|
|
|
chan_div = 48; // 48
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 48 && vco_div <= 64) {
|
|
|
+ else if (vco_div > 48 && vco_div <= 64) {
|
|
|
chan_div = 64; // 64
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 64 && vco_div <= 72) {
|
|
|
+ else if (vco_div > 64 && vco_div <= 72) {
|
|
|
chan_div = 72; // 72
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 72 && vco_div <= 96) {
|
|
|
+ else if (vco_div > 72 && vco_div <= 96) {
|
|
|
chan_div = 96; // 96
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 96 && vco_div <= 128) {
|
|
|
+ else if (vco_div > 96 && vco_div <= 128) {
|
|
|
chan_div = 128; // 128
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 128 && vco_div <= 192) {
|
|
|
+ else if (vco_div > 128 && vco_div <= 192) {
|
|
|
chan_div = 192; // 192
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 192 && vco_div <= 256) {
|
|
|
+ else if (vco_div > 192 && vco_div <= 256) {
|
|
|
chan_div = 256; // 256
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 256 && vco_div <= 384) {
|
|
|
+ else if (vco_div > 256 && vco_div <= 384) {
|
|
|
chan_div = 384; // 384
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 384 && vco_div <= 512) {
|
|
|
+ else if (vco_div > 384 && vco_div <= 512) {
|
|
|
chan_div = 512; // 512
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
- if (vco_div > 512 && vco_div <= 768) {
|
|
|
+ else if (vco_div > 512 && vco_div <= 768) {
|
|
|
chan_div = 768; // 768
|
|
|
f_vco = lmx_freq * chan_div;
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ f_vco = lmx_freq * 2;
|
|
|
+ }
|
|
|
|
|
|
- printf ("Chan_div in func = %d\n",chan_div);
|
|
|
- printf("F_vco in func = %f\n",f_vco);
|
|
|
// Divide the frequncy by the old value of the phase detector frequency and only left with the integer part
|
|
|
uint32_t N = (uint32_t) (f_vco/f_pd);
|
|
|
if (f_vco <= 12500e6) {
|
|
|
@@ -177,7 +171,6 @@ double ad9912_set_out_of_band(double lmx_freq,double f_pd) {
|
|
|
N = 32;
|
|
|
}
|
|
|
};
|
|
|
- printf("N = %d\n", N);
|
|
|
// Calculate the new phase detector frequency by dividing the frequency by the new value of N
|
|
|
f_pd = f_vco/N; // Phase detector frequency
|
|
|
|
|
|
@@ -240,13 +233,12 @@ double ad9912_set(void *bar1, double freq, double f_pd) {
|
|
|
};
|
|
|
|
|
|
// Create the appropriate header
|
|
|
- uint32_t *DDS_HEADER = bar1 + AD9912_BASE_ADDR;
|
|
|
- *DDS_HEADER = ((0 << 23) | (DeviceIdDDS << 18) | ((sizeof(ad9912_ftw_regs)/4) << 1) | 1);
|
|
|
-
|
|
|
+ uint32_t *dds_header = bar1 + AD9912_BASE_ADDR;
|
|
|
+ *dds_header = ((0 << 23) | (DeviceIdDDS << 18) | ((sizeof(ad9912_ftw_regs)/4) << 1) | 1);
|
|
|
+ uint32_t *dds_data = bar1 + AD9912_BASE_ADDR;
|
|
|
// Write the data
|
|
|
for (int i = 0; i < sizeof(ad9912_ftw_regs)/4; i++) {
|
|
|
- uint32_t *DDS_DATA = bar1 + AD9912_BASE_ADDR;
|
|
|
- *DDS_DATA = ad9912_ftw_regs[i];
|
|
|
+ *dds_data = ad9912_ftw_regs[i];
|
|
|
}
|
|
|
|
|
|
return f_pd;
|