From 772f84af39d8630e4d5587d001a05c0ae86bf34d Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Sat, 20 Mar 2021 14:17:46 +0100 Subject: [PATCH] Selftest and channel line --- Makefile | 1 + plot.c | 4 +++- sa_core.c | 10 +++++----- si4468.c | 9 ++++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 46e76b6..831bcaf 100644 --- a/Makefile +++ b/Makefile @@ -286,6 +286,7 @@ ULIBS = -lm RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC include $(RULESPATH)/rules.mk +#include $(CHIBIOS)/memory.mk flash: build/ch.bin dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D build/ch.bin diff --git a/plot.c b/plot.c index 3338597..9f4f55f 100644 --- a/plot.c +++ b/plot.c @@ -930,11 +930,13 @@ draw_cell(int m, int n) for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = c; } #ifdef __CHANNEL_POWER__ + c = GET_PALTETTE_COLOR(LCD_BRIGHT_COLOR_GREEN); if (setting.measurement == M_CP) { if (x+x0 == WIDTH/3 || x+x0 == 2*WIDTH/3 ) { - for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = LCD_TRIGGER_COLOR; + for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = c; } } + c = GET_PALTETTE_COLOR(LCD_GRID_COLOR); #endif } for (y = 0; y < h; y++) { diff --git a/sa_core.c b/sa_core.c index 5966167..172eeda 100644 --- a/sa_core.c +++ b/sa_core.c @@ -2639,7 +2639,7 @@ modulation_again: if (S_STATE(setting.spur_removal)){ // If in low input mode and spur reduction is on if (S_IS_AUTO(setting.below_IF) && #ifdef TINYSA4 - ( lf > ULTRA_MAX_FREQ || lf < local_IF/2 /* || ( (uint64_t)lf + (uint64_t)local_IF< MAX_LO_FREQ && lf + local_IF > 136000000ULL) */) + ( lf > ULTRA_MAX_FREQ || lf < local_IF/2 /* || ( (uint64_t)lf + (uint64_t)local_IF< MAX_LO_FREQ && lf + local_IF > 136000000ULL) */) #else (lf < local_IF / 2 || lf > local_IF) #endif @@ -2776,7 +2776,7 @@ modulation_again: if (setting.harmonic && lf > ULTRA_MAX_FREQ) { error_f *= setting.harmonic; } - if (error_f > actual_rbw_x10 * 5) //RBW / 4 +// if (error_f > actual_rbw_x10 * 5) //RBW / 4 local_IF += error_f; } else if ( real_old_freq[ADF4351_LO] < target_f) { error_f = real_old_freq[ADF4351_LO] - target_f; @@ -2788,7 +2788,7 @@ modulation_again: if (setting.harmonic && lf > ULTRA_MAX_FREQ) { error_f *= setting.harmonic; } - if ( error_f < - actual_rbw_x10 * 5) //RBW / 4 +// if ( error_f < - actual_rbw_x10 * 5) //RBW / 4 local_IF += error_f; } #endif @@ -3037,7 +3037,7 @@ modulation_again: pureRSSI = 0; else pureRSSI = Si446x_RSSI(); -//#define __DEBUG_FREQUENCY_SETTING__ +#define __DEBUG_FREQUENCY_SETTING__ #ifdef __DEBUG_FREQUENCY_SETTING__ // For debugging the frequency calculation stored_t[i] = -60.0 + (real_old_freq[ADF4351_LO] - f - old_freq[2])/10; #endif @@ -4012,7 +4012,7 @@ const test_case_t test_case [] = }; #else {// Condition Preparation Center Span Pass Width(%)Stop - TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.005, 0.01, 0, 0, 0), // 1 Zero Hz leakage + TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.005, 0.01, 10, 0, 0), // 1 Zero Hz leakage TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 0.015, 0.01, -30, 0, 0), // 2 Phase noise of zero Hz TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZ, 20, 7, -39, 10, -90), // 3 TEST_CASE_STRUCT(TC_SIGNAL, TP_10MHZ, 30, 7, -34, 10, -90), // 4 diff --git a/si4468.c b/si4468.c index b00a71a..bb64e12 100644 --- a/si4468.c +++ b/si4468.c @@ -913,7 +913,6 @@ float Simulated_SI4432_RSSI(uint32_t i, int s) #endif //------------------------------- ADF4351 ------------------------------------- -#ifdef __ADF4351__ #define bitRead(value, bit) (((value) >> (bit)) & 0x01) #define bitSet(value, bit) ((value) |= (1UL << (bit))) @@ -1207,11 +1206,13 @@ uint64_t ADF4351_prepare_frequency(int channel, uint64_t freq) // freq / 10Hz bitWrite (registers[4], 20, 0); } + volatile uint64_t PFDR = PFDRFout[channel]; - INTA = (((uint64_t)freq) * OutputDivider) / PFDR; MOD = ADF4350_modulo; + uint64_t half_spacing = PFDR / MOD / 2 / OutputDivider; + INTA = (((uint64_t)freq + half_spacing) * OutputDivider) / PFDR; uint64_t f_int = INTA *(uint64_t) MOD; - uint64_t f_target = ((((uint64_t)freq) * OutputDivider) * (uint64_t) MOD) / PFDR; + uint64_t f_target = ((((uint64_t)freq + half_spacing) * OutputDivider) * (uint64_t) MOD) / PFDR; FRAC = f_target - f_int; if (FRAC >= MOD) { FRAC -= MOD; @@ -1262,8 +1263,6 @@ uint64_t ADF4351_prepare_frequency(int channel, uint64_t freq) // freq / 10Hz return actual_freq; } -#endif - void ADF4351_enable(int s) { if (s)