简体   繁体   English

stm32f446 使用dma控制PWM占空比时,PWM波有异常波形

[英]stm32f446 When using dma to control PWM duty cycle, the PWM wave has abnormal waveform

MCU: f446rct6 System: freertos Library: hal MCU:f446rct6 系统:freertos 库:hal

Program logic:程序逻辑:

  1. Initialize the timer to output the PWM wave and initialize the DMA and connect to the Capture/Compare register将定时器初始化为 output PWM 波并初始化 DMA 并连接到 Capture/Compare 寄存器
  2. Start the timer启动计时器
  3. When data needs to be updated, start a dma transmission当需要更新数据时,启动 dma 传输

Phenomenon: There is no problem with the frequency and duty cycle of the PWM wave, but a strange triangular waveform often appears in the first or second waveform of DMA transmission.现象:PWM波的频率和占空比没有问题,但是在DMA传输的第一个或第二个波形中经常会出现一个奇怪的三角波。

Ask everyone, do you encounter similar waveforms when using pwm?请问大家,大家在使用pwm的时候有没有遇到过类似的波形呢? Please give me a hint to locate this problem, thank you请给我一个提示来定位这个问题,谢谢

引脚的输出示波器迹线

Potential causes include:潜在原因包括:

  1. You're switching the pin to DAC mode (if your MCU has a DAC) and driving it with an increasing value.您正在将引脚切换到 DAC 模式(如果您的 MCU 有 DAC)并以增加的值驱动它。

  2. The pin is disabled, and what you see is the drift of the voltage on the pin's and probe's combined capacitance.该引脚被禁用,您看到的是引脚和探头组合电容上的电压漂移。

  3. You're inadvertently switching the PWM to a very high frequency and the scope is set to too low sample rate.您无意中将 PWM 切换到非常高的频率,并且 scope 的采样率设置得太低。 Make sure you set the scope to highest possible sample rate / sample depth / sampling length, and decrease the horizontal scale (ie decrease the time per division by 2x or 5x).确保将 scope 设置为最高可能的采样率/采样深度/采样长度,并减小水平刻度(即,将每格的时间减少 2 倍或 5 倍)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM