espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.69k stars 7.29k forks source link

Daisy chaining of MCPWM timers (IDFGH-13953) #14786

Open eriksl opened 1 week ago

eriksl commented 1 week ago

Is your feature request related to a problem?

Yeah, so I need PWM (for lighting leds, not just some signalling) that is capable of 16 bits resolution or more. The 14 bits of the LED-PWM on the ESP32-S3 simply doesn't cut it, shame on you for leaving out the "high frequency" LED PWM module ;-)

So I am now turning to the MCPWM module (2x) which will probably do better (it looks like timer width is 16 bits).

Of course I am looking for more. The frequency is not the problem, I am aiming at 100-200 Hz and both types of modules can achieve that easily at the highest resolution.

Now my question is, according to the documentation, MCPWM timers within a group can be linked/synced. Would it be possible to daisychain two of them? Like this scenario: timer 0 counts up to 0xffff, when it overflows it kicks timer 1 and timer 1 progresses than exactly one value (0x0000 -> 0x0001 etc). Like timer 0 is the clock for timer 1. The generators could be linked to timer 1 and up to 32 bits of resolution could be achieved. I don't think it can be done, timer 1 will start running at the rate of the connected clock, not? Maybe there is a workaround? Maybe something likewise can be done with the LED-PWM module, that would be fine too. I really don't need all of the 8 channels ;-)

Thanks for your input!

Describe the solution you'd like.

No response

Describe alternatives you've considered.

No response

Additional context.

No response

suda-morris commented 1 week ago

@eriksl Thanks for the idea, it sounds interesting and promising.

AFAIK, the MCPWM timer's clock source can't be the output of another timer. But I will forward your feature request to our digital team, hopefully we can see this feature in the next chip. :crossed_fingers: I will keep this issue page on until we finally accomplish it.

eriksl commented 1 week ago

Yeah that would be great and probably not too complex to implement in silicon I assume? Something like timer 0 overflow is optional clock level toggle for timer 1.

However a wider timer would be even better of course. Something like 20 bits? Even better: a wider timer on the led pwm controller, I am using the mcpwm purely for the timer width now, which is quite a bit complex for just driving leds.

Thanks!