Open tcbennun opened 2 years ago
RTC8M_CLK
is the old name for FOSC_CLK
(we are planning to do some refactor to make the clock name unified on all chips), so you can select LEDC_USE_RTC8M_CLK
to keep the PWM during light sleep on ESP32C3.
There are two more things you need to make sure before you can see the PWM in sleep:
First is to make sure the gpio pin is configured correctly in sleep mode. The easiest way is probably by calling gpio_sleep_sel_dis(pin_num)
.
Second is you need to keep the RTC8M_CLK
on during sleep by calling esp_sleep_pd_config(ESP_PD_DOMAIN_RTC8M, ESP_PD_OPTION_ON)
(if you are on master or release/v4.4, then you don't need to worry about this, this will be done internally).
The definition of the
ledc_clk_cfg_t
enum inledc_types.h
includesLEDC_USE_RTC8M_CLK
for all SoCs. ESP32-C3 does not have such a clock, so this option is ambiguous.According to the TRM, LEDC_SCLK on ESP32-C3 may be sourced from APB_CLK, FOSC_CLK or XTAL_CLK (though the clock diagram in Figure 6-2 does not indicate that XTAL_CLK is an option!)
(Also, the TRM states that FOSC_CLK is the option to choose in order to generate PWM during light sleep, but the option isn't explicitly available in ESP-IDF, and when forcing the option in the conf register, PWM doesn't generate in light sleep anyway. If anyone has any idea how to make that work, I would appreciate the help!)