Skip to main content
Associate II
July 12, 2025
Question

Unable to start PWM on STM32G491

  • July 12, 2025
  • 3 replies
  • 298 views

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

 

3 replies

MHoll.2
Senior III
July 13, 2025

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
July 13, 2025

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
July 13, 2025

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