From d0a7c0649b7e9e1782a80bcdde8ad06a41081ae1 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sun, 28 Jun 2020 19:53:00 +0200 Subject: [PATCH] Added measuring of minimum sweep times --- nanovna.h | 3 ++- sa_core.c | 20 ++++++++++++++++++++ si4432.c | 4 ++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/nanovna.h b/nanovna.h index efc8093..e49e55c 100644 --- a/nanovna.h +++ b/nanovna.h @@ -631,7 +631,7 @@ void reset_settings(int m); enum { S_OFF=0, S_ON=1, S_AUTO_OFF=2, S_AUTO_ON=3 }; #ifdef __FAST_SWEEP__ -#define MINIMUM_SWEEP_TIME 3000U // Minimum sweep time on zero span in uS +#define MINIMUM_SWEEP_TIME 2000U // Minimum sweep time on zero span in uS #else #define MINIMUM_SWEEP_TIME 15000U // Minimum sweep time on zero span in uS #endif @@ -859,6 +859,7 @@ void SI4432_SetReference(int freq); #define START_PROFILE systime_t time = chVTGetSystemTimeX(); #define RESTART_PROFILE time = chVTGetSystemTimeX(); #define STOP_PROFILE {char string_buf[12];plot_printf(string_buf, sizeof string_buf, "T:%06d", chVTGetSystemTimeX() - time);ili9341_drawstringV(string_buf, 1, 180);} +#define DELTA_TIME (time = chVTGetSystemTimeX() - time) // Macros for convert define value to string #define STR1(x) #x #define define_to_STR(x) STR1(x) diff --git a/sa_core.c b/sa_core.c index 5ccfc7f..55b09d9 100644 --- a/sa_core.c +++ b/sa_core.c @@ -156,6 +156,12 @@ void reset_settings(int m) dirty = true; } +static uint32_t extra_vbw_step_time = 0; +static uint32_t etra_repeat_time = 0; +static uint32_t minimum_zero_span_sweep_time = 0; +static uint32_t minimum_sweep_time = 0; + + uint32_t calc_min_sweep_time_us(void) // Calculate minimum sweep time in uS needed just because of the delays for the RSSI to become stable { float t; @@ -825,7 +831,12 @@ float temppeakLevel; int temppeakIndex; static unsigned long old_freq[4] = { 0, 0, 0, 0 }; static unsigned long real_old_freq[4] = { 0, 0, 0, 0 }; +volatile int t; +//static uint32_t extra_vbw_step_time = 0; +//static uint32_t etra_repeat_time = 0; +//static uint32_t minimum_zero_span_sweep_time = 0; +//static uint32_t minimum_sweep_time = 0; void setupSA(void) { @@ -841,6 +852,15 @@ void setupSA(void) SI4432_Transmit(0); PE4302_init(); PE4302_Write_Byte(0); + + setting.sweep_time_us = 0; + START_PROFILE + SI4432_Fill(0,200); + int t1 = DELTA_TIME; + RESTART_PROFILE + SI4432_Fill(0,0); + int t2 = DELTA_TIME; + t = (t2 - t1) * 100 * 290 / 200; } extern int SI4432_frequency_changed; extern int SI4432_offset_changed; diff --git a/si4432.c b/si4432.c index 2951315..899f5da 100644 --- a/si4432.c +++ b/si4432.c @@ -404,7 +404,7 @@ void SI4432_Fill(int s, int start) t = 0; SPI2_CLK_LOW; - int i = 0; + int i = start; do { palClearPad(GPIOC, sel); shiftOut( 0x26 ); @@ -414,7 +414,7 @@ void SI4432_Fill(int s, int start) if (t) my_microsecond_delay(t); } while(1); - buf_index = start; + buf_index = start; // Is used to skip 1st entry during level triggering buf_read = true; } #endif