cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030F4P6 - PWM output voltage

boulganamed
Associate

I am working on a project to replace a legacy ST62 IC in a industrial charger 24V/45A charger with an STM32 microcontroller (STM32F0 series). The main issue is with the PWM signal generation using TIM1 and TIM3. Both timers have 16-bit prescalers (value 0 to 65535), and I need to generate a PWM at 1 kHz with about 1000 steps of resolution.

My timer clock is 8 MHz. Based on calculations, prescaler and ARR values can generate correct frequencies, but the PWM output voltage is only around 2.7V instead of the expected 5V, and there is no effective voltage output for charging.

I suspect this issue is linked to the STM32CubeMX pinout or timer configuration:

  • Correct PA6 pin configuration for TIM3 PWM output.

  • Proper timer frequency setup: prescaler around 725 with ARR 0 tested, but PWM not as expected.

  • Possible problem in software initialization or timer start sequence affecting PWM output.

  • Relay control pins and PWM outputs may not be correctly activated or sequenced.

I have tested a new STM32 board without programming, same issue persists, suggesting it’s not hardware damage but configuration.

Would appreciate help reviewing timer config, pin assignments, and software steps to properly initialize and start PWM on TIM1/TIM3 for reliable voltage output.

26 REPLIES 26
TDK
Super User

> the PWM output voltage is only around 2.7V instead of the expected 5V

Output voltage when the pin is high should be VDD, which is typically 3.3 V. It will never be 5 V. You can use a transistor if you need a 5 V output.

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Super User

@boulganamed wrote:

I am working on a project to replace a legacy ST62 IC in a industrial charger 24V/45A charger with an STM32 microcontroller (STM32F0 series). .


So was the legacy ST62 a 5V device?

As @TDK said, the STM32F0 are 3V - so you're going to have  to pay attention to that in all your interfaces...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

thanks for your reply:

but i used a card of stm32f030f4p6 like this :

boulganamed_0-1758722867345.jpeg

 

thanks for your reply:

but i used a card of stm32f030f4p6 like this :

boulganamed_0-1758722867345.jpeg

 

Note that everyone can see all replies - no need to repeat the same thing in multiple replies.

You can mention multiple people in one post using '@'

 


@boulganamed wrote:

but i used a card of stm32f030f4p6 like this 


That's not an ST board - please give full details - see: How to write your question to maximize your chances to find a solution

But the fact remains that the STM32 is a 3V microcontroller - so, unless that board contains voltage translators, you will still have to account for that ...

PS:

Zooming in, you can see that the header pins connect direct to the chip - there is no voltage translation:

AndrewNeil_0-1758728236370.png

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

I don't see how this changes anything. The microcontroller on that board is not operating at 5 V and can't output 5 V signals.

If you feel a post has answered your question, please click "Accept as Solution".
boulganamed
Associate

@TDK   @Andrew Neil 

When I connect the STM32F030F4P6 board to the charger, the chip outputs a 5V PWM signal on pin PA6, which is used to control the output voltage of 24V at 45A through the feedback on pin PA0. Currently, everything works fine with this setup. I now need to rework and adapt the firmware program to properly manage and regulate the output voltage.

Any advice or examples on how to implement effective output voltage control using PWM on PA6 and feedback on PA0 with STM32F030F4P6 would be greatly appreciated.

Thank you for your support!

> When I connect the STM32F030F4P6 board to the charger, the chip outputs a 5V PWM signal on pin PA6, ...

No, it does not. It can only output +3.3V

> Any advice or examples on how to implement effective output voltage control using PWM on PA6 and feedback on PA0 with STM32F030F4P6 would be greatly appreciated.

You cannot control the "effective output voltage" of a PWM.
The analogue property of a PWM is in it's pulse lengths and timing, not the signal levels.

Go back and re-read the responses you got.

You still haven't given any details of that board.

You need to post its schematic (or a link to it).

Again, please read How to write your question to maximize your chances to find a solution

 


@boulganamed wrote:

@TDK   @Andrew Neil 

When I connect the STM32F030F4P6 board to the charger, the chip outputs a 5V PWM signal on pin PA6!


Again, that's not true.

The STM32 is a 3.3V microcontroller - it cannot output any voltage higher than 3.3V.

Have you studied the STM32F030F4P6 datasheet?

https://www.st.com/resource/en/datasheet/stm32f030f4.pdf

To understand the PWM operation (and other peripherals), you will also need to study its Reference Manual:

https://www.st.com/resource/en/reference_manual/rm0360-stm32f030x4x6x8xc-and-stm32f070x6xb-advanced-armbased-32bit-mcus-stmicroelectronics.pdf

via: https://www.st.com/en/microcontrollers-microprocessors/stm32f030f4.html#documentation

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.