From 2c2ba26553c72e7d134e4e206e7e674a95424dcd Mon Sep 17 00:00:00 2001 From: Thomas Schlichter Date: Thu, 21 Oct 2021 20:50:04 +0200 Subject: [PATCH] NR_UE: fix bug in timing adjustment --- executables/nr-ue.c | 2 ++ openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 1d415e1230..76c4534384 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -464,12 +464,14 @@ int computeSamplesShift(PHY_VARS_NR_UE *UE) { if ( UE->rx_offset < UE->frame_parms.samples_per_frame/2 && UE->rx_offset > 0 ) { //LOG_I(PHY,"!!!adjusting -1 samples!!!\n"); + UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame return -1 ; } if ( UE->rx_offset > UE->frame_parms.samples_per_frame/2 && UE->rx_offset < UE->frame_parms.samples_per_frame ) { //LOG_I(PHY,"!!!adjusting +1 samples!!!\n"); + UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame return 1; } diff --git a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c index 3908febae9..e89280058a 100644 --- a/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c +++ b/openair1/PHY/NR_UE_ESTIMATION/nr_adjust_synch_ue.c @@ -55,13 +55,14 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, LOG_D(PHY,"AbsSubframe %d: rx_offset (before) = %d\n",subframe,ue->rx_offset); - // we only use channel estimates from tx antenna 0 here - for (int i = 0; i < frame_parms->nb_prefix_samples; i++) { + // search for maximum position within the cyclic prefix + for (int i = -frame_parms->nb_prefix_samples/2; i < frame_parms->nb_prefix_samples/2; i++) { int temp = 0; + int j = (i < 0) ? (i + frame_parms->ofdm_symbol_size) : i; for (int aa = 0; aa < frame_parms->nb_antennas_rx; aa++) { - int Re = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[(i<<1)]; - int Im = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[1+(i<<1)]; + int Re = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[(j<<1)]; + int Im = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[1+(j<<1)]; temp += (Re*Re/2) + (Im*Im/2); } @@ -71,9 +72,6 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, } } - if (max_pos > frame_parms->ofdm_symbol_size/2) - max_pos = max_pos - frame_parms->ofdm_symbol_size; - // filter position to reduce jitter if (clear == 1) max_pos_fil = max_pos;