SCANRAW zero level reduced

Removed_REF_marker
erikkaashoek 5 years ago
parent 8443630550
commit 8f81361bcd

@ -187,7 +187,7 @@
PIN_OSPEED_2M(5) | \
PIN_OSPEED_2M(6) | \
PIN_OSPEED_2M(7) | \
PIN_OSPEED_100M(8U) | \
PIN_OSPEED_2M(8U) | \
PIN_OSPEED_100M(9) | \
PIN_OSPEED_100M(10) | \
PIN_OSPEED_100M(GPIOA_USB_DM) | \
@ -305,7 +305,7 @@
PIN_OSPEED_100M(12) | \
PIN_OSPEED_100M(13) | \
PIN_OSPEED_100M(14) | \
PIN_OSPEED_100M(15))
PIN_OSPEED_2M(15))
#define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(0) | \
PIN_PUPDR_PULLUP(1) | \
PIN_PUPDR_PULLUP(2) | \

@ -809,7 +809,6 @@ VNA_SHELL_FUNCTION(cmd_dump)
VNA_SHELL_FUNCTION(cmd_refresh)
{
// read pixel count at one time (PART*2 bytes required for read buffer)
int i, y;
int m = generic_option_cmd("refresh", "off|on", argc, argv[0]);
if (m>=0) {
auto_capture = m;

@ -893,7 +893,14 @@ extern int debug_frequencies;
// STM32 minimum page size for write
#define FLASH_PAGESIZE 0x800
// config save area (flash7 addr)
#ifdef TINYSA3
#define SAVE_CONFIG_ADDR 0x0801B000
#endif
#ifdef TINYSA4
#define SAVE_CONFIG_ADDR 0x0803B000
#endif
#define SAVE_CONFIG_SIZE 0x00000800
// setting_t save area (save area + config size)
#define SAVE_PROP_CONFIG_ADDR (SAVE_CONFIG_ADDR + SAVE_CONFIG_SIZE)
@ -1120,7 +1127,7 @@ typedef int16_t pureRSSI_t;
// RSSI values conversion macro
// External programm zero level settings (need decrease on this value -)
#define EXT_ZERO_LEVEL (128)
#define EXT_ZERO_LEVEL (174)
#define DEVICE_TO_PURE_RSSI(rssi) ((rssi)<<4)
#define PURE_TO_DEVICE_RSSI(rssi) ((rssi)>>4)
#define float_TO_PURE_RSSI(rssi) ((rssi)*32)

@ -970,7 +970,7 @@ void trace_get_value_string( // Only used at one place
plot_printf(ptr2, sizeof(buf2) - 2, "%3.1f" , (dfreq + 50000) / 1000000.0);
}
#else
plot_printf(ptr2, sizeof(buf2) - 2, "%9.4qHz" , dfreq);
plot_printf(ptr2, sizeof(buf2) - 2, "%9.5qHz" , dfreq);
}
#endif
v = value(coeff[i]);

@ -169,7 +169,7 @@ void reset_settings(int m)
set_sweep_frequency(ST_STOP, 2900000000); // TODO <----------------- temp ----------------------
else
set_sweep_frequency(ST_STOP, 800000000); // TODO <----------------- temp ----------------------
setting.attenuate_x2 = 0; // TODO <----------------- temp ---------------
setting.attenuate_x2 = 10;
setting.auto_attenuation = true;
setting.sweep_time_us = 0;
setting.lo_drive=1;
@ -1161,15 +1161,28 @@ void calculate_correction(void)
pureRSSI_t get_frequency_correction(uint32_t f) // Frequency dependent RSSI correction to compensate for imperfect LPF
{
pureRSSI_t cv;
if (setting.extra_lna) {
if (f > 2100000000U) {
cv = float_TO_PURE_RSSI(+13);
} else {
cv = float_TO_PURE_RSSI( (float)f * 6.0 / 1000000000); // +6dBm at 1GHz
}
}
if (!(setting.mode == M_LOW || setting.mode == M_GENLOW))
return(0.0);
int i = 0;
while (f > config.correction_frequency[i] && i < CORRECTION_POINTS)
i++;
if (i >= CORRECTION_POINTS)
return(scaled_correction_value[CORRECTION_POINTS-1] >> (SCALE_FACTOR - 5) );
if (i == 0)
return(scaled_correction_value[0] >> (SCALE_FACTOR - 5) );
if (i >= CORRECTION_POINTS) {
cv += scaled_correction_value[CORRECTION_POINTS-1] >> (SCALE_FACTOR - 5);
goto done;
}
if (i == 0) {
cv += scaled_correction_value[0] >> (SCALE_FACTOR - 5);
goto done;
}
f = f - config.correction_frequency[i-1];
#if 0
uint32_t m = (config.correction_frequency[i] - config.correction_frequency[i-1]) >> SCALE_FACTOR ;
@ -1177,8 +1190,9 @@ pureRSSI_t get_frequency_correction(uint32_t f) // Frequency dependent RSSI
float cv = config.correction_value[i-1] + ((f >> SCALE_FACTOR) * multi) / (float)(1 << (SCALE_FACTOR -1)) ;
#else
int32_t scaled_f = f >> SCALE_FACTOR;
pureRSSI_t cv = (scaled_correction_value[i-1] + (scaled_f * scaled_correction_multi[i])) >> (SCALE_FACTOR - 5) ;
cv += (scaled_correction_value[i-1] + (scaled_f * scaled_correction_multi[i])) >> (SCALE_FACTOR - 5) ;
#endif
done:
return(cv);
}
#pragma GCC pop_options
@ -2042,7 +2056,7 @@ modulation_again:
}
// -------------------------------- Acquisition loop for one requested frequency covering spur avoidance and vbwsteps ------------------------
pureRSSI_t RSSI = float_TO_PURE_RSSI(-150);
#define __DEBUG_SPUR__
//#define __DEBUG_SPUR__
#ifdef __DEBUG_SPUR__ // For debugging the spur avoidance control
if (!setting.auto_IF)
stored_t[i] = -90.0; // Display when to do spur shift in the stored trace
@ -2217,14 +2231,18 @@ modulation_again:
ADF4351_R_counter(setting.R);
if (false) { // Avoid 72MHz spur
#define SPUR 72000000
if (true) { // Avoid 72MHz spur
#define SPUR 2 * 72000000
uint32_t tf = ((lf + actual_rbw_x10*100) / SPUR) * SPUR;
#undef STM32_USBPRE
int STM32_USBPRE;
#undef STM32_PLLMUL
int STM32_PLLMUL;
if (lf < 200000000 && lf >= SPUR && tf + actual_rbw_x10*100 >= lf && tf < lf + actual_rbw_x10*100) {
if (lf < 200000000 && lf >= SPUR && tf + actual_rbw_x10*400 >= lf && tf < lf + actual_rbw_x10*400) {
RCC->CFGR |= STM32_SW_HSI;
#if 0
STM32_USBPRE = STM32_USBPRE_DIV1; // Switch to 48MHz clock (1 << 22)
STM32_PLLMUL = ((6 - 2) << 18);
uint32_t CFGR = STM32_MCOSEL | STM32_USBPRE | STM32_PLLMUL |
@ -2235,12 +2253,16 @@ modulation_again:
old_CFGR = CFGR;
RCC->CFGR = CFGR;
}
#endif
} else {
RCC->CFGR |= STM32_SW_PLL;
#if 0
STM32_USBPRE = STM32_USBPRE_DIV1P5; // Switch to 72MHz clock (0 << 22)
STM32_PLLMUL = ((9 - 2) << 18);
orig_CFGR = STM32_MCOSEL | STM32_USBPRE | STM32_PLLMUL |
STM32_PLLSRC | STM32_PPRE1 | STM32_PPRE2 |
STM32_HPRE;
#endif
}
}

@ -44,7 +44,8 @@
#ifdef USE_HARDWARE_SPI_MODE
#define SI4432_SPI SPI1
//#define SI4432_SPI_SPEED SPI_BR_DIV64
#define SI4432_SPI_SPEED SPI_BR_DIV16
#define SI4432_SPI_SPEED SPI_BR_DIV32
//#define SI4432_SPI_SPEED SPI_BR_DIV16
static uint32_t old_spi_settings;
#else
static uint32_t old_port_moder;
@ -1043,8 +1044,8 @@ void ADF4351_Setup(void)
ADF4351_set_frequency(0,200000000);
// ADF4351_mux(2); // No led
ADF4351_mux(6); // Show lock on led
ADF4351_mux(2); // No led
// ADF4351_mux(6); // Show lock on led
// ADF4351_set_frequency(1,150000000,0);
// ADF4351_Set(0);
@ -1331,10 +1332,15 @@ void ADF4351_enable_aux_out(int s)
void ADF4351_enable_out(int s)
{
if (s)
bitSet(registers[4], 5);
else
bitClear(registers[4], 5);
if (s) {
bitClear(registers[2], 11); // Disable VCO power down
bitClear(registers[2], 5); // Disable power down
bitSet(registers[4], 5); // Enable output
} else {
bitClear(registers[4], 5); // Disable output
bitSet(registers[2], 5); // Enable power down
bitSet(registers[2], 11); // Enable VCO power down
}
ADF4351_Set(0);
}

@ -765,6 +765,25 @@ static UI_FUNCTION_ADV_CALLBACK(menu_lo_drive_acb)
// draw_cal_status();
}
static UI_FUNCTION_ADV_CALLBACK(menu_mixer_drive_acb)
{
(void)item;
if(b){
#ifdef TINYSA4
b->param_1.i = data;
#else
b->param_1.i = menu_drive_value[data] + (setting.mode==M_GENHIGH ? setting.offset : 0);
#endif
b->icon = data == setting.lo_drive ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return;
}
//Serial.println(item);
set_lo_drive(data);
menu_move_back();
// ui_mode_normal();
// draw_cal_status();
}
static UI_FUNCTION_ADV_CALLBACK(menu_sdrive_acb){
(void)item;
(void)data;
@ -1526,11 +1545,11 @@ static const menuitem_t menu_load_preset[] =
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_lo_drive[] = {
{ MT_ADV_CALLBACK, 3, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 2, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 1, "%+ddBm", menu_lo_drive_acb},
{ MT_ADV_CALLBACK, 0, "%+ddBm", menu_lo_drive_acb},
static const menuitem_t menu_mixer_drive[] = {
{ MT_ADV_CALLBACK, 3, "%+ddBm", menu_mixer_drive_acb},
{ MT_ADV_CALLBACK, 2, "%+ddBm", menu_mixer_drive_acb},
{ MT_ADV_CALLBACK, 1, "%+ddBm", menu_mixer_drive_acb},
{ MT_ADV_CALLBACK, 0, "%+ddBm", menu_mixer_drive_acb},
{ MT_CANCEL, 255, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
@ -1895,7 +1914,7 @@ static const menuitem_t menu_settings[] =
{ MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "Set to zero for auto IF"},
{ MT_SUBMENU,0, "SCAN SPEED", menu_scanning_speed},
{ MT_KEYPAD, KM_REPEAT, "SAMPLE\nREPEAT", "1..100"},
{ MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_lo_drive},
{ MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_mixer_drive},
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_settings2},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel

Loading…
Cancel
Save

Powered by TurnKey Linux.