cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303 PWM generation TIM1_CH3

kristblo
Associate II

Hi,

I'm having trouble getting PWM output on my STM32F303. I'm using CubeMX for pin config, then generating for Make for use with VSCode on Ubuntu. TIM1_CH3 has been configured for PWM output on PC2, and TIM1_CH2 on PC1. CH2 works as expected, while CH3 seems dead as a doorknob other than picking up some noise from CH2. Same config for the two channels (could they even be different?), and I'm calling the starter functions as follows, shortly after the CubeMX-generated init function:

 

 

  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);//MTR2
  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);//MTR2

 

 

Any reasons for this to be happening? I noticed quite a few people have a problem with TIM1_CH3, but they always seem to do the initialization themselves, which I figured MX would do for me.

1 ACCEPTED SOLUTION

Accepted Solutions
kristblo
Associate II

After being stuck on this for far too long, I realised I wasn't writing to the CCR3 register for that timer when setting my duty cycle. For some reason I thought each channel had a unique set of CCRs, and reused some (evidently) poorly optimised code from a previous project. Cheers!

View solution in original post

1 REPLY 1
kristblo
Associate II

After being stuck on this for far too long, I realised I wasn't writing to the CCR3 register for that timer when setting my duty cycle. For some reason I thought each channel had a unique set of CCRs, and reused some (evidently) poorly optimised code from a previous project. Cheers!