mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
Fix very strange bug, on band 2
!!!!! Don`t understand why si5351 non stable on band 2 then change from band 3 It fixed if set before sweep one frequency from band 1 (for example 50MHz) Possibly problem in tlv320aic3204_set_gain, call only si5351_set_frequency_with_offset not work Little faster call command from shell Fix interpolation if points < POINTS_COUNT
This commit is contained in:
parent
3eb8a4cfe9
commit
23c765b719
23
main.c
23
main.c
|
|
@ -120,6 +120,8 @@ static THD_FUNCTION(Thread1, arg)
|
|||
if (shell_function){
|
||||
shell_function(shell_nargs-1, &shell_args[1]);
|
||||
shell_function = 0;
|
||||
osalThreadSleepMilliseconds(10);
|
||||
continue;
|
||||
}
|
||||
// Process UI inputs
|
||||
ui_process();
|
||||
|
|
@ -802,11 +804,18 @@ bool sweep(bool break_on_operation)
|
|||
// blink LED while scanning
|
||||
palClearPad(GPIOC, GPIOC_LED);
|
||||
// Power stabilization after LED off, also align timings on i == 0
|
||||
|
||||
// !!!!! Don`t understand why si5351 non stable on band 2 then change from band 3
|
||||
// It fixed if set before one band 1 frequency
|
||||
// Possibly problem in gain, call only si5351_set_frequency_with_offset not work
|
||||
// Also it allow align sweep timings
|
||||
set_frequency(50000000);
|
||||
DSP_START(1);DSP_WAIT_READY;
|
||||
for (i = 0; i < sweep_points; i++) { // 5300
|
||||
if (frequencies[i] == 0) break;
|
||||
delay = set_frequency(frequencies[i]); // 700
|
||||
tlv320aic3204_select(0); // 60 CH0:REFLECT, reset and begin measure
|
||||
DSP_START(delay+((i==0)?2:0)); // 1900
|
||||
DSP_START(delay); // 1900
|
||||
//================================================
|
||||
// Place some code thats need execute while delay
|
||||
//================================================
|
||||
|
|
@ -1359,7 +1368,7 @@ cal_interpolate(int s)
|
|||
j = 0;
|
||||
for (; i < sweep_points; i++) {
|
||||
uint32_t f = frequencies[i];
|
||||
|
||||
if (f == 0) goto interpolate_finish;
|
||||
for (; j < src->_sweep_points-1; j++) {
|
||||
if (src->_frequencies[j] <= f && f < src->_frequencies[j+1]) {
|
||||
// found f between freqs at j and j+1
|
||||
|
|
@ -1388,11 +1397,11 @@ cal_interpolate(int s)
|
|||
for (; i < sweep_points; i++) {
|
||||
// fill cal_data at tail of src
|
||||
for (eterm = 0; eterm < 5; eterm++) {
|
||||
cal_data[eterm][i][0] = src->_cal_data[eterm][sweep_points-1][0];
|
||||
cal_data[eterm][i][1] = src->_cal_data[eterm][sweep_points-1][1];
|
||||
cal_data[eterm][i][0] = src->_cal_data[eterm][src->_sweep_points-1][0];
|
||||
cal_data[eterm][i][1] = src->_cal_data[eterm][src->_sweep_points-1][1];
|
||||
}
|
||||
}
|
||||
|
||||
interpolate_finish:
|
||||
cal_status |= src->_cal_status | CALSTAT_APPLY | CALSTAT_INTERPOLATED;
|
||||
redraw_request |= REDRAW_CAL_STATUS;
|
||||
}
|
||||
|
|
@ -2184,8 +2193,8 @@ static void VNAShell_executeLine(char *line){
|
|||
shell_function= scp->sc_function;
|
||||
// Wait execute command in sweep thread
|
||||
do{
|
||||
osalThreadSleepMilliseconds(100);}
|
||||
while(shell_function);
|
||||
osalThreadSleepMilliseconds(100);
|
||||
} while(shell_function);
|
||||
}
|
||||
else
|
||||
scp->sc_function(shell_nargs-1, &shell_args[1]);
|
||||
|
|
|
|||
19
si5351.c
19
si5351.c
|
|
@ -65,13 +65,26 @@ si5351_bulk_write(const uint8_t *buf, int len)
|
|||
(void)i2cMasterTransmitTimeout(&I2CD1, SI5351_I2C_ADDR, buf, len, NULL, 0, 1000);
|
||||
i2cReleaseBus(&I2CD1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void si5351_bulk_read(uint8_t reg, uint8_t* buf, int len)
|
||||
static bool si5351_bulk_read(uint8_t reg, uint8_t* buf, int len)
|
||||
{
|
||||
int addr = SI5351_I2C_ADDR>>1;
|
||||
i2cAcquireBus(&I2CD1);
|
||||
msg_t mr = i2cMasterTransmitTimeout(&I2CD1, addr, ®, 1, buf, len, 1000);
|
||||
msg_t mr = i2cMasterTransmitTimeout(&I2CD1, SI5351_I2C_ADDR, ®, 1, buf, len, 1000);
|
||||
i2cReleaseBus(&I2CD1);
|
||||
return mr == MSG_OK;
|
||||
}
|
||||
|
||||
static void si5351_wait_pll_lock(void)
|
||||
{
|
||||
uint8_t status;
|
||||
int count = 100;
|
||||
do{
|
||||
status=0xFF;
|
||||
si5351_bulk_read(0, &status, 1);
|
||||
if ((status & 0x60) == 0) // PLLA and PLLB locked
|
||||
return;
|
||||
}while (--count);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue