Commit a903ec64 authored by Marwan Hammouda's avatar Marwan Hammouda

[develop] Added: timing offset compensation at UE

     - post-compensation for DL and pre-compensation for UL
parent 8691824d
......@@ -762,6 +762,8 @@ void *UE_thread(void *arg)
int timing_advance = UE->timing_advance;
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
int rx_offset_slot = 0; //samples to be shifted for the current slot
int UL_TO_Tx_ofs = 0;
bool syncRunning=false;
const int nb_slot_frame = UE->frame_parms.slots_per_frame;
......@@ -869,14 +871,21 @@ void *UE_thread(void *arg)
int readBlockSize, writeBlockSize;
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);
if (UE->apply_timing_offset && (slot_nr == nb_slot_frame - 1)) {
rx_offset_slot = UE->rx_offset_TO * UE->rx_offset_slot / nb_slot_frame - UE->rx_offset_comp;
UE->rx_offset_comp += rx_offset_slot;
UE->rx_offset_slot++;
UL_TO_Tx_ofs += 2*rx_offset_slot; //to adapt the UE's transmission time in order to get aligned at gNB
readBlockSize=get_readBlockSize(slot_nr, &UE->frame_parms) + rx_offset_slot;
writeBlockSize=UE->frame_parms.get_samples_per_slot((slot_nr + DURATION_RX_TO_TX) % nb_slot_frame, &UE->frame_parms);
/*
if (UE->apply_timing_offset && (slot_nr == nb_slot_frame-1)) {
const int sampShift = -(UE->rx_offset>>1);
readBlockSize -= sampShift;
writeBlockSize -= sampShift;
UE->apply_timing_offset = false;
}
*/
AssertFatal(readBlockSize ==
UE->rfdevice.trx_read_func(&UE->rfdevice,
......@@ -885,9 +894,9 @@ void *UE_thread(void *arg)
readBlockSize,
UE->frame_parms.nb_antennas_rx),"");
if(slot_nr == (nb_slot_frame - 1)) {
// read in first symbol of next frame and adjust for timing drift
int first_symbols = UE->frame_parms.ofdm_symbol_size + UE->frame_parms.nb_prefix_samples0; // first symbol of every frames
if( slot_nr==(nb_slot_frame-1)) {
// read in first symbol of next frame
int first_symbols=UE->frame_parms.ofdm_symbol_size+UE->frame_parms.nb_prefix_samples0; // first symbol of every frames
if (first_symbols > 0) {
openair0_timestamp ignore_timestamp;
......
......@@ -114,11 +114,6 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
ue->rx_offset_comp = 0;
}
const int sample_shift = -(ue->rx_offset>>1);
// reset IIR filter for next offset calculation
ue->max_pos_fil += sample_shift * 32768;
if(abs(diff)<5)
count_max_pos_ok ++;
else
......
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