Fixed rest of examples for new UHD driver

master
ismagom 9 years ago
parent efb331439e
commit a5b52179fa

@ -34,7 +34,6 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <signal.h>
#include "srslte/srslte.h" #include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h" #include "srslte/cuhd/cuhd.h"
@ -168,6 +167,8 @@ int main(int argc, char **argv) {
cuhd_set_rx_gain(uhd, 50); cuhd_set_rx_gain(uhd, 50);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6);
/* set receiver frequency */ /* set receiver frequency */
cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq); cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq);
cuhd_rx_wait_lo_locked(uhd); cuhd_rx_wait_lo_locked(uhd);
@ -185,14 +186,20 @@ int main(int argc, char **argv) {
/* set sampling frequency */ /* set sampling frequency */
int srate = srslte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
/* Modify master clock rate for 15 Mhz */ if (srate < 10e6) {
if (cell.nof_prb == 75) { cuhd_set_master_clock_rate(uhd, 4*srate);
cuhd_set_master_clock_rate(uhd, 23.04e6); } else {
cuhd_set_master_clock_rate(uhd, srate);
}
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
if (srate_uhd != srate) {
fprintf(stderr, "Could not set sampling rate\n");
exit(-1);
} }
cuhd_set_rx_srate(uhd, (double) srate);
} else { } else {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb); fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
return SRSLTE_ERROR; exit(-1);
} }
INFO("Stopping UHD and flushing buffer...\n",0); INFO("Stopping UHD and flushing buffer...\n",0);

@ -165,6 +165,9 @@ int main(int argc, char **argv) {
} }
cuhd_set_rx_gain(uhd, 50); cuhd_set_rx_gain(uhd, 50);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6);
// Supress UHD messages // Supress UHD messages
cuhd_supress_stdout(); cuhd_supress_stdout();

@ -490,6 +490,9 @@ int main(int argc, char **argv) {
} }
#ifndef DISABLE_UHD #ifndef DISABLE_UHD
cuhd_set_master_clock_rate(uhd, 30.72e6);
if (!output_file_name) { if (!output_file_name) {
printf("Set TX rate: %.2f MHz\n", printf("Set TX rate: %.2f MHz\n",
cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000); cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000);

@ -325,7 +325,6 @@ int main(int argc, char **argv) {
/* set sampling frequency */ /* set sampling frequency */
int srate = srslte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
if (srate < 10e6) { if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate); cuhd_set_master_clock_rate(uhd, 4*srate);

@ -312,6 +312,8 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6);
/* Set receiver gain */ /* Set receiver gain */
float x = cuhd_set_rx_gain(uhd, prog_args.uhd_rx_gain); float x = cuhd_set_rx_gain(uhd, prog_args.uhd_rx_gain);
printf("Set RX gain to %.1f dB\n", x); printf("Set RX gain to %.1f dB\n", x);
@ -344,12 +346,17 @@ cell.nof_ports = 1;
/* set sampling frequency */ /* set sampling frequency */
int srate = srslte_sampling_freq_hz(cell.nof_prb); int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) { if (srate != -1) {
/* Modify master clock rate for 15 Mhz */ if (srate < 10e6) {
if (cell.nof_prb == 75) { cuhd_set_master_clock_rate(uhd, 4*srate);
cuhd_set_master_clock_rate(uhd, 23.04e6); } else {
cuhd_set_master_clock_rate(uhd, srate);
}
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
if (srate_uhd != srate) {
fprintf(stderr, "Could not set sampling rate\n");
exit(-1);
} }
cuhd_set_rx_srate(uhd, (double) srate);
cuhd_set_tx_srate(uhd, (double) srate);
} else { } else {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb); fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
exit(-1); exit(-1);

@ -122,6 +122,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6);
printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
printf("Set 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 RX rate: %.6f MHz\n", cuhd_set_rx_srate(uhd, uhd_rate*1e6) / 1000000); printf("Set RX rate: %.6f MHz\n", cuhd_set_rx_srate(uhd, uhd_rate*1e6) / 1000000);

@ -123,6 +123,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6);
printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000); printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
printf("Set 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 RX rate: %.6f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000); printf("Set RX rate: %.6f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);

@ -126,6 +126,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error opening uhd\n"); fprintf(stderr, "Error opening uhd\n");
exit(-1); exit(-1);
} }
cuhd_set_master_clock_rate(uhd, 30.72e6);
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 RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_rx_gain)); printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_rx_gain));

Loading…
Cancel
Save