From 8729b385f0132c0b53b5a9c60e4e3d4226fd3533 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Sun, 27 Feb 2022 17:45:05 +0100 Subject: [PATCH] Prevent crash on start with >100Hz on counter input Same procedure. setoption65 1 is a working workaround to avoid a crash on starting the device when there is a frequency of 100Hz or higher on one counter. The change temporarily disables the counter during the access to the flash. I', currently not sure if this is an ESP8266 only problem or also an ESP32 problem that the interrupt of the counter and flash access could cause a crash. --- tasmota/settings.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tasmota/settings.ino b/tasmota/settings.ino index 0a9ec1c9c..7309106e9 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -230,7 +230,9 @@ void UpdateQuickPowerCycle(bool update) { const uint32_t QPC_COUNT = 7; // Number of Power Cycles before Settings erase const uint32_t QPC_SIGNATURE = 0xFFA55AFF; - +#ifdef USE_COUNTER + CounterInterruptDisable(true); +#endif #ifdef ESP8266 const uint32_t qpc_sector = SETTINGS_LOCATION - CFG_ROTATES; const uint32_t qpc_location = qpc_sector * SPI_FLASH_SEC_SIZE; @@ -280,10 +282,11 @@ void UpdateQuickPowerCycle(bool update) { AddLog(LOG_LEVEL_INFO, PSTR("QPC: Reset")); } #endif // ESP32 - +#ifdef USE_COUNTER + CounterInterruptDisable(false); +#endif #endif // FIRMWARE_MINIMAL } - #ifdef USE_EMERGENCY_RESET /*********************************************************************************************\ * Emergency reset if Rx and Tx are tied together