From f991d3dc751e110425d4a0eed722f6de0fef4261 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 14 May 2011 19:57:03 -0700 Subject: usrp1: apply conditional disables/enables to rx and tx Scapped the old gnuradio code for information about VRQ_FPGA_SET_XX_ENABLE. It turns out that we should disabled + restore state when changing muxes or rates. The USRP seems to stream properly when receiving single and dual channel. Prior to this commit, tx was accicentally always disabled from a few commits ago. --- host/lib/usrp/usrp1/mboard_impl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'host/lib/usrp/usrp1/mboard_impl.cpp') diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index cd04e7351..d6f6832a4 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -339,7 +339,7 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) //handle the get request conditioned on the key switch(key.as()){ - case MBOARD_PROP_RX_SUBDEV_SPEC: + case MBOARD_PROP_RX_SUBDEV_SPEC:{ _rx_subdev_spec = val.as(); if (_rx_subdev_spec.size() > this->get_num_ddcs()){ throw uhd::value_error(str(boost::format( @@ -349,10 +349,12 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) } verify_rx_subdev_spec(_rx_subdev_spec, _mboard_proxy->get_link()); //set the mux and set the number of rx channels + bool s = this->disable_rx(); _iface->poke32(FR_RX_MUX, calc_rx_mux(_rx_subdev_spec, _mboard_proxy->get_link())); - return; + this->restore_rx(s); + }return; - case MBOARD_PROP_TX_SUBDEV_SPEC: + case MBOARD_PROP_TX_SUBDEV_SPEC:{ _tx_subdev_spec = val.as(); if (_tx_subdev_spec.size() > this->get_num_ducs()){ throw uhd::value_error(str(boost::format( @@ -362,8 +364,10 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) } verify_tx_subdev_spec(_tx_subdev_spec, _mboard_proxy->get_link()); //set the mux and set the number of tx channels + bool s = this->disable_tx(); _iface->poke32(FR_TX_MUX, calc_tx_mux(_tx_subdev_spec, _mboard_proxy->get_link())); - return; + this->restore_tx(s); + }return; case MBOARD_PROP_EEPROM_MAP: // Step1: commit the map, writing only those values set. -- cgit v1.2.3 From 4b772ff4f3b1e388e150402beaf6567f3ea29e1c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 14 May 2011 20:25:52 -0700 Subject: usrp1: correct TX codec rate, it should also read 64e6 when probed We were using clock_rate*2 to simulate a codec rate of 128MHz. This reflected the old gnuradio API, but the rate between FPGA and codec is really 64MHz for both rx and tx directions. --- host/lib/usrp/usrp1/dsp_impl.cpp | 24 +++++++++--------------- host/lib/usrp/usrp1/mboard_impl.cpp | 4 ++-- 2 files changed, 11 insertions(+), 17 deletions(-) (limited to 'host/lib/usrp/usrp1/mboard_impl.cpp') diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp index 1679c0470..66b11b989 100644 --- a/host/lib/usrp/usrp1/dsp_impl.cpp +++ b/host/lib/usrp/usrp1/dsp_impl.cpp @@ -103,11 +103,8 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t wh { size_t rate = size_t(_clock_ctrl->get_master_clock_freq() / val.as()); - if ((rate & 0x01) || (rate < 4) || (rate > 256)) { - UHD_MSG(error) << "Decimation must be even and between 4 and 256" - << std::endl; - return; - } + //clip the rate to something in range: + rate = std::min(std::max(rate, 4), 256); _rx_dsp_decim = rate; //TODO Poll every 100ms. Make it selectable? @@ -166,11 +163,11 @@ void usrp1_impl::tx_dsp_get(const wax::obj &key_, wax::obj &val, size_t which_ds return; case DSP_PROP_CODEC_RATE: - val = _clock_ctrl->get_master_clock_freq() * 2; + val = _clock_ctrl->get_master_clock_freq(); return; case DSP_PROP_HOST_RATE: - val = _clock_ctrl->get_master_clock_freq() * 2 / _tx_dsp_interp; + val = _clock_ctrl->get_master_clock_freq() / _tx_dsp_interp; return; default: UHD_THROW_PROP_GET_ERROR(); @@ -201,21 +198,18 @@ void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t wh case DSP_PROP_HOST_RATE: if (which_dsp != 0) return; //only for dsp[0] as this is vectorized { - size_t rate = size_t(_clock_ctrl->get_master_clock_freq() * 2 / val.as()); + size_t rate = size_t(_clock_ctrl->get_master_clock_freq() / val.as()); - if ((rate & 0x01) || (rate < 8) || (rate > 512)) { - UHD_MSG(error) << "Interpolation rate must be even and between 8 and 512" - << std::endl; - return; - } + //clip the rate to something in range: + rate = std::min(std::max(rate, 4), 256); _tx_dsp_interp = rate; //TODO Poll every 100ms. Make it selectable? - _tx_samps_per_poll_interval = size_t(0.1 * _clock_ctrl->get_master_clock_freq() * 2 / rate); + _tx_samps_per_poll_interval = size_t(0.1 * _clock_ctrl->get_master_clock_freq() / rate); bool s = this->disable_tx(); - _iface->poke32(FR_INTERP_RATE, _tx_dsp_interp / 4 - 1); + _iface->poke32(FR_INTERP_RATE, _tx_dsp_interp/2 - 1); this->restore_tx(s); return; } diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index d6f6832a4..e9108e4f1 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -214,8 +214,8 @@ void usrp1_impl::mboard_init(void) // Normal mode with no loopback or Rx counting _iface->poke32(FR_MODE, 0x00000000); _iface->poke32(FR_DEBUG_EN, 0x00000000); - _iface->poke32(FR_RX_SAMPLE_RATE_DIV, 0x00000001); - _iface->poke32(FR_TX_SAMPLE_RATE_DIV, 0x00000003); + _iface->poke32(FR_RX_SAMPLE_RATE_DIV, 0x00000001); //divide by 2 + _iface->poke32(FR_TX_SAMPLE_RATE_DIV, 0x00000001); //divide by 2 _iface->poke32(FR_DC_OFFSET_CL_EN, 0x0000000f); // Reset offset correction registers -- cgit v1.2.3