Add '+' when output above 0dBm

Speed-test
erikkaashoek 4 years ago
parent 3b6d29f33a
commit 5fea965bad

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-914012201054471" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1591214633354629" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -17,7 +17,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-914012201054471" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1591214633354629" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

@ -28,6 +28,7 @@
#define BOARD_NAME "tinySA4"
#include <stm32f303xc.h>
//#include "..\nanovna.h"
/*
* Board frequencies.
*/
@ -89,6 +90,7 @@
#define GPIOB_SPI_MOSI 5
#define GPIO_LO_SEL 6
#define LINE_LO_SEL PAL_LINE(GPIOB, GPIO_LO_SEL)
//#define __NEW_SWITCHES__
#ifdef __NEW_SWITCHES__
#define GPIO_SD_CD 12
#define LINE_SD_CD PAL_LINE(GPIOB, GPIO_SD_CD)

@ -49,7 +49,7 @@
#define __SI4463__
#define __SI4468__
#define __ADF4351__
#define __NEW_SWITCHES__
//#define __NEW_SWITCHES__
#endif
#define __PE4302__
//#define __SIMULATION__
@ -128,6 +128,10 @@
#define MAX_LO_FREQ 4350000000ULL
//#define LOW_MAX_FREQ 800000000ULL
#define MIN_BELOW_LO 550000000ULL
#ifdef __NEW_SWITCHES__
#define DIRECT_START 822000000ULL
#define DIRECT_STOP 1130000000ULL
#endif
#endif
/*
* main.c
@ -692,6 +696,9 @@ typedef struct config {
int8_t cor_nfm;
uint8_t _brightness;
uint8_t high_out_adf4350;
#ifdef __ULTRA__
uint8_t direct;
#endif
float sweep_voltage;
float switch_offset;
int16_t ext_zero_level;

@ -72,8 +72,8 @@ bool ultra;
#ifdef TINYSA4
int noise_level;
float log_averaging_correction;
uint32_t old_CFGR;
uint32_t orig_CFGR;
//uint32_t old_CFGR; // Not used??
//uint32_t orig_CFGR; // Not used??
int debug_frequencies = false;
int linear_averaging = true;
@ -2021,10 +2021,7 @@ case M_LOW: // Mixed into 0
#ifdef TINYSA4
ADF4351_enable(true);
// ADF4351_drive(setting.lo_drive);
if (setting.tracking_output)
ADF4351_enable_aux_out(true);
else
ADF4351_enable_aux_out(false);
ADF4351_enable_aux_out(setting.tracking_output);
ADF4351_enable_out(true);
#endif
@ -2110,7 +2107,7 @@ case M_GENLOW: // Mixed output from 0
ADF4351_enable_out(true);
// ADF4351_drive(setting.lo_drive);
ADF4351_enable(true);
ADF4351_enable_aux_out(false);
ADF4351_enable_aux_out(setting.tracking_output);
if (setting.atten_step) { // use switch as attenuator
enable_rx_output(false);
@ -2777,6 +2774,11 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
int modulation_index = 0;
int modulation_count_iter = 0;
int spur_second_pass = false;
#ifdef __NEW_SWITCHES__
int direct = (setting.mode == M_LOW && config.direct && f > DIRECT_START && f<DIRECT_STOP );
#else
const int direct = false;
#endif
#ifdef TINYSA4
if (i == 0 && old_temp != Si446x_get_temp()) {
old_temp = Si446x_get_temp();
@ -2901,7 +2903,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
#endif
#endif
// ------------------------------------- Set the output level ----------------------------------
// ------------------------------------- START Set the output level ----------------------------------
if (( setting.frequency_step != 0 || setting.level_sweep != 0.0 || i == 0)) { // Initialize or adapt output levels
if (setting.mode == M_GENLOW) {// if in low output mode and level sweep or frequency weep is active or at start of sweep
@ -3069,6 +3071,9 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
}
}
}
// ------------------------------------- END Set the output level ----------------------------------
#ifdef __SI4432__
if (setting.mode == M_LOW && S_IS_AUTO(setting.agc) && !check_for_AM && UNIT_IS_LOG(setting.unit)) { // If in low input mode with auto AGC and log unit
if (f < 1500000)
@ -3156,14 +3161,29 @@ modulation_again:
}
}
#ifdef __ULTRA__
// -------------- set ultra ---------------------------------
if (setting.mode == M_LOW && ultra && f > ultra_threshold) {
enable_ultra(true);
}
else
enable_ultra(false);
// -------------- set ultra or direct ---------------------------------
if (setting.mode == M_LOW) {
if (ultra && f > ultra_threshold) {
enable_ultra(true);
}
else {
#ifdef __NEW_SWITCHES__
if (direct) {
enable_ultra(true);
enable_direct(true);
enable_high(true);
}
else {
enable_ultra(false);
enable_direct(false);
enable_high(false);
#else
enable_ultra(false);
#endif
// -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------
}
}
#endif
// -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------
pureRSSI_t RSSI = float_TO_PURE_RSSI(-150);
if (debug_avoid){ // For debugging the spur avoidance control
stored_t[i] = -90.0; // Display when to do spur shift in the stored trace
@ -3179,6 +3199,9 @@ modulation_again:
local_vbw_steps *= 2;
}
#endif
// -----------------------------------START vbwsteps loop ------------------------------------
int t = 0;
do {
freq_t lf = f;
@ -3208,7 +3231,7 @@ modulation_again:
lf += offs;
#endif
}
// -------------- Calculate the IF -----------------------------
// -------------- START Calculate the IF -----------------------------
if (/* MODE_INPUT(setting.mode) && */ i > 0 && FREQ_IS_CW()) // In input mode in zero span mode after first setting of the LO's
goto skip_LO_setting; // No more LO changes required, save some time and jump over the code
@ -3246,7 +3269,7 @@ again: // Spur redu
local_IF = DEFAULT_IF;
#endif
}
if (setting.mode == M_LOW) {
if (setting.mode == M_LOW && !direct) {
if (tracking) { // VERY SPECIAL CASE!!!!! Measure BPF
#if 0 // Isolation test
local_IF = lf;
@ -3387,7 +3410,7 @@ again: // Spur redu
if (setting.modulation == MO_EXTERNAL) // VERY SPECIAL CASE !!!!!! LO input via high port
local_IF += lf;
}
}
} // --------------- END IF calculation ------------------------
// ------------- Set LO ---------------------------
@ -3396,7 +3419,7 @@ again: // Spur redu
#ifdef TINYSA4
int inverted_f = false;
#endif
if (setting.mode == M_LOW && !setting.tracking && S_STATE(setting.below_IF)) { // if in low input mode and below IF
if (setting.mode == M_LOW && !direct && !setting.tracking && S_STATE(setting.below_IF)) { // if in low input mode and below IF
#ifdef __ULTRA__
if (lf < local_IF)
#endif
@ -3441,9 +3464,12 @@ again: // Spur redu
#endif
set_freq (SI4432_LO, target_f); // otherwise to above IF
#endif
// ----------------------------- START Calculate and set the AD4351 frequency and set the RX frequency --------------------------------
#ifdef __ADF4351__
// START_PROFILE;
if (MODE_LOW(setting.mode)) {
if (MODE_LOW(setting.mode) &&!direct) {
if (config.frequency_IF2 != 0) {
set_freq (ADF4351_LO2, config.frequency_IF2 - local_IF); // Down from IF2 to fixed second IF in Ultra SA mode
local_IF = config.frequency_IF2;
@ -3456,9 +3482,9 @@ again: // Spur redu
if (setting.R == 0) {
if (setting.mode == M_GENLOW) {
if (local_modulo == 0) ADF4351_modulo(1000);
ADF4351_R_counter(1);
ADF4351_R_counter(3);
} else
if (lf < 1000000000 /* && lf >= TXCO_DIV3 */ && MODE_INPUT(setting.mode)) {
if (lf > 8000000 && lf < 1000000000 /* && lf >= TXCO_DIV3 */ && MODE_INPUT(setting.mode)) {
if (local_modulo == 0) {
if (actual_rbw_x10 >= 3000)
ADF4351_modulo(1000);
@ -3488,7 +3514,7 @@ again: // Spur redu
if (setting.frequency_step < 100000)
ADF4351_R_counter(3);
else
ADF4351_R_counter(1);
ADF4351_R_counter(1); // Used to be 1
}
}
else {
@ -3541,7 +3567,7 @@ again: // Spur redu
}
}
#endif
} else if (setting.mode == M_HIGH) {
} else if (setting.mode == M_HIGH || direct) {
set_freq (SI4463_RX, lf); // sweep RX, local_IF = 0 in high mode
} else if (setting.mode == M_GENHIGH) {
if (config.high_out_adf4350) {
@ -3552,9 +3578,11 @@ again: // Spur redu
local_IF = 0;
}
}
// ----------------------------- END Calculate and set the AD4351 frequency and set the RX frequency --------------------------------
// STOP_PROFILE;
#endif
}
} // ----------------- LO's set --------------------------
#ifdef __MCU_CLOCK_SHIFT__
if (setting.mode == M_LOW && !in_selftest) { // Avoid 48MHz spur
@ -3590,7 +3618,7 @@ again: // Spur redu
// ----------- Set IF ------------------
if (local_IF != 0) // When not in one of the high modes
if (local_IF != 0) // When not in one of the high modes and not in direct mode
{
#ifdef __SI4432__
set_freq (SI4432_RX , local_IF);
@ -3865,10 +3893,10 @@ again: // Spur redu
break; // abort
} while (t < local_vbw_steps); // till all sub steps done
#ifdef TINYSA4
if (old_CFGR != orig_CFGR) {
old_CFGR = orig_CFGR;
RCC->CFGR = orig_CFGR;
}
// if (old_CFGR != orig_CFGR) { // Never happens ???
// old_CFGR = orig_CFGR;
// RCC->CFGR = orig_CFGR;
// }
#define IGNORE_RSSI 30000
// pureRSSI_t rssi = (RSSI>0 ? RSSI + correct_RSSI + correct_RSSI_freq : IGNORE_RSSI); // add correction
pureRSSI_t rssi = RSSI + correct_RSSI + correct_RSSI_freq; // add correction
@ -5060,14 +5088,14 @@ typedef struct test_case {
const test_case_t test_case [] =
#ifdef TINYSA4
{// Condition Preparation Center Span Pass Width(%)Stop
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.05, 0.1, 0, 0, 0), // 1 Zero Hz leakage
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.06, 0.11, -30, 0, -30), // 1 Zero Hz leakage
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.1, 0.1, -70, 0, 0), // 2 Phase noise of zero Hz
TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ, 30, 1, -23, 10, -85), // 3
TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ_ULTRA, 900, 1, -75, 10, -85), // 4 Test Ultra mode
#define TEST_SILENCE 4
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 200, 100, -70, 0, 0), // 5 Wide band noise floor low mode
TEST_CASE_STRUCT(TC_BELOW, TPH_SILENT, 633, 994, -85, 0, 0), // 6 Wide band noise floor high mode
TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZEXTRA, 30, 14, -23, 27, -70), // 7 BPF loss and stop band
TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZEXTRA, 30, 14, -23, 27, -45), // 7 BPF loss and stop band
TEST_CASE_STRUCT(TC_FLAT, TP_10MHZEXTRA, 30, 14, -18, 9, -60), // 8 BPF pass band flatness
TEST_CASE_STRUCT(TC_BELOW, TP_30MHZ, 900, 1, -90, 0, -90), // 9 LPF cutoff
TEST_CASE_STRUCT(TC_SIGNAL, TP_30MHZ_SWITCH,30, 7, -23, 10, -50), // 10 Switch isolation using high attenuation

@ -75,8 +75,8 @@
#define ADF_SPI_SPEED SPI_BR_DIV2
#define PE4302_HW_SHIFT true
#define PE_SPI_SPEED SPI_BR_DIV2
#define PE_SW_DELAY 1
#define PE_SPI_SPEED SPI_BR_DIV8
#define PE_SW_DELAY 2
static uint32_t old_spi_settings;
#else
@ -1832,7 +1832,7 @@ void enable_extra_lna(int s)
#ifdef __ULTRA__
void enable_ultra(int s)
{
static int old_ultra = -1;
static int old_ultra = 2;
if (s != old_ultra) {
#ifdef TINYSA4
if (s)
@ -1871,6 +1871,10 @@ void enable_high(int s)
#ifdef __NEW_SWITCHES__
void enable_direct(int s)
{
static int old_direct = 2;
if (s == old_direct)
return;
old_direct = s;
if (s)
SI4463_set_gpio(4,SI446X_GPIO_MODE_DRIVE0);
else

@ -1238,6 +1238,21 @@ static UI_FUNCTION_ADV_CALLBACK(menu_ultra_acb)
// menu_move_back(false);
ui_mode_normal();
}
static UI_FUNCTION_ADV_CALLBACK(menu_direct_acb)
{
(void)data;
(void)item;
if (b){
b->icon = config.direct == 0 ? BUTTON_ICON_NOCHECK : BUTTON_ICON_CHECK;
return;
}
config.direct = !config.direct;
config_save();
// menu_move_back(false);
ui_mode_normal();
}
#endif
static UI_FUNCTION_CALLBACK(menu_clearconfig_cb)
@ -2621,6 +2636,7 @@ static const menuitem_t menu_settings3[] =
{ MT_ADV_CALLBACK, 0, "ADF OUT", menu_adf_out_acb},
{ MT_ADV_CALLBACK, 0, "ENABLE\nULTRA", menu_ultra_acb},
{ MT_KEYPAD, KM_LPF, "ULTRA\nSTART", "Enter ULTRA mode start freq"},
{ MT_ADV_CALLBACK, 0, "ENABLE\nDIRECT", menu_direct_acb},
// { MT_KEYPAD | MT_LOW, KM_IF2, "IF2 FREQ", "Set to zero for no IF2"},
{ MT_KEYPAD, KM_R, "R", "Set R"},
{ MT_KEYPAD, KM_MOD, "MODULO", "Set MODULO"},
@ -3118,12 +3134,12 @@ static void fetch_numeric_target(uint8_t mode)
if (setting.level_sweep != 0)
plot_printf(uistat.text, sizeof uistat.text, "%.1f to %.1fdBm", uistat.value, end_level);
else
plot_printf(uistat.text, sizeof uistat.text, "%.1fdBm", uistat.value);
plot_printf(uistat.text, sizeof uistat.text, "%+.1fdBm", uistat.value);
break;
case KM_HIGHOUTLEVEL:
uistat.value = get_level(); // compensation for dB offset during low output mode
uistat.value += setting.external_gain;
plot_printf(uistat.text, sizeof uistat.text, "%.1fdBm", uistat.value);
plot_printf(uistat.text, sizeof uistat.text, "%+.1fdBm", uistat.value);
break;
case KM_DECAY:
uistat.value = setting.decay;

Loading…
Cancel
Save

Powered by TurnKey Linux.