From e8f9bfc6ba8b1517a1db8d61fae9f1e6f0e5733b Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 11 Mar 2020 10:27:53 +0100 Subject: [PATCH] Addition of PRACH TA correction --- lib/include/srslte/interfaces/ue_interfaces.h | 4 ++-- srsue/hdr/phy/phy.h | 3 ++- srsue/src/phy/phy.cc | 9 ++++++--- srsue/src/stack/mac/proc_ra.cc | 2 +- srsue/test/mac_test.cc | 2 +- srsue/test/phy/ue_phy_test.cc | 2 +- srsue/test/ttcn3/hdr/lte_ttcn3_phy.h | 2 +- srsue/test/ttcn3/src/lte_ttcn3_phy.cc | 2 +- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/include/srslte/interfaces/ue_interfaces.h b/lib/include/srslte/interfaces/ue_interfaces.h index 9997e7802..8ff56d829 100644 --- a/lib/include/srslte/interfaces/ue_interfaces.h +++ b/lib/include/srslte/interfaces/ue_interfaces.h @@ -544,8 +544,8 @@ public: /* Configure PRACH using parameters written by RRC */ virtual void configure_prach_params() = 0; - virtual void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm) = 0; - virtual prach_info_t prach_get_info() = 0; + virtual void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec) = 0; + virtual prach_info_t prach_get_info() = 0; /* Indicates the transmission of a SR signal in the next opportunity */ virtual void sr_send() = 0; diff --git a/srsue/hdr/phy/phy.h b/srsue/hdr/phy/phy.h index b33d63be2..ffb2405b7 100644 --- a/srsue/hdr/phy/phy.h +++ b/srsue/hdr/phy/phy.h @@ -85,7 +85,7 @@ public: void configure_prach_params() final; /* Transmits PRACH in the next opportunity */ - void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm) final; + void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec) final; prach_info_t prach_get_info() final; /* Indicates the transmission of a SR signal in the next opportunity */ @@ -158,6 +158,7 @@ private: /* Current time advance */ uint32_t n_ta = 0; + uint32_t n_ta_base = 0; static void set_default_args(phy_args_t& args); bool check_args(const phy_args_t& args); diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 5e4d57f20..aec6ba1f6 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -259,6 +259,7 @@ void phy::get_metrics(phy_metrics_t* m) void phy::set_timeadv_rar(uint32_t ta_cmd) { n_ta = srslte_N_ta_new_rar(ta_cmd); + n_ta += n_ta_base; sfsync.set_time_adv_sec(((float)n_ta) * SRSLTE_LTE_TS); Info("PHY: Set TA RAR: ta_cmd: %d, n_ta: %d, ta_usec: %.1f\n", ta_cmd, n_ta, ((float)n_ta) * SRSLTE_LTE_TS * 1e6); } @@ -339,10 +340,11 @@ float phy::get_pathloss_db() return common.cur_pathloss; } -void phy::prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm) +void phy::prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec) { - n_ta = 0; - sfsync.set_time_adv_sec(0.0f); + n_ta = 0; /* Reset Time aligment */ + n_ta_base = (uint32_t)roundf(ta_base_sec / SRSLTE_LTE_TS); + sfsync.set_time_adv_sec(ta_base_sec); common.reset_radio(); if (!prach_buffer.prepare_to_send(preamble_idx, allowed_subframe, target_power_dbm)) { Error("Preparing PRACH to send\n"); @@ -370,6 +372,7 @@ void phy::reset() { Info("Resetting PHY\n"); n_ta = 0; + n_ta_base = 0; sfsync.set_time_adv_sec(0); for (uint32_t i = 0; i < nof_workers; i++) { workers[i]->reset(); diff --git a/srsue/src/stack/mac/proc_ra.cc b/srsue/src/stack/mac/proc_ra.cc index fd04e79b2..3facd0b8c 100644 --- a/srsue/src/stack/mac/proc_ra.cc +++ b/srsue/src/stack/mac/proc_ra.cc @@ -343,7 +343,7 @@ void ra_proc::preamble_transmission() received_target_power_dbm = rach_cfg.iniReceivedTargetPower + delta_preamble_db + (preambleTransmissionCounter - 1) * rach_cfg.powerRampingStep; - phy_h->prach_send(sel_preamble, sel_maskIndex - 1, received_target_power_dbm); + phy_h->prach_send(sel_preamble, sel_maskIndex - 1, received_target_power_dbm, 0.0f); rntis->rar_rnti = 0; ra_tti = 0; rar_received = false; diff --git a/srsue/test/mac_test.cc b/srsue/test/mac_test.cc index 9aafbe425..25354376e 100644 --- a/srsue/test/mac_test.cc +++ b/srsue/test/mac_test.cc @@ -123,7 +123,7 @@ public: // phy_interface_mac_lte void configure_prach_params(){}; - void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm) + void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec) { prach_delay_cnt = 0; last_preamble_idx = preamble_idx; diff --git a/srsue/test/phy/ue_phy_test.cc b/srsue/test/phy/ue_phy_test.cc index 6b89bdba3..d4eacfb40 100644 --- a/srsue/test/phy/ue_phy_test.cc +++ b/srsue/test/phy/ue_phy_test.cc @@ -501,7 +501,7 @@ int main(int argc, char** argv) // 3. Transmit PRACH phy_test->get_phy_interface_mac()->configure_prach_params(); - phy_test->get_phy_interface_mac()->prach_send(0, -1, 0.0f); + phy_test->get_phy_interface_mac()->prach_send(0, -1, 0.0f, 0.0f); TESTASSERT(phy_test->get_radio()->wait_tx(default_timeout, false)); // 4. Configure RNTI with PUCCH and check transmission diff --git a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h index d222dbdc5..517685efb 100644 --- a/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h +++ b/srsue/test/ttcn3/hdr/lte_ttcn3_phy.h @@ -93,7 +93,7 @@ public: // phy_interface_mac_lte void configure_prach_params(); - void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm); + void prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec); prach_info_t prach_get_info(); void sr_send(); int sr_last_tx_tti(); diff --git a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc index 5f2a4795c..6708ba8af 100644 --- a/srsue/test/ttcn3/src/lte_ttcn3_phy.cc +++ b/srsue/test/ttcn3/src/lte_ttcn3_phy.cc @@ -194,7 +194,7 @@ void lte_ttcn3_phy::configure_prach_params() log.debug("%s not implemented.\n", __FUNCTION__); }; -void lte_ttcn3_phy::prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm) +void lte_ttcn3_phy::prach_send(uint32_t preamble_idx, int allowed_subframe, float target_power_dbm, float ta_base_sec) { log.info("Sending PRACH with preamble %d on PCID=%d\n", preamble_idx, pcell.info.id); prach_tti_tx = current_tti;