以該框圖為例:
- 選擇引腳
- 配置引數
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); } }