Skip to main content
Visitor II
February 23, 2024
Solved

STM32F303 PWM generation TIM1_CH3

  • February 23, 2024
  • 1 reply
  • 1073 views

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.

    This topic has been closed for replies.
    Best answer by kristblo

    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!

    1 reply

    kristbloAuthorAnswer
    Visitor II
    February 23, 2024

    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!