diff --git a/srslte/examples/cell_measurement.c b/srslte/examples/cell_measurement.c index 1a6ab2059..8c8ee4903 100644 --- a/srslte/examples/cell_measurement.c +++ b/srslte/examples/cell_measurement.c @@ -34,7 +34,6 @@ #include #include #include -#include #include "srslte/srslte.h" #include "srslte/cuhd/cuhd.h" @@ -168,6 +167,8 @@ int main(int argc, char **argv) { cuhd_set_rx_gain(uhd, 50); } + cuhd_set_master_clock_rate(uhd, 30.72e6); + /* set receiver frequency */ cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq); cuhd_rx_wait_lo_locked(uhd); @@ -183,17 +184,23 @@ int main(int argc, char **argv) { } /* set sampling frequency */ - int srate = srslte_sampling_freq_hz(cell.nof_prb); - if (srate != -1) { - /* Modify master clock rate for 15 Mhz */ - if (cell.nof_prb == 75) { - cuhd_set_master_clock_rate(uhd, 23.04e6); + int srate = srslte_sampling_freq_hz(cell.nof_prb); + if (srate != -1) { + if (srate < 10e6) { + cuhd_set_master_clock_rate(uhd, 4*srate); + } 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); + } + } else { + fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb); + exit(-1); } - cuhd_set_rx_srate(uhd, (double) srate); - } else { - fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb); - return SRSLTE_ERROR; - } INFO("Stopping UHD and flushing buffer...\n",0); cuhd_stop_rx_stream(uhd); diff --git a/srslte/examples/cell_search.c b/srslte/examples/cell_search.c index 57601f840..0f90cd1c1 100644 --- a/srslte/examples/cell_search.c +++ b/srslte/examples/cell_search.c @@ -165,6 +165,9 @@ int main(int argc, char **argv) { } cuhd_set_rx_gain(uhd, 50); } + + cuhd_set_master_clock_rate(uhd, 30.72e6); + // Supress UHD messages cuhd_supress_stdout(); diff --git a/srslte/examples/pdsch_enodeb.c b/srslte/examples/pdsch_enodeb.c index 621e4b634..4e9b83608 100644 --- a/srslte/examples/pdsch_enodeb.c +++ b/srslte/examples/pdsch_enodeb.c @@ -490,6 +490,9 @@ int main(int argc, char **argv) { } #ifndef DISABLE_UHD + + cuhd_set_master_clock_rate(uhd, 30.72e6); + if (!output_file_name) { printf("Set TX rate: %.2f MHz\n", cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000); diff --git a/srslte/examples/pdsch_ue.c b/srslte/examples/pdsch_ue.c index 19abf481c..d58521bee 100644 --- a/srslte/examples/pdsch_ue.c +++ b/srslte/examples/pdsch_ue.c @@ -324,8 +324,7 @@ int main(int argc, char **argv) { } while (ret == 0); /* 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 < 10e6) { cuhd_set_master_clock_rate(uhd, 4*srate); diff --git a/srslte/examples/prach_ue.c b/srslte/examples/prach_ue.c index db37631b4..0e85a8278 100644 --- a/srslte/examples/prach_ue.c +++ b/srslte/examples/prach_ue.c @@ -312,6 +312,8 @@ int main(int argc, char **argv) { exit(-1); } + cuhd_set_master_clock_rate(uhd, 30.72e6); + /* Set receiver gain */ float x = cuhd_set_rx_gain(uhd, prog_args.uhd_rx_gain); printf("Set RX gain to %.1f dB\n", x); @@ -342,18 +344,23 @@ cell.id = 1; cell.nof_ports = 1; /* set sampling frequency */ - int srate = srslte_sampling_freq_hz(cell.nof_prb); - if (srate != -1) { - /* Modify master clock rate for 15 Mhz */ - if (cell.nof_prb == 75) { - cuhd_set_master_clock_rate(uhd, 23.04e6); + int srate = srslte_sampling_freq_hz(cell.nof_prb); + if (srate != -1) { + if (srate < 10e6) { + cuhd_set_master_clock_rate(uhd, 4*srate); + } 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); + } + } else { + fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb); + exit(-1); } - cuhd_set_rx_srate(uhd, (double) srate); - cuhd_set_tx_srate(uhd, (double) srate); - } else { - fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb); - exit(-1); - } INFO("Stopping UHD and flushing buffer...\r",0); cuhd_stop_rx_stream(uhd); diff --git a/srslte/examples/usrp_capture.c b/srslte/examples/usrp_capture.c index a4f555663..6036dc4e0 100644 --- a/srslte/examples/usrp_capture.c +++ b/srslte/examples/usrp_capture.c @@ -122,6 +122,8 @@ int main(int argc, char **argv) { fprintf(stderr, "Error opening uhd\n"); 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 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); diff --git a/srslte/examples/usrp_capture_sync.c b/srslte/examples/usrp_capture_sync.c index 073029e51..edb3bfabe 100644 --- a/srslte/examples/usrp_capture_sync.c +++ b/srslte/examples/usrp_capture_sync.c @@ -123,6 +123,8 @@ int main(int argc, char **argv) { fprintf(stderr, "Error opening uhd\n"); 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 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); diff --git a/srslte/examples/usrp_txrx.c b/srslte/examples/usrp_txrx.c index 5784febd1..298aa30ee 100644 --- a/srslte/examples/usrp_txrx.c +++ b/srslte/examples/usrp_txrx.c @@ -126,6 +126,8 @@ int main(int argc, char **argv) { fprintf(stderr, "Error opening uhd\n"); exit(-1); } + cuhd_set_master_clock_rate(uhd, 30.72e6); + 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 RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_rx_gain));