Controlling Rgb led using Timers in stm32
Hi, i am using Timers to control the intensity of a RGB LED. I need help with a code because I don't know why i have to do this thing.
I have these lines:
TIM1->CCR1 = Intensity; For Red Color
TIM1->CCR2 = Intensity; For green color
TIM1->CCR4 = Intensity; For blue color
but it doesn't work while calling
(&htim1, TIM_CHANNEL_4);
But if i do this:
// Set alternate output for CH2, disabling main output (no need of it because already disabled, but just in case)
CLEAR_BIT(TIM1->CCER, 1 << 4);
SET_BIT(TIM1->CCER, 1 << 6);
// Set alternate output for CH1, disabling main output (no need of last thing but whatever)
CLEAR_BIT(TIM1->CCER, 1 << 0);
SET_BIT(TIM1->CCER, 1 << 2);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4);
It starts working. This last code is not mine, this is why i am asking this. Why i have to use clear bit, and do this shifts? I have no idea with this.
Thank you so much.
