参考阅读http://t.csdn.cn/XPF2q
参考视频:
点击查看【bilibili】
一些关键知识
for(pwmVal = 0; pwmVal <= 1000; pwmVal++)
{
__HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_1,pwmVal);
HAL_Delay(1);
}
for(pwmVal = 0; pwmVal <= 1000; pwmVal++)
{
__HAL_TIM_SetCompare(&htim3, TIM_CHANNEL_1,1000-pwmVal);
HAL_Delay(1);
}