embassy icon indicating copy to clipboard operation
embassy copied to clipboard

Added support for using variable period PWM timers by updating ARR in stead of CCR.

Open mickem opened this issue 6 months ago • 4 comments

This is a clone of the waveform_chX functions but instead of settings CCR it sets ARR. The effect of this is that the waveform will have a variable period and a fixed pulse width.

I guess one could have added this to the existing macro but I felt this was cleaner.

Note 1: Apart from using arr this should be identical to the other method so I guess one could argue that a "super method" could be built or parts of the function could be reused but as this solved my problem and was quick and simple I went with it.

Note 2: I am unsure about the array type. The original waveform method has a u16 but I think it should be dynamic depending on the underlying timer used so it should be 32 bit for 32bit timers and 16 bit for 16 bit timers.

Note 3: The arr is I think "per timer" not "per channel" so it is possible that it might make more sense to use a single function and not one per channel.

So please do let me know if this makes sense and what makes the most sense regarding all the notes.

mickem avatar Apr 28 '25 17:04 mickem

bender run

jamesmunns avatar May 02 '25 07:05 jamesmunns

@mickem needs one rustfmt fix, but CI should be unstuck now.

jamesmunns avatar May 02 '25 07:05 jamesmunns

Thanks for unsticking, formatting has been fixed...

mickem avatar May 02 '25 07:05 mickem

Any updates on this?

mickem avatar May 20 '25 05:05 mickem