Commit 9825842e authored by Sakthivel Velumani's avatar Sakthivel Velumani

Adjust samples in time only when valid PBCH is present

parent 6cc01f7c
...@@ -734,16 +734,6 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) { ...@@ -734,16 +734,6 @@ void syncInFrame(PHY_VARS_NR_UE *UE, openair0_timestamp *timestamp) {
} }
} }
int computeSamplesShift(PHY_VARS_NR_UE *UE) {
int samples_shift = -(UE->rx_offset>>1);
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 << 15; // reset IIR filter when sample shift is applied
}
return samples_shift;
}
static inline int get_firstSymSamp(uint16_t slot, NR_DL_FRAME_PARMS *fp) { static inline int get_firstSymSamp(uint16_t slot, NR_DL_FRAME_PARMS *fp) {
if (fp->numerology_index == 0) if (fp->numerology_index == 0)
return fp->nb_prefix_samples0 + fp->ofdm_symbol_size; return fp->nb_prefix_samples0 + fp->ofdm_symbol_size;
...@@ -904,14 +894,13 @@ void *UE_thread(void *arg) { ...@@ -904,14 +894,13 @@ void *UE_thread(void *arg) {
int readBlockSize, writeBlockSize; int readBlockSize, writeBlockSize;
if (slot_nr<(nb_slot_frame - 1)) {
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms); readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms);
writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX) % nb_slot_frame, &UE->frame_parms); writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX) % nb_slot_frame, &UE->frame_parms);
} else { if (UE->apply_timing_offset && (slot_nr == nb_slot_frame-1)) {
UE->rx_offset_diff = computeSamplesShift(UE); const int sampShift = -(UE->rx_offset>>1);
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) - readBlockSize -= sampShift;
UE->rx_offset_diff; writeBlockSize -= sampShift;
writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX) % nb_slot_frame, &UE->frame_parms)- UE->rx_offset_diff; UE->apply_timing_offset = false;
} }
AssertFatal(readBlockSize == AssertFatal(readBlockSize ==
......
...@@ -94,6 +94,10 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, ...@@ -94,6 +94,10 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
else else
ue->rx_offset = diff; ue->rx_offset = diff;
const int sample_shift = -(ue->rx_offset>>1);
// reset IIR filter for next offset calculation
ue->max_pos_fil += sample_shift << 15;
if(abs(diff)<5) if(abs(diff)<5)
count_max_pos_ok ++; count_max_pos_ok ++;
else else
......
...@@ -284,7 +284,7 @@ void nr_processDLSegment(void* arg) { ...@@ -284,7 +284,7 @@ void nr_processDLSegment(void* arg) {
if (no_iteration_ldpc > dlsch->max_ldpc_iterations) if (no_iteration_ldpc > dlsch->max_ldpc_iterations)
no_iteration_ldpc = dlsch->max_ldpc_iterations; no_iteration_ldpc = dlsch->max_ldpc_iterations;
} else { } else {
LOG_I(PHY,"%d.%d CRC NOT OK\n",rdata->proc->frame_rx,rdata->proc->nr_slot_rx); LOG_D(PHY,"%d.%d CRC NOT OK\n",rdata->proc->frame_rx,rdata->proc->nr_slot_rx);
no_iteration_ldpc = dlsch->max_ldpc_iterations + 1; no_iteration_ldpc = dlsch->max_ldpc_iterations + 1;
} }
......
...@@ -516,6 +516,7 @@ typedef struct { ...@@ -516,6 +516,7 @@ typedef struct {
int rx_offset; /// Timing offset int rx_offset; /// Timing offset
int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP int rx_offset_diff; /// Timing adjustment for ofdm symbol0 on HW USRP
int max_pos_fil; /// Timing offset IIR filter int max_pos_fil; /// Timing offset IIR filter
bool apply_timing_offset; /// Do time sync for current frame
int time_sync_cell; int time_sync_cell;
/// Timing Advance updates variables /// Timing Advance updates variables
......
...@@ -352,7 +352,7 @@ void nr_ue_measurement_procedures(uint16_t l, ...@@ -352,7 +352,7 @@ void nr_ue_measurement_procedures(uint16_t l,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT);
} }
static void nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue, static int nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,
int estimateSz, int estimateSz,
struct complex16 dl_ch_estimates[][estimateSz], struct complex16 dl_ch_estimates[][estimateSz],
...@@ -420,6 +420,7 @@ static void nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue, ...@@ -420,6 +420,7 @@ static void nr_ue_pbch_procedures(PHY_VARS_NR_UE *ue,
} }
return ret;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_OUT);
} }
...@@ -929,9 +930,9 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, ...@@ -929,9 +930,9 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
if(ssb_index == fp->ssb_index) { if(ssb_index == fp->ssb_index) {
LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
nr_ue_pbch_procedures(ue, proc, estimateSz, dl_ch_estimates, phy_data, rxdataF); const int pbchSuccess = nr_ue_pbch_procedures(ue, proc, estimateSz, dl_ch_estimates, phy_data, rxdataF);
if (ue->no_timing_correction==0) { if (ue->no_timing_correction==0 && pbchSuccess == 0) {
LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction);
nr_adjust_synch_ue(fp, nr_adjust_synch_ue(fp,
ue, ue,
...@@ -943,6 +944,7 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue, ...@@ -943,6 +944,7 @@ void pbch_pdcch_processing(PHY_VARS_NR_UE *ue,
0, 0,
16384); 16384);
} }
ue->apply_timing_offset = true;
} }
LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__); LOG_D(PHY, "Doing N0 measurements in %s\n", __FUNCTION__);
nr_ue_rrc_measurements(ue, proc, rxdataF); nr_ue_rrc_measurements(ue, proc, rxdataF);
......
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