2022-02-11 11:27 AM
I want to generate a PWM at ~76K Hz using the TIMER1 on an STM32F401 microcontroller.
To my understanding, because the timer 1 is clocked at 84 MHz, I need to configure the ARR to 1099. See the screenshot to see my detailed configuration.
## The problem: I observed a ~14.5 kHz on my logic analyzer.
I don't understand where this calling comes from. Do you have any idea?
## Config details
Here you can see which bus is connected to timer1
Here you can see my clock tree configurationHere you can see my PWM configuration
## Software version
CubeMx 6.4.0
Solved! Go to Solution.
2022-02-11 11:56 AM
So it's off by a factor of ~5.2.
84 MHz / 5.2 = 16 MHz, which is the HSI frequency.
Most likely your system clock is the default HSI and not what you have shown in the clock tree.
Perhaps clock initialization fails and is silently ignored.
Outputting MCO would confirm, but what you've shown is pretty conclusive in itself.
2022-02-11 11:56 AM
So it's off by a factor of ~5.2.
84 MHz / 5.2 = 16 MHz, which is the HSI frequency.
Most likely your system clock is the default HSI and not what you have shown in the clock tree.
Perhaps clock initialization fails and is silently ignored.
Outputting MCO would confirm, but what you've shown is pretty conclusive in itself.
2022-02-14 01:06 PM
You were right. For some reason, the SystemClock_Config was not called in the main.
Even after regenerating the project.
Thanks for your answer @TDK