From 82ad33c98f87a54bea52a775420c8f0b057d5ce2 Mon Sep 17 00:00:00 2001 From: Gregg Date: Sat, 25 Sep 2021 15:58:23 -0500 Subject: [PATCH] Updated error-check for out-of-range PWM frequency (an ESP32-S2 check) PWM has now been fully tested and verified with an ESP32 device under Arduino-ESP32 versions 1.0.6 and 2.0.0, and with an ESP32-S2 device under Arduino-ESP32 version 2.0.0. Tests confirmed using both high (5000 Hz) and low (1 Hz or 5Hz) frequencies to ensure timers are correctly configured. Next Task: Update RFControl routines for 2.0.0 and ESP32-S2 compatibility. --- src/extras/PwmPin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/extras/PwmPin.cpp b/src/extras/PwmPin.cpp index e45e873..31609de 100644 --- a/src/extras/PwmPin.cpp +++ b/src/extras/PwmPin.cpp @@ -30,6 +30,8 @@ LedC::LedC(uint8_t pin, uint16_t freq){ timerList[nTimer][nMode]->duty_resolution=(ledc_timer_bit_t)res; if(ledc_timer_config(timerList[nTimer][nMode])!=0){ Serial.printf("\n*** ERROR: Frequency=%d Hz is out of allowed range ---",freq); + delete timerList[nTimer][nMode]; + timerList[nTimer][nMode]=NULL; return; } }