Skip to main content
Associate II
Jul 12, 2025 11:10 PM UTC
Question

Unable to start PWM on STM32G491

I am unable to start a PWM signal on my Nucleo board --> I was not able to observe a signal on an oscilloscope.

Please see the following code and Cube configurations.

1) Is the following code all that is necessary to start a PWM on a channel (given it is configured correctly in IOC)?

2) I confirmed that I am connected to the right pin by toggling a GPIO prior to configuring for PWM

HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_1);
TIM2->CCR1 = 30;

Matthew47_0-1752361752604.png

 

This topic has been closed for replies.

3 replies

MHoll.2
Senior III
Jul 13, 2025 6:19 AM UTC

Difficult to help with this information.

Can You provide some aditional information ( .ioc file and if possible the code You are using)

waclawek.jan
Super User
Jul 13, 2025 8:00 AM UTC

Make sure you are observing the right pin and that there are no obstacles (e.g. solder bridge) to that signal on the board. 

Read out and check/post content of TIM and relevant GPIO registers.

JW

Matthew47Author
Associate II
Jul 13, 2025 6:34 PM UTC

I resolved my issue by grasping a better understanding of the following concepts

1) ARR (auto reload register), CCR, and counter period settings

In my case (without using a prescaler):

CLK / ARR (auto reload register) = PWM frequency

170MHz / 4096 = 41503.91KHz

2) I was mistakenly using the incorrect CCRx register. PWM CH1 should use CCR1, PWM CH2 should use CCR2, etc