From 434186fd9f1cd60d7b469c9be276fbf7465dce2d Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Wed, 11 Nov 2020 16:42:46 +0100
Subject: [PATCH] Correct TA timer condition

- wrap around 1024 (frame number is 0-1023)
- check for equality of frames with high numbers will trigger every 10ms
---
 openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
index a3c724e6f6..6a04e06073 100644
--- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c
@@ -641,7 +641,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
      * Possible improvement: take the periodicity from input file.
      * If such UE is not scheduled now, it will be by the preprocessor later.
      * If we add the CE, ta_apply will be reset */
-    if (frame >= (sched_ctrl->ta_frame + 10) % 1023)
+    if (frame == (sched_ctrl->ta_frame + 10) % 1024)
       sched_ctrl->ta_apply = true; /* the timer is reset once TA CE is scheduled */
 
     if (sched_ctrl->rbSize <= 0)
-- 
2.26.2