cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to start PWM on STM32G491

Matthew47
Associate II

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 3
MHoll.2
Senior III

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

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

Matthew47
Associate II

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