Question
STM32F4 PWM
Posted on December 05, 2014 at 19:08
Hello,
I'm trying to change the duty cycle of TIM1 in PWM Mode, but somehow my code is not working. void TIM1_CC_IRQHandler(void) { HAL_NVIC_ClearPendingIRQ(TIM1_CC_IRQn); HAL_TIM_IRQHandler(&htim1); cx++; if (cx>450) { cx=0; } TIM1->CCR1=cx; TIM1->CCR2=cx; TIM1->CCR3=cx; } If I remove the lines TIM1->CCR1=cx; TIM1->CCR2=cx; TIM1->CCR3=cx; the code works fine, but without changing the duty cycle of course. How can I change the duty cycle on the fly? Thanks