参考阅读http://t.csdn.cn/XPF2q
参考视频:
点击查看【bilibili】

一些关键知识

image.png
image.png
image.png
f80d3b9d16995d66659f33292fe8751.jpg

  1. for(pwmVal = 0; pwmVal <= 1000; pwmVal++)
  2. {
  3. __HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_1,pwmVal);
  4. HAL_Delay(1);
  5. }
  6. for(pwmVal = 0; pwmVal <= 1000; pwmVal++)
  7. {
  8. __HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_1,1000-pwmVal);
  9. HAL_Delay(1);
  10. }