Change PWM Frequency of STM Microcontrollers

Hi All,

I am currently working on a project in which I am using Infineon IXF, 007T driver, for running the BLDC Motor. Using Arduino as a microcontroller the setup works fine but the driving IC gets extremely hot after a few minutes. The reason is high switching loss and it is recommended to lower down the PWM frequency. Although the Arduino is set to a fixed PWM frequency of 32 K Hz, I lowered it to 4 kHz by changing the register’s value but it was causing electrical noise.

Now I am using STM32 Nucleuo F030R8 microcontroller but by default, the controller frequency is set to 1 kHz, by changing the driver.pwm_frequency the frequency remains the same. I am using Platform Io IDE.

I am new to STM to not familiar with their registers. Kindly, can someone help me with how to change the PWM frequency to 10 K Hz?

Many Thanks,
Moid Khan

Hey @MoidKhan!

So, by default when using the SimpleFOC you should have the pwm frequency of 25kHz for the stm32 devices.
Are you sure you’re using the stm32duino?
Which version are you using?

The Microcontroller I have is ST Nucleo-F030R8. I am using Platform IO IDE, for uploading and writing the code.


You’ll need to install the stm32 support for the stm32 devices based on GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino

I am not using the platformio so I’m not sure how to do it exactly :smiley:
But for the arduino ide it is very easy though.

Many Thanks. I will switch to STM32duino and will Run the code there.

When using platformIO, please also pay attention to add the option:

lib_archive = false

to your platformio.ini file.

1 Like

After switching to STM32duio, the code worked perfectly, Thanks

1 Like

Hey MoidKhan

I’m having the same issue, can you explain how to switch to STM32duio ?

Edit: I fixed it. For everyone else who runs into this issue:


lib_archive = false

into your platformio.ini and run a clean after that pwm should be settable

1 Like