2024-02-23 09:10 AM - edited 2024-02-23 09:12 AM
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.
Solved! Go to Solution.
2024-02-23 09:25 AM
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!
2024-02-23 09:25 AM
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!