cancel
Showing results for 
Search instead for 
Did you mean: 

I'd like to generate the PWM using the GPIO pins available. Is it possible? And what's the maximum output current can be provided by the GPIO pins?

CNguy.11
Associate

The MCU I'm trying to use in my application project is the STM32F446ZCJ. The main purpose is to generate 48 PWM to control the regulators. Is it possible?

2 REPLIES 2

Oh, a "manually bit-banged" PWM... so you run a timer, and in its interrupt you count on a counter and based on how it compares to the given "channel's" current setting you toggle a GPIO pin... Say, a well-written routine may take something around 20 cycles per pin if all pins run at the same PWM frequency, that's around 1000 cycles to handle 48 pins, at 180MHz it takes around 5.5us. You want to do something useful with the mcu, so say you don't want to run this more than some 25% of the total processing time, so your basic PWM "tick" is around 20us. For example, for 8-bit resolution you can then achieve some 200Hz PWM frequency.

> to control the regulators

Don't assume we know what your task is. What is "the regulator"?

JW

Danish1
Lead II

As well as a maximum current that may be drawn from a single pin, there is a maximum total current which may be drawn from all I/O pins combined.

For sm32f437 we're talking 25 mA per pin but only 120 mA for all pins. So you don't gain anything by paralleling more than 5 pins.

Now if you're after more PWM because you have many independent regulators to control (and are not just trying to boost the drive current), then the next question is how the processor might keep track of all the regulator loops - there's a lot of processing involved.

If all PWMs have the same period (but not necessarily the same duty-cycle) you could use DMA driven off a timer to pump out a predetermined PWM pattern to a port. If you're not using all 16 bits on a port, writing 32-bit DMA to the BSRR can leave some pins untouched.

I might add that this is not the approach I would consider first - it's all very complicated and there's a risk that a bug in the software will blow up the hardware!

Danish