修改如下
bit bBkpKey;
GENERAL_TIM_Mode_Config(CCR1_Val,CCR2_Val,CCR3_Val,CCR4_Val);
while(1)
{
bit bKey;
//检测按键按下
if(GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_3) == 0)
{
bKey = 1;
}
else
{
bKey = 0;
}
if (bKey && !bBkpKey)
{
CCR1_Val += 100; //CCR的值加100
//输出PWM
GENERAL_TIM_Mode_Config(CCR1_Val,CCR2_Val,CCR3_Val,CCR4_Val);
}
bBkpKey = bKey;
}
更多操作 |