Added LO offset

master
ismagom 10 years ago
parent 104efa35ff
commit 93e98cd214

@ -116,7 +116,8 @@ void radio_uhd::set_rx_srate(float srate)
void radio_uhd::set_tx_freq(float freq) void radio_uhd::set_tx_freq(float freq)
{ {
cuhd_set_tx_freq(uhd, freq); //cuhd_set_tx_freq(uhd, freq);
cuhd_set_tx_freq_offset(uhd, freq, 8e6);
} }
void radio_uhd::set_tx_gain(float gain) void radio_uhd::set_tx_gain(float gain)

@ -162,7 +162,7 @@ int cuhd_open_(char *args, void **h, bool create_thread_gain, bool tx_gain_same_
{ {
cuhd_handler *handler = new cuhd_handler(); cuhd_handler *handler = new cuhd_handler();
std::string _args = std::string(args); std::string _args = std::string(args);
handler->usrp = uhd::usrp::multi_usrp::make(_args + ", master_clock_rate=30720000, num_recv_frames=512"); handler->usrp = uhd::usrp::multi_usrp::make(_args);// + ", master_clock_rate=30720000, num_recv_frames=512");
// handler->usrp = uhd::usrp::multi_usrp::make(_args + ", master_clock_rate=50000000" + ", num_recv_frames=512"); // handler->usrp = uhd::usrp::multi_usrp::make(_args + ", master_clock_rate=50000000" + ", num_recv_frames=512");
handler->usrp->set_clock_source("internal"); handler->usrp->set_clock_source("internal");

@ -149,12 +149,12 @@ int main(int argc, char **argv) {
} }
printf("Subframe len: %d samples\n", flen); printf("Subframe len: %d samples\n", flen);
printf("Set TX/RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000); printf("Set TX/RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);
printf("Set TX/RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain)); printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain));
printf("Set TX gain: %.1f dB\n", cuhd_set_tx_gain(uhd, uhd_gain));
printf("Set TX/RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); printf("Set TX/RX freq: %.2f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(nof_prb)); cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(nof_prb));
cuhd_set_tx_gain(uhd, uhd_gain); cuhd_set_tx_freq_offset(uhd, uhd_freq, 8e6);
cuhd_set_tx_freq(uhd, uhd_freq); sleep(1);
cuhd_rx_wait_lo_locked(uhd);
cf_t *zeros = calloc(sizeof(cf_t),flen); cf_t *zeros = calloc(sizeof(cf_t),flen);
@ -169,19 +169,23 @@ int main(int argc, char **argv) {
uint32_t nframe=0; uint32_t nframe=0;
while(nframe<nof_frames) { while(nframe<nof_frames) {
printf("Rx subframe %d\n", nframe);
cuhd_recv_with_time(uhd, &buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs); cuhd_recv_with_time(uhd, &buffer[flen*nframe], flen, true, &tstamp.full_secs, &tstamp.frac_secs);
nframe++; nframe++;
if (nframe==9 || nframe==8) { if (nframe==9 || nframe==8 || nframe==10) {
srslte_timestamp_add(&tstamp, 0, 2e-3); srslte_timestamp_add(&tstamp, 0, 2e-3);
if (nframe==8) { if (nframe==8) {
cuhd_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false); cuhd_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, true, false);
printf("Transmitting zeros\n"); printf("Transmitting zeros\n");
} else { } else if (nframe == 9) {
cuhd_send_timed2(uhd, preamble, flen, tstamp.full_secs, tstamp.frac_secs, false, true); cuhd_send_timed2(uhd, preamble, flen, tstamp.full_secs, tstamp.frac_secs, false, false);
printf("Transmitting PRACH\n"); printf("Transmitting PRACH\n");
} else {
cuhd_send_timed2(uhd, zeros, flen, tstamp.full_secs, tstamp.frac_secs, false, true);
printf("Transmitting zeros\n");
} }
} }
printf("Rx subframe %d\n", nframe);
} }
if (f) { if (f) {
fwrite(&buffer[10*flen], flen*sizeof(cf_t), 1, f); fwrite(&buffer[10*flen], flen*sizeof(cf_t), 1, f);

Loading…
Cancel
Save