美文网首页
5. PWM Output

5. PWM Output

作者: T_K_233 | 来源:发表于2020-07-11 10:11 被阅读0次

针脚设置


image.png image.png image.png

时钟设置


image.png
/* USER CODE BEGIN PM */
void setPWM(TIM_HandleTypeDef *handler, uint32_t channel, double output) {
  __HAL_TIM_SET_COMPARE(handler, channel, (int) (output * 2240.) + 2932);
}
/* USER CODE END PM */

生成控制 Servo 的波宽,

40.67 Hz

宽 1.10ms ~ 2.0 ms


  /* USER CODE BEGIN 2 */

  HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
  /* USER CODE END 2 */
    /* USER CODE BEGIN 3 */
    double output = 0.0;
    setPWM(&htim1, TIM_CHANNEL_1, output);
  }
  /* USER CODE END 3 */

相关文章

网友评论

      本文标题:5. PWM Output

      本文链接:https://www.haomeiwen.com/subject/ejhkcktx.html