srsLTE: fix TA calculation

This commit is contained in:
Xavier Arteaga 2020-06-22 12:23:40 +02:00 committed by Xavier Arteaga
parent 729986f259
commit 794f969e1a
1 changed files with 7 additions and 3 deletions

View File

@ -312,9 +312,13 @@ static void chest_ul_estimate(srslte_chest_ul_t* q,
}
}
// Average and store time aligment error
if (isnormal(ta_err)) {
res->ta_us = roundf(ta_err / 15e-2f) / (10.0f * (float)stride);
// Calculate actual time alignment error in micro-seconds
if (isnormal(ta_err) && stride > 0) {
ta_err /= (float)stride; // Divide by the pilot spacing
ta_err /= 15e3f; // Convert from normalized frequency to seconds
ta_err *= 1e6f; // Convert to micro-seconds
ta_err = roundf(ta_err * 10.0f) / 10.0f; // Round to one tenth of micro-second
res->ta_us = ta_err;
} else {
res->ta_us = 0.0f;
}