2014-12-05 10:08 AM
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? Thanks2014-12-05 10:21 AM
Depends if you have it in immediate load mode, I'd probably opt to update them in the Update interrupt so you aren't trying to chase the edge as it advances.
HAL stuff, really can't help you with that. Ive posted some Servo PWM and other PWM examples using the Standard Peripheral Library to the forum.2014-12-10 03:18 AM
Hi Lucas,
Please refer to where similar question was asked. -Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.