[stm32] Fix Assertion Failure in HAL Library Due to Period=0 During PWM Initialization

Co-authored-by: wdfk-prog <1425075683@qq.com>
This commit is contained in:
wdfk-prog 2025-07-08 10:07:49 +08:00 committed by Rbb666
parent 3d72290b38
commit dc225f3f83
1 changed files with 1 additions and 1 deletions

View File

@ -374,7 +374,7 @@ static rt_err_t stm32_hw_pwm_init(struct stm32_pwm *device)
/* configure the timer to pwm mode */
tim->Init.Prescaler = 0;
tim->Init.CounterMode = TIM_COUNTERMODE_UP;
tim->Init.Period = 0;
tim->Init.Period = 1;
tim->Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32L4)
tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;