Commit b4f46144 authored by Sakthivel Velumani's avatar Sakthivel Velumani

Fixed bugs in frame sync for UE

UE is a bit more stable now
parent 5c041cc1
...@@ -666,6 +666,8 @@ void *UE_thread(void *arg) { ...@@ -666,6 +666,8 @@ void *UE_thread(void *arg) {
int thread_idx=0; int thread_idx=0;
notifiedFIFO_t freeBlocks; notifiedFIFO_t freeBlocks;
initNotifiedFIFO_nothreadSafe(&freeBlocks); initNotifiedFIFO_nothreadSafe(&freeBlocks);
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
for (int i=0; i<RX_NB_TH+1; i++) // RX_NB_TH working + 1 we are making to be pushed for (int i=0; i<RX_NB_TH+1; i++) // RX_NB_TH working + 1 we are making to be pushed
pushNotifiedFIFO_nothreadSafe(&freeBlocks, pushNotifiedFIFO_nothreadSafe(&freeBlocks,
...@@ -683,11 +685,12 @@ void *UE_thread(void *arg) { ...@@ -683,11 +685,12 @@ void *UE_thread(void *arg) {
syncRunning=false; syncRunning=false;
syncData_t *tmp=(syncData_t *)NotifiedFifoData(res); syncData_t *tmp=(syncData_t *)NotifiedFifoData(res);
// shift the frame index with all the frames we trashed meanwhile we perform the synch search // shift the frame index with all the frames we trashed meanwhile we perform the synch search
decoded_frame_rx=(tmp->proc.decoded_frame_rx+trashed_frames) % MAX_FRAME_NUMBER; decoded_frame_rx=((((mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused)<<4) | tmp->proc.decoded_frame_rx) +
(!UE->init_sync_frame) + trashed_frames) % MAX_FRAME_NUMBER;
delNotifiedFIFO_elt(res); delNotifiedFIFO_elt(res);
} else { } else {
readFrame(UE, &timestamp, true); readFrame(UE, &timestamp, true);
trashed_frames++; trashed_frames+=2;
continue; continue;
} }
} }
...@@ -722,7 +725,7 @@ void *UE_thread(void *arg) { ...@@ -722,7 +725,7 @@ void *UE_thread(void *arg) {
// and we shifted above to the first slot of next frame // and we shifted above to the first slot of next frame
decoded_frame_rx++; decoded_frame_rx++;
// we do ++ first in the regular processing, so it will be begin of frame; // we do ++ first in the regular processing, so it will be begin of frame;
absolute_slot=decoded_frame_rx*nb_slot_frame + nb_slot_frame -1; absolute_slot=decoded_frame_rx*nb_slot_frame -1;
continue; continue;
} }
......
...@@ -303,7 +303,13 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode, ...@@ -303,7 +303,13 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc, PHY_VARS_NR_UE *ue, runmode_t mode,
// sync at symbol ue->symbol_offset // sync at symbol ue->symbol_offset
// computing the offset wrt the beginning of the frame // computing the offset wrt the beginning of the frame
sync_pos_frame = (fp->ofdm_symbol_size + fp->nb_prefix_samples0)+((ue->symbol_offset)-1)*(fp->ofdm_symbol_size + fp->nb_prefix_samples); sync_pos_frame = (fp->ofdm_symbol_size + fp->nb_prefix_samples0)+((ue->symbol_offset)-1)*(fp->ofdm_symbol_size + fp->nb_prefix_samples);
ue->rx_offset = ue->ssb_offset - sync_pos_frame;
if (ue->ssb_offset < sync_pos_frame)
ue->rx_offset = fp->samples_per_frame - sync_pos_frame + ue->ssb_offset;
else
ue->rx_offset = ue->ssb_offset - sync_pos_frame;
ue->init_sync_frame = is;
} }
nr_gold_pdcch(ue,0, 2); nr_gold_pdcch(ue,0, 2);
......
...@@ -1012,6 +1012,7 @@ typedef struct { ...@@ -1012,6 +1012,7 @@ typedef struct {
// uint8_t prach_timer; // uint8_t prach_timer;
uint8_t decode_SIB; uint8_t decode_SIB;
uint8_t decode_MIB; uint8_t decode_MIB;
uint8_t init_sync_frame;
/// temporary offset during cell search prior to MIB decoding /// temporary offset during cell search prior to MIB decoding
int ssb_offset; int ssb_offset;
uint16_t symbol_offset; // offset in terms of symbols for detected ssb in sync uint16_t symbol_offset; // offset in terms of symbols for detected ssb in sync
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment