Skip to content

Commit d3f8b9b

Browse files
committed
修复pwm初始化时,相应的时钟没有使能的问题
1 parent ff861d1 commit d3f8b9b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

bsp/stm32/libraries/HAL_Drivers/drv_pwm.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,6 @@ static rt_err_t stm32_hw_pwm_init(struct stm32_pwm *device)
323323
tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
324324
#endif
325325

326-
if (HAL_TIM_PWM_Init(tim) != HAL_OK)
327-
{
328-
LOG_E("%s pwm init failed", device->name);
329-
result = -RT_ERROR;
330-
goto __exit;
331-
}
332-
333326
if (HAL_TIM_Base_Init(tim) != HAL_OK)
334327
{
335328
LOG_E("%s time base init failed", device->name);
@@ -345,6 +338,13 @@ static rt_err_t stm32_hw_pwm_init(struct stm32_pwm *device)
345338
goto __exit;
346339
}
347340

341+
if (HAL_TIM_PWM_Init(tim) != HAL_OK)
342+
{
343+
LOG_E("%s pwm init failed", device->name);
344+
result = -RT_ERROR;
345+
goto __exit;
346+
}
347+
348348
master_config.MasterOutputTrigger = TIM_TRGO_RESET;
349349
master_config.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
350350
if (HAL_TIMEx_MasterConfigSynchronization(tim, &master_config) != HAL_OK)

0 commit comments

Comments
 (0)