diff --git a/NANOVNA_STM32_F072/mcuconf.h b/NANOVNA_STM32_F072/mcuconf.h index 241b42d..4142039 100644 --- a/NANOVNA_STM32_F072/mcuconf.h +++ b/NANOVNA_STM32_F072/mcuconf.h @@ -223,6 +223,6 @@ /* * WDG driver system settings. */ -#define STM32_WDG_USE_IWDG FALSE +#define STM32_WDG_USE_IWDG TRUE #endif /* MCUCONF_H */ diff --git a/NANOVNA_STM32_F303/mcuconf.h b/NANOVNA_STM32_F303/mcuconf.h index 4dedf5d..8ce881d 100644 --- a/NANOVNA_STM32_F303/mcuconf.h +++ b/NANOVNA_STM32_F303/mcuconf.h @@ -92,7 +92,7 @@ #else // Use 32768Hz LSE #define STM32_LSE_ENABLED TRUE -#define STM32_LSI_ENABLED FALSE +#define STM32_LSI_ENABLED TRUE #define STM32_RTCSEL STM32_RTCSEL_LSE #define STM32_RTC_PRESA_VALUE 32 #define STM32_RTC_PRESS_VALUE 1024 @@ -265,6 +265,6 @@ /* * WDG driver system settings. */ -#define STM32_WDG_USE_IWDG FALSE +#define STM32_WDG_USE_IWDG TRUE #endif /* MCUCONF_H */ diff --git a/halconf.h b/halconf.h index e8caf3b..5ea5b6e 100644 --- a/halconf.h +++ b/halconf.h @@ -175,7 +175,7 @@ * @brief Enables the WDG subsystem. */ #if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) -#define HAL_USE_WDG FALSE +#define HAL_USE_WDG TRUE #endif /*===========================================================================*/ diff --git a/main.c b/main.c index e07b8d4..32d2a87 100644 --- a/main.c +++ b/main.c @@ -285,6 +285,7 @@ static THD_FUNCTION(Thread1, arg) // plot trace and other indications as raster draw_all(completed); // flush markmap only if scan completed to prevent // remaining traces + wdgReset(&WDGD1); // STOP_PROFILE } @@ -3102,6 +3103,13 @@ int main(void) set_sweep_frequency(ST_STOP, (freq_t) 4000000); sweep(false); #endif + static const WDGConfig scan_wdgcfg = { + STM32_IWDG_PR_256, + STM32_IWDG_RL(1 * (40000 / 256)), /* 1 second */ + STM32_IWDG_WIN_DISABLED + }; + wdgInit(); + wdgStart(&WDGD1, &scan_wdgcfg); if (reset_state|| (caldata_recall(0) == -1)) { load_LCD_properties(); diff --git a/sa_core.c b/sa_core.c index 907afc7..478fb22 100644 --- a/sa_core.c +++ b/sa_core.c @@ -4932,6 +4932,7 @@ again: // Spur redu t++; // one subscan done if (break_on_operation && operation_requested) // break subscanning if requested break; // abort + wdgReset(&WDGD1); } while (t < local_vbw_steps); // till all sub steps done TRACE(7); #ifdef TINYSA4 diff --git a/ui.c b/ui.c index caee27c..3cfb211 100644 --- a/ui.c +++ b/ui.c @@ -186,6 +186,7 @@ int btn_side(void) static int btn_check(void) { systime_t ticks; + wdgReset(&WDGD1); // Debounce input while(TRUE){ ticks = chVTGetSystemTimeX(); @@ -212,6 +213,7 @@ static int btn_check(void) static int btn_wait_release(void) { while (TRUE) { + wdgReset(&WDGD1); systime_t ticks = chVTGetSystemTimeX(); systime_t dt = ticks - last_button_down_ticks; // Debounce input @@ -299,6 +301,7 @@ touch_measure_x(void) static inline int touch_status(void) { + wdgReset(&WDGD1); return adc_single_read(ADC_TOUCH_Y) > TOUCH_THRESHOLD; } @@ -655,6 +658,8 @@ extern const char *states[]; chThdSleepMilliseconds(40); if ((cnt++)&0x07) continue; // Not update time so fast + wdgReset(&WDGD1); + #ifdef TINYSA4 #ifdef __USE_RTC__ uint32_t tr = rtc_get_tr_bin(); // TR read first @@ -7798,6 +7803,7 @@ static void sa_save_file(uint8_t format) { #else plot_printf(fs_filename, FF_LFN_BUF, "%08x.%s", rtc_get_FAT(), file_ext[format]); #endif + wdgReset(&WDGD1); } else { ui_mode_keypad(KM_FILENAME);