The crystal's error measured against an LTE cell and kept in flash (esp_sdr_cal.h; CONFIG_ESP_SDR_LTE_CAL measures, CONFIG_ESP_SDR_CALSTORE stores).
More...
The crystal's error measured against an LTE cell and kept in flash (esp_sdr_cal.h; CONFIG_ESP_SDR_LTE_CAL measures, CONFIG_ESP_SDR_CALSTORE stores).
Guide: Crystal calibration.
◆ ESP_SDR_CAL_EXTRAPOLATE_DC
| #define ESP_SDR_CAL_EXTRAPOLATE_DC 100 |
The model is not extrapolated further than this beyond its points, 0.1 degC.
◆ ESP_SDR_CAL_POINT_MERGE_DC
| #define ESP_SDR_CAL_POINT_MERGE_DC 20 |
A measurement replaces a point this close in temperature, 0.1 degC.
◆ ESP_SDR_CAL_POINTS
| #define ESP_SDR_CAL_POINTS 8 |
Calibration points (temperature, error) a record keeps for the temperature model.
◆ ESP_SDR_CAL_QUADRATIC_SPAN_DC
| #define ESP_SDR_CAL_QUADRATIC_SPAN_DC 100 |
The points must span this much for a quadratic fit (with 3 or more), 0.1 degC.
◆ ESP_SDR_CAL_TEMP_UNKNOWN
| #define ESP_SDR_CAL_TEMP_UNKNOWN INT16_MIN |
No temperature known for a record.
◆ ESP_SDR_LTE_SCAN_DEFAULT
| #define ESP_SDR_LTE_SCAN_DEFAULT |
Value: { \
.start_mhz = 2110, .stop_mhz = 2170, .candidates = 6, .tries = 12, .estimates = 5, \
.gain = -1, \
}
Scan defaults: LTE band 1 downlink (2110 to 2170 MHz).
◆ esp_sdr_cal_add_point()
| void esp_sdr_cal_add_point |
( |
struct esp_sdr_cal_record * | rec, |
|
|
int16_t | temp_dc, |
|
|
int32_t | ppb ) |
|
inlinestatic |
Add a measurement to a record's points.
A point within ESP_SDR_CAL_POINT_MERGE_DC of temp_dc is replaced; with all points in use the oldest goes. The new point is the newest.
- Parameters
-
| rec | Record. |
| temp_dc | Chip temperature in 0.1 degC. |
| ppb | The crystal's error measured there. |
◆ esp_sdr_cal_eval()
| int esp_sdr_cal_eval |
( |
const struct esp_sdr_cal_record * | rec, |
|
|
int16_t | temp_dc, |
|
|
int32_t * | ppb ) |
|
inlinestatic |
The crystal's error at a temperature, from a record's points.
One point gives a constant, two the line through them, three or more a least-squares quadratic when they span ESP_SDR_CAL_QUADRATIC_SPAN_DC (else a least-squares line). The temperature is clamped to ESP_SDR_CAL_EXTRAPOLATE_DC beyond the points.
- Parameters
-
| rec | Record. |
| temp_dc | Chip temperature in 0.1 degC. |
| ppb | Set to the error there. |
- Return values
-
| 0 | on success. |
| -ENOENT | if the record has no points. |
◆ esp_sdr_cal_update()
Take a measured crystal error into the correction in force, and store it.
With a temperature the measurement becomes a point of the model in force (esp_sdr_cal_add_point()), without one the constant correction (the points go). The result is applied (esp_sdr_set_freq_corr_model()) and, with CONFIG_ESP_SDR_CALSTORE, stored. esp_sdr_lte_calibrate() ends with it; a host that measures the error itself (the WHY2025 badge's P4 for its C6) hands its measurement over the same way.
- Parameters
-
| meas | The measurement: ppb, spread_ppb, carrier_khz, cell_id, estimates and temp_dc (ESP_SDR_CAL_TEMP_UNKNOWN for none); its points are not used. |
| out | Set to the record now in force, or NULL. |
- Return values
-
| 0 | if applied and stored. |
| -ENOTSUP | if applied, without CONFIG_ESP_SDR_CALSTORE. |
| -EINVAL | beyond ESP_SDR_FREQ_CORR_MAX_PPB: nothing changes. |
| other | negative errno if applied but not stored. |
◆ esp_sdr_get_freq_corr_model()
◆ esp_sdr_lte_calibrate()
Measure the crystal's error against an LTE cell and apply it.
Steps the LO across the scan range by 1 MHz (steps the LO does not reach are left out: the S3 reaches down to about 1865 MHz, the C6 to about 1775), ranks the steps by received power, then captures at the strongest ones until a cell decodes (esp_sdr_lte_detect()), and collects estimates from that cell, each against where the LO is (esp_sdr_get_lo_residual_hz()). Their median, added to the correction in force, goes to esp_sdr_cal_update(): a point of the temperature model, applied and, with CONFIG_ESP_SDR_CALSTORE, stored. Takes the radio for seconds to minutes and gives it back with the frequency and gain it had. The S3 and the C5 capture 1 to 2 ms at a time, the C6 0.2 ms (80 MS/s only), so the C6 needs many more captures to catch the synchronization signals (every 5 ms). Needs CONFIG_ESP_SDR_LTE_CAL, and about 9 KiB of stack in the calling thread (rfprobe's shell thread peaks at 11.6 KiB with it on the S3).
- Parameters
-
| scan | What to search; NULL for ESP_SDR_LTE_SCAN_DEFAULT. |
| res | Filled with the outcome. |
- Return values
-
| 0 | on success. |
| -ENOENT | if no cell decoded, -ERANGE if the estimates disagree. |
| -ENOMEM | without the heap for the work memory. |
| other | negative errno from the radio. |
◆ esp_sdr_set_freq_corr_model()
Correct tuning with a record's temperature model.
With points, the correction follows the chip's temperature: every retune evaluates the model at the die temperature (esp_sdr_get_temp_dc()). Without points, or without a temperature, the record's ppb is the correction. esp_sdr_set_freq_corr_ppb() drops the model again. Retunes now.
- Parameters
-
- Return values
-