以该框图为例:
- 选择引脚
- 配置参数
80MHz变为100Hz的配置
设置占空比 -
打开定时器
-
手动更改占空比
void keyb2_3_func() { if(key[1].single_flag==1) { pa6_duty+=10; if(pa6_duty>=100) { pa6_duty=10; } __HAL_TIM_SetCompare(&htim16,TIM_CHANNEL_1,pa6_duty); key[1].single_flag=0; char temp[20]; sprintf(temp," PA6=%d%% ",pa6_duty); LCD_DisplayStringLine(Line8,(u8*)temp); } if(key[2].single_flag==1) { pa7_duty+=10; if(pa7_duty>=100) { pa7_duty=10; } __HAL_TIM_SetCompare(&htim17,TIM_CHANNEL_1,pa7_duty); key[2].single_flag=0; char temp[20]; sprintf(temp," PA7=%d%% ",pa7_duty); LCD_DisplayStringLine(Line9,(u8*)temp); } }