51.1. 比较点匹配触发pwm

51.1.1. 概述

pwm 支持在周期内任意时刻去修改 pwm 波形。该工程展示了在周期内零点和重载点修改 pwm 波形并通过MCU相应引脚输出。

51.1.2. 配置

51.1.3. 运行

  • 上电后,通过示波器可以观察到三路输出,P0输出零点匹配触发,P2输出重载点匹配触发,P4输出中心对齐波形,用作参考波形。

  • P0 P2每输出10个波形后,在匹配点修改 PWM 输出波形

  • 串口打印如下信息:

pwmv2 point trigger example
choose PWM output channel [P0 P2 P4]


>> P0 and P2 generate pwm waveform P4 is reference
Modify the duty cycle at the midpoint when generating the 11th pulse
duty cycle will be updated from 0 - 100 and back to 0, the step size is 20%
  • 所得波形如图所示, 黄色为P0输出,粉色为P2输出,蓝色为P4输出

    波形图