From 39fe985681bcc63b0c23fc214549984b8b051785 Mon Sep 17 00:00:00 2001
From: Thomas Schlichter <thomas.schlichter@iis.fraunhofer.de>
Date: Tue, 11 Oct 2022 11:31:34 +0200
Subject: [PATCH] NR_UE: slightly improve timing synchronization by minimizing
 the adjustment of the filtered peak position value

---
 executables/nr-ue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/executables/nr-ue.c b/executables/nr-ue.c
index 8b022adc62e..c2747738804 100644
--- a/executables/nr-ue.c
+++ b/executables/nr-ue.c
@@ -798,10 +798,10 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
 
 int computeSamplesShift(PHY_VARS_NR_UE *UE) {
   int samples_shift = -(UE->rx_offset>>1);
-  UE->rx_offset   = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame
-  UE->max_pos_fil = 0; // reset IIR filter when sample shift is applied
   if (samples_shift != 0) {
     LOG_I(NR_PHY,"Adjusting frame in time by %i samples\n", samples_shift);
+    UE->rx_offset = 0; // reset so that it is not applied falsely in case of SSB being only in every second frame
+    UE->max_pos_fil += samples_shift; // reset IIR filter when sample shift is applied
   }
   return samples_shift;
 }
-- 
GitLab