Page 1 of 1

Problem with low frequency PWM (LEDC)

Posted: Sun Nov 13, 2022 11:37 am
by gluuuyy
I'm using ESP32C3. It has LEDC (and no MCPWM)

Question 1:

What's the min frequency of LEDC PWM?
I tried with ledc example in IDF 4.4.2 and modified the number.
The allowed min number of freq_hz was 10.
But why isn't the min frequency 40MHz/(2^10+1)/(2^14)=2.38Hz ? (chapter 30.3.2.3 of technical reference)
And if we use RTC 8MHz as timer clock, 8MHz/(2^10+1)/(2^14)=0.47Hz
Am I getting the technical reference wrong?

Problem 2:

If I set freq_hz=10 (the lowest allowed value),
I can see the LED blinks at a frequency much lower than 10Hz.

Problem 3:

Get watchdog error if set freq_hz=10. No error when freq_hz high.

Code: Select all

E (10265) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (10265) task_wdt:  - IDLE (CPU 0)
E (10265) task_wdt: Tasks currently running:
E (10265) task_wdt: CPU 0: main
E (15265) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (15265) task_wdt:  - IDLE (CPU 0)
E (15265) task_wdt: Tasks currently running:
E (15265) task_wdt: CPU 0: main
E (20265) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (20265) task_wdt:  - IDLE (CPU 0)
E (20265) task_wdt: Tasks currently running:
E (20265) task_wdt: CPU 0: main

Re: Problem with low frequency PWM (LEDC)

Posted: Fri Jan 06, 2023 1:52 am
by hzlijianjun
I has made a test with esp32c3 for minimum frequency PWM of ledc。
  1.  
  2. ...
  3. ledc_timer_config_t ledc_timer  = {
  4.     ...
  5.     .freq_hz = 2,
  6.     .clk_cfg = LEDC_USE_RTC8M_CLK
  7. }
  8. ...
Looks like it works correctly with the minimum freq_hz set to 2.