diff --git a/sa_cmd.c b/sa_cmd.c index 8c11736..6def7ca 100644 --- a/sa_cmd.c +++ b/sa_cmd.c @@ -1390,9 +1390,17 @@ VNA_SHELL_FUNCTION(cmd_scanraw) freq_t old_step = setting.frequency_step; float f_step = (stop-start)/ points; setting.frequency_step = (freq_t)f_step; + // perform() recalculates for a new frequency step itself. Zero span measures a series of RSSI + // samples at one frequency, which needs a full setup, also for the sweep after it. + bool zero_span = setting.frequency_step == 0; + if (zero_span && points == 1) { // one point as in a sweep: one measurement, auto RBW as in zero span + setting.frequency_step = setting.rbw_x10 ? setting.rbw_x10*50 : 300000; + zero_span = false; + } again: operation_requested = false; - dirty = true; + if (zero_span) + dirty = true; // adc_stop_analog_watchdog(); int oldpos = 0; if (!UI_OFF) { // ui off: no progress bar @@ -1431,7 +1439,8 @@ again: ili9341_fill(OFFSETX, CHART_BOTTOM+1, WIDTH, 1); } setting.frequency_step = old_step; - dirty = true; + if (zero_span) + dirty = true; redraw_request = 0; // disable screen update in this mode } diff --git a/sa_core.c b/sa_core.c index 4d3a8f6..f6b5827 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3715,6 +3715,7 @@ bool depth_error = false; #endif +static freq_t setup_frequency_step; // frequency step the first point of perform() was set up for pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) // Measure the RSSI for one frequency, used from sweep and other measurement routines. Must do all HW setup { @@ -3735,7 +3736,11 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / } #endif TRACE(10); - if (i == 0 && dirty ) { // if first point in scan and dirty + // First point after a change of settings (dirty) or of the frequency step (scanraw, the sweep + // after it): only dirty sets up the hardware, which takes about 80 ms on the tinySA basic + if (i == 0 && (dirty || setting.frequency_step != setup_frequency_step)) { + const bool hw = dirty; + if (hw) { #ifdef __ADF4351__ clear_frequency_cache(); #endif @@ -3749,15 +3754,17 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) / PE4302_Write_Byte((int)(setting.attenuate_x2)); #endif set_calibration_freq(setting.refer); - update_rbw(); - calculate_step_delay(); prev_output_level_dBm = MIN_RSSI_VALUE; // clear cached level setting - // Initialize HW - scandirty = true; // This is the first pass with new settings for (int t=0;t