Hi there,
So I don’t believe so but , I know there is such a thing with other ESP32’s you set it and let the Hardware handle it. The ESP32 uses a subsystem called LEDC (LED Control) for PWM output. It’s hardware-driven and very flexible.
You configure:
- PWM frequency (e.g., 25 kHz for motor)
- PWM resolution (e.g., 10 bits for 0–1023)
- Duty cycle (e.g., 500 for ~50%)
Then the LEDC peripheral maintains the output without needing CPU cycles.
Sleep Modes and PWM
Sleep Mode | LEDC PWM Output? | Notes |
---|---|---|
Light Sleep | ![]() |
Timer and LEDC stay active, CPU paused |
Deep Sleep | ![]() |
Only RTC and ULP stay active — LEDC halts |
Something like this is implemented.
ledcSetup(0, 25000, 10); // Channel 0, 25kHz, 10-bit resolution
ledcAttachPin(5, 0); // Pin 5 to channel 0
ledcWrite(0, 512); // 50% duty
// Optionally go to light sleep
esp_sleep_enable_timer_wakeup(1000000); // wake after 1s
esp_light_sleep_start();
HTH
GL PJ
Samd21 is the light weight Xiao, check the Others too