2020-09-07 08:05 AM
2020-09-07 09:53 AM
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;
2020-09-07 09:53 AM
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;
2020-09-07 10:04 AM
https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h#L1342 if you must have a HAL incantation for this.
JW
2020-09-08 08:59 AM
thanks for your answer, it works!!
2020-09-08 08:59 AM
I've find the solution in the following reply. Thanks for your support.