Skip to content

Commit c07ec0e

Browse files
committed
esp32/machine_pwm.c: Fix lightsleep.
Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
1 parent 117fedc commit c07ec0e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ports/esp32/machine_pwm.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,12 @@ static void set_freq(machine_pwm_obj_t *self, unsigned int freq) {
392392
timer.deconfigure = false;
393393

394394
timer.clk_cfg = LEDC_AUTO_CLK;
395-
395+
#if !(CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2)
396+
ledc_clk_cfg_t clk_cfg = find_clock_in_use();
397+
if (clk_cfg != LEDC_AUTO_CLK) {
398+
timer.clk_cfg = clk_cfg;
399+
} else
400+
#endif
396401
if (self->lightsleep) {
397402
timer.clk_cfg = LEDC_USE_RC_FAST_CLK; // 8 or 20 MHz
398403
} else {
@@ -414,7 +419,7 @@ static void set_freq(machine_pwm_obj_t *self, unsigned int freq) {
414419
}
415420
#if !(CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2)
416421
// Check for clock source conflict
417-
ledc_clk_cfg_t clk_cfg = find_clock_in_use();
422+
clk_cfg = find_clock_in_use();
418423
if ((clk_cfg != LEDC_AUTO_CLK) && (clk_cfg != timer.clk_cfg)) {
419424
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("one or more active timers use a different clock source, not supported by the current SoC."));
420425
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy