Custom PWM Freq

Hi all

I know earlier on in the year there was some talk about creating a library for more advanced PWM use e.g. analogWrite(duty,freq,pin) for example.
Just wondered if anyone has got around to this? If not would there be an implementation possible using @peekay123’s intervalTimer library? Would this be the most efficient way to do it? I’m used to setting up PWM directly via the timer registers on other platforms, however if there is an abstracted method already out there I’d be keen to give that a go.


@G65434_2: You must be referring to a custom PWM frequency? Because analogWrite() by nature is custom duty cycle.
A custom frequency has a lot of challenges, most notably loss of resolution when increasing speed.

Me too. You’re always welcome to dig down to the bare metal with a local build, and see what can be accomplished.

1 Like

Yes @WebDust21, sorry wasn’t really thinking there, I’m only after 1kHz so it should be fine, I suppose I’ll just read the STM32F2 datasheet and implement it locally for now.