From 654e58e0d17dda8bf5c053d6a10333fe103b3d87 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Fri, 3 Jul 2020 12:53:35 +0200 Subject: [PATCH] Add option to debug AGC --- sa_core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sa_core.c b/sa_core.c index d806ee6..4f33366 100644 --- a/sa_core.c +++ b/sa_core.c @@ -20,6 +20,8 @@ #include "SI4432.h" // comment out for simulation #include "stdlib.h" +//#define __DEBUG_AGC__ If set the AGC value will be shown in the stored trace and fast CW mode will be disabled + int dirty = true; int scandirty = true; @@ -1499,7 +1501,9 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M #ifdef __FAST_SWEEP__ if (i == 0 && setting.frequency_step == 0 && setting.trigger == T_AUTO && setting.spur == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) { // if ultra fast scanning is needed prefill the SI4432 RSSI read buffer +#ifndef __DEBUG_AGC__ // Don't prefill if debugging the AGC SI4432_Fill(MODE_SELECT(setting.mode), 0); +#endif } #endif @@ -1542,7 +1546,9 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M #ifdef __FAST_SWEEP__ if (i == 0 && setting.frequency_step == 0 /* && setting.trigger == T_AUTO */&& setting.spur == 0 && old_actual_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < ONE_SECOND_TIME) { - SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer +#ifndef __DEBUG_AGC__ // do not prefill if debugging the AGC + SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer +#endif } #endif SI4432_step_delay = old_actual_step_delay; // Trigger happened, restore step delay @@ -1675,7 +1681,9 @@ sweep_again: // stay in sweep loop when output mo if (setting.subtract_stored) { RSSI = RSSI - stored_t[i] ; } - // stored_t[i] = (SI4432_Read_Byte(0x69) & 0x0f) * 3.0 - 90.0; // Display the AGC value in the stored trace +#ifdef __DEBUG_AGC__ // For debugging the AGC control + stored_t[i] = (SI4432_Read_Byte(0x69) & 0x0f) * 3.0 - 90.0; // Display the AGC value in the stored trace +#endif if (scandirty || setting.average == AV_OFF) { // Level calculations actual_t[i] = RSSI; age[i] = 0;