From 224e75f8e2863da27a7481c98d06fc7800dfb39f Mon Sep 17 00:00:00 2001 From: Aegean Odyssey <57586704+aegean-odyssey@users.noreply.github.com> Date: Mon, 25 Nov 2019 02:33:38 +0000 Subject: [PATCH] Changes to improve printing performance of the USB connection. - change watchdog timeout to call Marlin's kill mechanism - show the "kill" message on the lcd display - change watchdog timeout from ~4.8s to ~9.6s; - reduce delta_segments_per_second to 240 - minor tweaks --- README.md | 3 +-- marlin_changes/Configuration.h | 2 +- marlin_changes/Configuration_adv.h | 2 +- marlin_changes/HAL_stm32.c | 10 ++++---- marlin_changes/HAL_stm32.h | 7 +++--- marlin_changes/Marlin_main.cpp | 1 + marlin_changes/malyanlcd_stm32.cpp | 2 +- marlin_changes/watchdog_stm32.cpp | 39 ++++++++++++++++-------------- 8 files changed, 35 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index adf79082..2ab8a9f6 100644 --- a/README.md +++ b/README.md @@ -96,8 +96,7 @@ M500 ; save M104 S[first_layer_temperature] T0 M140 S[first_layer_bed_temperature] ; wait on hot end and bed temps -M109 -S[first_layer_temperature] T0 +M109 S[first_layer_temperature] T0 M190 S[first_layer_bed_temperature] ; home axes, probe/adjust z-offset, and pause 4s G28 diff --git a/marlin_changes/Configuration.h b/marlin_changes/Configuration.h index f6da26d1..ea5b13dc 100644 --- a/marlin_changes/Configuration.h +++ b/marlin_changes/Configuration.h @@ -633,7 +633,7 @@ // Make delta curves from many straight lines (linear interpolation). // This is a trade-off between visible corners (not enough segments) // and processor overload (too many expensive sqrt calls). - #define DELTA_SEGMENTS_PER_SECOND 500 + #define DELTA_SEGMENTS_PER_SECOND 240 // Convert feedrates to apply to the Effector instead of the Carriages #define DELTA_FEEDRATE_SCALING diff --git a/marlin_changes/Configuration_adv.h b/marlin_changes/Configuration_adv.h index 6028ae77..6a65e51d 100644 --- a/marlin_changes/Configuration_adv.h +++ b/marlin_changes/Configuration_adv.h @@ -915,7 +915,7 @@ // reset. However, THIS FEATURE IS UNSAFE!, as it will only work if // interrupts are disabled. And the code could hang in an interrupt // routine with interrupts disabled. - //#define WATCHDOG_RESET_MANUAL + #define WATCHDOG_RESET_MANUAL #endif // @section lcd diff --git a/marlin_changes/HAL_stm32.c b/marlin_changes/HAL_stm32.c index 14a47fd2..4df3a083 100644 --- a/marlin_changes/HAL_stm32.c +++ b/marlin_changes/HAL_stm32.c @@ -861,6 +861,11 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef * pcd) void SysTick_Handler(void) { +#if ENABLED(USE_WATCHDOG) +#if ENABLED(WATCHDOG_RESET_MANUAL) + faux_watchdog_interrupt(); +#endif +#endif ptimer_isr(); HAL_IncTick(); HAL_SYSTICK_IRQHandler(); @@ -887,11 +892,6 @@ void TIM6_IRQHandler(void) void TIM7_IRQHandler(void) { -#if ENABLED(USE_WATCHDOG) -#if ENABLED(WATCHDOG_RESET_MANUAL) - faux_watchdog_interrupt(void); -#endif -#endif HAL_temp_timer_isr(); TIM7->SR = 0; } diff --git a/marlin_changes/HAL_stm32.h b/marlin_changes/HAL_stm32.h index 34c4a55f..564c633b 100644 --- a/marlin_changes/HAL_stm32.h +++ b/marlin_changes/HAL_stm32.h @@ -148,11 +148,12 @@ int HAL_tim7_init(void); // IWDT -#define FAUX_TIMEOUT 5859 // ~6.0s (depends on tim7 rate) -#define IWDG_TIMEOUT 1500 // ~4.8s - +#define FAUX_TIMEOUT 8000 // 8.0s +#define IWDG_TIMEOUT 3000 // 9.6s + int HAL_iwdg_init(void); void HAL_iwdg_refresh(void); +void faux_watchdog_interrupt(void); // SPI1 diff --git a/marlin_changes/Marlin_main.cpp b/marlin_changes/Marlin_main.cpp index f21db572..e84da39b 100644 --- a/marlin_changes/Marlin_main.cpp +++ b/marlin_changes/Marlin_main.cpp @@ -15649,6 +15649,7 @@ void kill(const char* lcd_msg) #endif } #else + lcd_setalertstatusPGM(lcd_msg); sei(); debug_wait_on_pushbutton(); cli(); diff --git a/marlin_changes/malyanlcd_stm32.cpp b/marlin_changes/malyanlcd_stm32.cpp index 4d061176..d2186845 100644 --- a/marlin_changes/malyanlcd_stm32.cpp +++ b/marlin_changes/malyanlcd_stm32.cpp @@ -608,7 +608,7 @@ void lcd_setalertstatusPGM(const char * message) { char s[MAX_CURLY_COMMAND]; - sprintf(s, "{E:%s}", message); + sprintf(s, "{E:%.30s}", message); malyan_ui_write(s); } diff --git a/marlin_changes/watchdog_stm32.cpp b/marlin_changes/watchdog_stm32.cpp index 4f4722b7..4818a78d 100644 --- a/marlin_changes/watchdog_stm32.cpp +++ b/marlin_changes/watchdog_stm32.cpp @@ -30,37 +30,40 @@ #include "Marlin.h" #include "watchdog.h" - #ifndef FAUX_TIMEOUT -#define FAUX_TIMEOUT 5859 // ~6s, depends on temperature isr rate +#define FAUX_TIMEOUT 8000 // 8s #endif -void watchdog_init(void) +#if ENABLED(WATCHDOG_RESET_MANUAL) +static uint16_t faux_watchdog = 0; + +void faux_watchdog_interrupt(void) { - HAL_iwdg_init(); - watchdog_reset(); + if (! faux_watchdog) return; + if (faux_watchdog--) return; + + SERIAL_ERROR_START(); + SERIAL_ERRORLNPGM("Watchdog Error"); + + kill(PSTR("Watchdog Error")); + //while (1); } void watchdog_reset(void) { -#if ENABLED(WATCHDOG_RESET_MANUAL) faux_watchdog = FAUX_TIMEOUT; -#endif HAL_iwdg_refresh(); } +#else -#if ENABLED(WATCHDOG_RESET_MANUAL) -static uint16_t faux_watchdog = 0; - -void faux_watchdog_interrupt(void) +void watchdog_reset(void) { - if (! faux_watchdog) return; - if (faux_watchdog--) return; + HAL_iwdg_refresh(); +} +#endif +void watchdog_init(void) +{ + HAL_iwdg_init(); watchdog_reset(); - SERIAL_ERROR_START(); - SERIAL_ERRORLNPGM("Watchdog barked, please turn off the printer."); - kill(PSTR("ERR:Watchdog")); - while (1); } -#endif