ST ARM高级定时器PWM输出模式

338 阅读1分钟

1 PWM 4种主要输出模式

image.png

2 PWM输出

image.png

2.1 主函数

image.png

2.2 PWM输出模式实验

image.png

  • PWM2 | OCPolarity ->TIM_OCPOLARITY_HIGH
  • 当比较值固定为200 时,高电平占空比 = ((arr+1) – CCR1) / (arr+1) = (500-200)/500=60% image.png

3 互补PWM输出模式实验

image.png image.png

  • 设置输出比较值和死区时间的函数 image.png
  • atim_timx_cplm_pwm_set(300, 100) 这个语句,相当于设置捕获/比较寄存器的值为300,DTG[7:0]的值为 100。通过计算可以得到 PWM 的占空比为 70%,死区时间为 2.38us。 image.png
  • PWM1 | OCPolarity ->TIM_OCPOLARITY_LOW | OCNPolarity->TIM_OCPOLARITY_LOW image.png

3.1 实验分析

  • PWM1 | OCPolarity ->TIM_OCPOLARITY_LOW | OCNPolarity->TIM_OCPOLARITY_LOW image.png
  • 占空比计算 image.png
  • 实验现象 image.png image.png