소스 검색

[fix][stm32]修复输出高电平异常的问题

wdfk-prog 2 년 전
부모
커밋
aaf1abf25f
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      bsp/stm32/libraries/HAL_Drivers/drv_pwm.c

+ 3 - 2
bsp/stm32/libraries/HAL_Drivers/drv_pwm.c

@@ -278,9 +278,10 @@ static rt_err_t drv_pwm_set(TIM_HandleTypeDef *htim, struct rt_pwm_configuration
     {
         pulse = MIN_PULSE;
     }
-    else if (pulse > period)
+    /*To determine user input, output high level is required*/
+    else if (pulse >= period)
     {
-        pulse = period;
+        pulse = period + 1;
     }
     __HAL_TIM_SET_COMPARE(htim, channel, pulse - 1);