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

@Andrew Neil @TDK @Ozone 

Thank you all for your input and questions.

First, I would like to clarify that I do not have the schematic diagram of the charger or the ST62 IC part. I am not trying to hack or reverse engineer a commercial charger system. My goal is to undertake this project myself as a way to upgrade my skills in both hardware and software programming.

I am a mechatronics engineering technician from Morocco, seeking opportunities to explore and develop my skills internationally, particularly interested in working in the US or Asia.

Regarding my measurements, I always put the negative probe on the GND (VSS) and the positive probe on the pin under test, such as PA0.

I hope this clarifies my intentions and approach. Thanks again to everyone for the support and helpful discussions.

 


@boulganamed wrote:

@Andrew Neil @TDK @Ozone 

 I do not have the schematic diagram of the charger or the ST62 IC part.


So how can you possibly create an STM32 circuit which is equivalent to the old ST62-based design?

 


@boulganamed wrote:

I always put the negative probe on the GND (VSS) and the positive probe on the pin under test, such as PA0.


As has been said many times, If you're seeing anything higher than 3.3V at that point then something is seriously wrong.

An STM32 cannot generate an output at any pin which is higher than its supply voltage - in this case, 3.3V.

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.

this is role of charger ; 

  • State machine (STANDBY → SOFT_START → CHARGING → ERROR)
  • Force test mode - Hold reset button at startup to bypass all safety checks
  • Fixed PWM generation - Added missing timer start and ADC calibration
  • LED indicators (red/green/orange)
  • Relay control for soft-start and main power
  • ADC reading with 4x averaging
  • PWM regulation (10-90% duty cycle at 1kHz)

 

Andrew Neil
Super User

None of this helps use to understand the circuits in which you are using these chips.

That's what we need to see.

 

From those datasheets you can see that there's no way you'll get more than VDD out of any microcontroller pin.

AndrewNeil_0-1759144198419.png

 

So either your measurements are wrong, or you're going to blow the chips up!

 

BTW: It's better to go to the manufacturer's own website for documentation whenever possible.

For obsolete stuff like ST62 you may be stuck with 3rd-parties, but STM32 is current:

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

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.

> So either your measurements are wrong, or you're going to blow the chips up!

I got the impression the OP is a bit out his depth here...

Hello,

As I understood you need to replace a module that contains a very old ST MCU (ST6) family that generated a PWM signal with a STM32 MCU, is that correct?

From the ST6 datasheet, it says that VDD could be between 3V to 6V:

mALLEm_0-1759144646243.png

So are you sure that ST6 MCU is generating PWM at 5V level?

As said maybe by others, especially the last post of @Andrew Neil :you cannot in any case to exceed the VDD level on the all GPIOs. So you need to use voltage level shift technique. You can use transistors or SN74AHCT1G126: its VDD =5V and Its VIHmin = 2V that means it could be driven by a voltage of 3.3V (logic high without issue) and outputs 5V which could be a suitable solution for you.

See also this video may help you.

Hope that helps.

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.