2025-09-24 4:13 AM - last edited on 2025-09-24 5:57 AM by Andrew Neil
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.
2025-09-24 5:08 AM - edited 2025-09-24 5:08 AM
> 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.
2025-09-24 5:59 AM
@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...
2025-09-24 7:07 AM - edited 2025-09-24 7:08 AM
thanks for your reply:
but i used a card of stm32f030f4p6 like this :
2025-09-24 7:09 AM
thanks for your reply:
but i used a card of stm32f030f4p6 like this :
2025-09-24 8:35 AM - edited 2025-09-24 8:37 AM
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:
2025-09-24 8:41 AM
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.
2025-09-25 3:28 AM
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!
2025-09-25 3:57 AM
> 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.
2025-09-25 4:33 AM
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: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:
via: https://www.st.com/en/microcontrollers-microprocessors/stm32f030f4.html#documentation