Using PWM to control LED brightness on an STM32
I'm looking into the best way to control the brightness of an LED load using PWM from an STM32 and would appreciate some advice on the practical side of the implementation.
My understanding is that the average brightness can be controlled by changing the PWM duty cycle while keeping the LED supply voltage constant. For example, increasing the duty cycle should increase the average current and therefore the perceived brightness.
What I'm less certain about is choosing an appropriate PWM frequency. A very low frequency could potentially result in visible flicker, while a much higher frequency increases the number of switching events.
For a longer LED load, I'm also wondering whether it is better to keep the STM32 PWM output isolated from the actual LED current path using a dedicated MOSFET or LED driver.
If anyone has implemented PWM-controlled LED lighting with an STM32, what PWM frequency and timer configuration have you found to be a good starting point?
I'm particularly interested in the STM32 timer/PWM configuration and the interface between the MCU and the LED driver.
