STM32F4 PWM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-12-05 10:08 AM
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
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-12-05 10:21 AM
Posted on December 05, 2014 at 19:21
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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-12-10 3:18 AM
Posted on December 10, 2014 at 12:18
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.
