Skip to content

Commit

Permalink
fix build errors and averaging bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-tenma-white committed Feb 15, 2021
1 parent 0ed5bae commit e9d2238
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ cd NanoVNA-V2-firmware
Now you can build the firmware by running make in the firmware sources directory:
```
cd NanoVNA-V2-firmware
make BOARDNAME=board_v2_2 EXTRA_CFLAGS="-DSWEEP_POINTS_MAX=201 -DSAVEAREA_MAX=7"
make -j4 BOARDNAME=board_v2_plus EXTRA_CFLAGS="-DSWEEP_POINTS_MAX=201 -DSAVEAREA_MAX=7" LDSCRIPT=./gd32f303cc_with_bootloader.ld
```
Note that `SWEEP_POINTS_MAX` and `SAVEAREA_MAX` can be customized depending on hardware target.
Since Plus4 ECAL is no longer needed, and the extra RAM can be used to increase `SWEEP_POINTS_MAX` to 301 points (warning: experimental! there may not be enough stack space if ram usage is near full).
Expand All @@ -64,7 +64,7 @@ Since Plus4 ECAL is no longer needed, and the extra RAM can be used to increase

For Plus4, a different linker script and display driver needs to be used. The build command line for the Plus4 is:
```
make BOARDNAME=board_v2_plus4 EXTRA_CFLAGS="-DSWEEP_POINTS_MAX=201 -DSAVEAREA_MAX=7 -DDISPLAY_ST7796" LDSCRIPT=./gd32f303cc_with_bootloader_plus4.ld
make -j4 BOARDNAME=board_v2_plus4 EXTRA_CFLAGS="-DSWEEP_POINTS_MAX=201 -DSAVEAREA_MAX=7 -DDISPLAY_ST7796" LDSCRIPT=./gd32f303cc_with_bootloader_plus4.ld
```

The first time you build the firmware on a fresh repository, there is a libopencm3 bug that sometimes causes the linker script to be overwritten with one that will not work. If the built firmware does not boot, try running the following commands, then rebuild:
Expand Down
15 changes: 9 additions & 6 deletions main2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ static void setVNASweepToUSB() {
setFrequency((freqHz_t)*(uint64_t*)(registers + 0x00));
}
#else
currTimingsArgs.nAverage = 1;
sys_syscall(5, &currTimingsArgs);
setHWSweep(sys_setSweep_args {
(freqHz_t)*(uint64_t*)(registers + 0x00),
(freqHz_t)*(uint64_t*)(registers + 0x10),
Expand Down Expand Up @@ -987,6 +989,9 @@ static void measurementDataSmooth(complexf *data, int points, int count){
data[j] = (data[j] + data[j] + prev)/3.0f;
}
}
int currDPCnt = 0;
int lastFreqIndex = -1;
VNAObservation currDP;

#define USE_FIXED_CORRECTION
// callback called by VNAMeasurement when an observation is available.
Expand Down Expand Up @@ -1155,10 +1160,10 @@ static void setVNASweepToUI() {
vnaMeasurement.setSweep(start, step, current_props._sweep_points, current_props._avg);
ecalState = ECAL_STATE_MEASURING;
#else
currTimingsArgs.nAverage = current_props._avg;
currTimingsArgs.nAverage = 1;
sys_syscall(5, &currTimingsArgs);
setHWSweep(sys_setSweep_args {
start, step, current_props._sweep_points, 1
start, step, current_props._sweep_points, current_props._avg
});
#endif
update_grid();
Expand Down Expand Up @@ -1867,7 +1872,7 @@ namespace UIActions {
vnaMeasurement.measurement_mode = MEASURE_MODE_FULL;
collectMeasurementCB = [type]() {
#if BOARD_REVISION >= 4
sys_setTimings_args args {0, current_props._avg};
sys_setTimings_args args {0, 1};
sys_syscall(5, &args);
#else
vnaMeasurement.ecalIntervalPoints = MEASUREMENT_ECAL_INTERVAL;
Expand All @@ -1876,9 +1881,7 @@ namespace UIActions {
current_props._cal_status |= (1 << type);
ui_cal_collected();
};
uint32_t avgMult = current_props._avg;
if(avgMult < BOARD_MEASUREMENT_MIN_CALIBRATION_AVG) avgMult = BOARD_MEASUREMENT_MIN_CALIBRATION_AVG;
if(avgMult > BOARD_MEASUREMENT_MAX_CALIBRATION_AVG) avgMult = BOARD_MEASUREMENT_MAX_CALIBRATION_AVG;
uint32_t avgMult = 2;
#if BOARD_REVISION >= 4
__sync_synchronize();
sys_setTimings_args args {0, avgMult};
Expand Down

0 comments on commit e9d2238

Please sign in to comment.