Solved
I'm using a STM32F429I discovery with HAL drivers. Is there a sample code showing how to change the duty cycle of a timer working in PWM output mode at run-time? Thanks, Piero
..
..
You can just change the CCRx register directly. I don't think HAL has a function for doing only this. Pretty sure the LL library does.
For 50% duty:
TIMx->CCRx = (TIMx->ARR + 1) / 2;
For 25%/75% duty:
TIMx->CCRx = (TIMx->ARR + 1) / 4;
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.