NR_UE: fix frequency offset estimation/compensation if SSB is in the second captured frame
This commit is contained in:
@@ -251,52 +251,51 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
|
|
||||||
/* process pss search on received buffer */
|
/* process pss search on received buffer */
|
||||||
sync_pos = pss_synchro_nr(ue, is, NO_RATE_CHANGE);
|
sync_pos = pss_synchro_nr(ue, is, NO_RATE_CHANGE);
|
||||||
|
if (sync_pos < fp->nb_prefix_samples)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (sync_pos >= fp->nb_prefix_samples)
|
ue->ssb_offset = sync_pos - fp->nb_prefix_samples;
|
||||||
ue->ssb_offset = sync_pos - fp->nb_prefix_samples;
|
|
||||||
else
|
|
||||||
ue->ssb_offset = sync_pos + fp->samples_per_frame - fp->nb_prefix_samples;
|
|
||||||
|
|
||||||
#ifdef DEBUG_INITIAL_SYNCH
|
#ifdef DEBUG_INITIAL_SYNCH
|
||||||
LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id);
|
LOG_I(PHY,"[UE%d] Initial sync : Estimated PSS position %d, Nid2 %d\n", ue->Mod_id, sync_pos,ue->common_vars.eNb_id);
|
||||||
LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset);
|
LOG_I(PHY,"sync_pos %d ssb_offset %d \n",sync_pos,ue->ssb_offset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// digital compensation of FFO for SSB symbols
|
/* check that SSS/PBCH block is continuous inside the received buffer */
|
||||||
if (ue->UE_fo_compensation){
|
if (ue->ssb_offset + NR_N_SYMBOLS_SSB * (fp->ofdm_symbol_size + fp->nb_prefix_samples) < fp->samples_per_frame) {
|
||||||
double s_time = 1/(1.0e3*fp->samples_per_subframe); // sampling time
|
|
||||||
double off_angle = -2*M_PI*s_time*(ue->common_vars.freq_offset); // offset rotation angle compensation per sample
|
|
||||||
|
|
||||||
// In SA we need to perform frequency offset correction until the end of buffer because we need to decode SIB1
|
// digital compensation of FFO for SSB symbols
|
||||||
// and we do not know yet in which slot it goes.
|
if (ue->UE_fo_compensation){
|
||||||
|
double s_time = 1/(1.0e3*fp->samples_per_subframe); // sampling time
|
||||||
|
double off_angle = -2*M_PI*s_time*(ue->common_vars.freq_offset); // offset rotation angle compensation per sample
|
||||||
|
|
||||||
// start for offset correction
|
// In SA we need to perform frequency offset correction until the end of buffer because we need to decode SIB1
|
||||||
int start = sa ? is*fp->samples_per_frame : is*fp->samples_per_frame + ue->ssb_offset;
|
// and we do not know yet in which slot it goes.
|
||||||
|
|
||||||
// loop over samples
|
// start for offset correction
|
||||||
int end = sa ? n_frames*fp->samples_per_frame : start + NR_N_SYMBOLS_SSB*(fp->ofdm_symbol_size + fp->nb_prefix_samples);
|
int start = is*fp->samples_per_frame;
|
||||||
|
|
||||||
for(int n=start; n<end; n++){
|
// loop over samples
|
||||||
for (int ar=0; ar<fp->nb_antennas_rx; ar++) {
|
int end = start + fp->samples_per_frame;
|
||||||
re = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n]);
|
|
||||||
im = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n+1]);
|
for(int n=start; n<end; n++){
|
||||||
((short *)ue->common_vars.rxdata[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle)));
|
for (int ar=0; ar<fp->nb_antennas_rx; ar++) {
|
||||||
((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle)));
|
re = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n]);
|
||||||
|
im = ((double)(((short *)ue->common_vars.rxdata[ar]))[2*n+1]);
|
||||||
|
((short *)ue->common_vars.rxdata[ar])[2*n] = (short)(round(re*cos(n*off_angle) - im*sin(n*off_angle)));
|
||||||
|
((short *)ue->common_vars.rxdata[ar])[2*n+1] = (short)(round(re*sin(n*off_angle) + im*cos(n*off_angle)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* check that SSS/PBCH block is continuous inside the received buffer */
|
/* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */
|
||||||
if (is*fp->samples_per_frame + ue->ssb_offset + NR_N_SYMBOLS_SSB * (fp->ofdm_symbol_size + fp->nb_prefix_samples) < n_frames*fp->samples_per_frame) {
|
/* for NR this is not the case but slot_fep is still used for computing FFT of samples */
|
||||||
|
/* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */
|
||||||
/* slop_fep function works for lte and takes into account begining of frame with prefix for subframe 0 */
|
/* symbol number are from beginning of SS/PBCH blocks as below: */
|
||||||
/* for NR this is not the case but slot_fep is still used for computing FFT of samples */
|
/* Signal PSS PBCH SSS PBCH */
|
||||||
/* in order to achieve correct processing for NR prefix samples is forced to 0 and then restored after function call */
|
/* symbol number 0 1 2 3 */
|
||||||
/* symbol number are from beginning of SS/PBCH blocks as below: */
|
/* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */
|
||||||
/* Signal PSS PBCH SSS PBCH */
|
/* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */
|
||||||
/* symbol number 0 1 2 3 */
|
|
||||||
/* time samples in buffer rxdata are used as input of FFT -> FFT results are stored in the frequency buffer rxdataF */
|
|
||||||
/* rxdataF stores SS/PBCH from beginning of buffers in the same symbol order as in time domain */
|
|
||||||
|
|
||||||
for(int i=0; i<4;i++)
|
for(int i=0; i<4;i++)
|
||||||
nr_slot_fep_init_sync(ue,
|
nr_slot_fep_init_sync(ue,
|
||||||
@@ -322,10 +321,10 @@ int nr_initial_sync(UE_nr_rxtx_proc_t *proc,
|
|||||||
// and we do not know yet in which slot it goes.
|
// and we do not know yet in which slot it goes.
|
||||||
|
|
||||||
// start for offset correction
|
// start for offset correction
|
||||||
int start = sa ? is*fp->samples_per_frame : is*fp->samples_per_frame + ue->ssb_offset;
|
int start = is*fp->samples_per_frame;
|
||||||
|
|
||||||
// loop over samples
|
// loop over samples
|
||||||
int end = sa ? n_frames*fp->samples_per_frame-1 : start + NR_N_SYMBOLS_SSB*(fp->ofdm_symbol_size + fp->nb_prefix_samples);
|
int end = start + fp->samples_per_frame;
|
||||||
|
|
||||||
for(int n=start; n<end; n++){
|
for(int n=start; n<end; n++){
|
||||||
for (int ar=0; ar<fp->nb_antennas_rx; ar++) {
|
for (int ar=0; ar<fp->nb_antennas_rx; ar++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user