46.1. PWM输出

46.1.1. 概述

pwm工程主要演示了如何配置几种不同类型的pwm波形并通过MCU的引脚进行输出。

  • 强制输出

  • 边沿对齐pwm

  • 失效模式

  • 中心对齐pwm

  • 中心对齐互补pwm

46.1.2. 配置

46.1.3. 运行现象

  • 上电后,通过示波器可依次观测到P0、P1输出高电平、低电平、边沿对齐PWM、中心对齐PWM、中心对齐互补PWM

  • 串口打印如下信息:

pwm example


>> Test force PWM output on P0 and P1
Output high
Output low

>> Generate edge aligned waveform
Two waveforms will be generated, PWM P0 is the target waveform
whose duty cycle will be updated from 0 - 100 and back to 0; PWM P1 is a reference

>> Generate edge aligned waveform and fault mode enable
Two waveforms will be generated, PWM P0 is the target waveform
whose duty cycle will be updated from 0 - 100 and back to 0; PWM P1 is a reference

>> Generate central aligned waveform
Two waveforms will be generated, PWM P0 is the target waveform
whose duty cycle will be updated from 0 - 100 and back to 0; PWM P1 is a reference

>> Generate central aligned waveform in pair
Two waveforms will be generated in pair, PWM P0 and P1 are target
waveforms whose duty cycle will be updated from 0 - 100 and back to 0
test done

备注

只依次输出一次PWM波形,如果需要再次观测波形,需要重新运行程序。