Electronic – Number of PWM pins on STM32F072

microcontrollerpwmstm32

Microcontroller datasheet

I am in the process of selecting a micro controller for a project where I need a lot of PWM pins (around 30) for LEDs. I'd prefer hardware supported PWM so that my CPU is free for other tasks but it's not a necessity if it can be done comfortably on software side as well. 100 Hz PWM frequency should work for the LEDs and I won't be needing more than 8 brightness levels.

I have narrowed down on STM32F072V8T6 (100 pin LQFP) which has 87 GPIO and other features (like capacitive touch sensing and rtc with Vbat pin) that I require for my project.

Going through the datasheet, I am not able to figure out how many PWM pins can I get out of it (I come from arduino background where no. of PWM pins are mentioned directly). I found a small note saying – "One 16-bit advanced-control timer for six-channel PWM output"

Does that mean I can have only 6 PWM pins?

If this is the really the case, what are my other cheap alternatives to get as many PWM outputs? I saw some PWM output port expanders which communicate over i2c but the cost seems too high.

Best Answer

I don't think that ST has any microcontroller with 30 pwm outputs but with such low frequency you don't really need it. There's a 1 ms interrupt with systick that will provide you with 10 levels of brightness at 100Hz.

Each time the interrupt is triggered set or reset an io pin, you'll have to keep track of 30 variables, one for each pin. It's really easy and you are only limited by the chip pin count.