21ic问答首页 - KF32LS201
KF32LS201
11295396172020-12-01
为什么程序执行到 case100 后不会跳到case200 检测不到关机按键按下 求大佬讲解
void POWER_ON_OFF(void)
{
static uint8_t POWER_ON_OFF_STATUS = 0;
static uint32_t DET_COUNT = 0;
while(1)
{
switch(POWER_ON_OFF_STATUS)
{
case 0: // 开机检测
if(ONOFF_DET == 0)DET_COUNT ++;
else DET_COUNT = 0;
if(DET_COUNT > 10000)
{
GPIO_Set_Output_Data_Bits(POWER_LOCK_PORT,POWER_LOCK,Bit_SET);
GPIO_Set_Output_Data_Bits(LED1_PORT,LED1,Bit_RESET);
POWER_ON_OFF_STATUS =100;
DET_COUNT = 0;
}
break;
case 100:
if(ONOFF_DET == 0)DET_COUNT=0 ;
else DET_COUNT++;
if(DET_COUNT > 10000)
{
POWER_ON_OFF_STATUS = 200;
DET_COUNT = 0;
}
break;
case 200: //关机检测
if(ONOFF_DET == 0)DET_COUNT++;
else DET_COUNT=0;
if(DET_COUNT > 1000000)
{
GPIO_Set_Output_Data_Bits(POWER_LOCK_PORT,POWER_LOCK,Bit_SET);
GPIO_Set_Output_Data_Bits(LED1_PORT,LED1,Bit_RESET);
POWER_ON_OFF_STATUS = 250;
DET_COUNT = 0;
}
break;
case 250:
if(ONOFF_DET == 0)DET_COUNT = 0;
else DET_COUNT ++;
if(DET_COUNT > 100000)
{
POWER_ON_OFF_STATUS = 0;
DET_COUNT = 0;
}
break;
default:break;
}
}
}
搜索
void POWER_ON_OFF(void)
{
static uint8_t POWER_ON_OFF_STATUS = 0;
static uint32_t DET_COUNT = 0;
while(1)
{
switch(POWER_ON_OFF_STATUS)
{
case 0: // 开机检测
if(ONOFF_DET == 0)DET_COUNT ++;
else DET_COUNT = 0;
if(DET_COUNT > 10000)
{
GPIO_Set_Output_Data_Bits(POWER_LOCK_PORT,POWER_LOCK,Bit_SET);
GPIO_Set_Output_Data_Bits(LED1_PORT,LED1,Bit_RESET);
POWER_ON_OFF_STATUS =100;
DET_COUNT = 0;
}
break;
case 100:
if(ONOFF_DET == 0)DET_COUNT=0 ;
else DET_COUNT++;
if(DET_COUNT > 10000)
{
POWER_ON_OFF_STATUS = 200;
DET_COUNT = 0;
}
break;
case 200: //关机检测
if(ONOFF_DET == 0)DET_COUNT++;
else DET_COUNT=0;
if(DET_COUNT > 1000000)
{
GPIO_Set_Output_Data_Bits(POWER_LOCK_PORT,POWER_LOCK,Bit_SET);
GPIO_Set_Output_Data_Bits(LED1_PORT,LED1,Bit_RESET);
POWER_ON_OFF_STATUS = 250;
DET_COUNT = 0;
}
break;
case 250:
if(ONOFF_DET == 0)DET_COUNT = 0;
else DET_COUNT ++;
if(DET_COUNT > 100000)
{
POWER_ON_OFF_STATUS = 0;
DET_COUNT = 0;
}
break;
default:break;
}
}
}
搜索
复制
赞0
#define LED1_PORT GPIOB_SFR
#define POWER_LOCK GPIO_PIN_MASK_0 //PF0
#define POWER_LOCK_PORT GPIOF_SFR
#define POWER_DET GPIO_PIN_MASK_4 //PF4
#define POWER_DET_PORT GPIOF_SFR
#define ONOFF_DET GPIO_Read_Input_Data_Bit(POWER_DET_PORT,POWER_DET) //读取PF4的输入电平
管脚定义
搜索
评论
2020-12-02
赞0
评论
2020-12-01
用ChipON KungFu这个IDE,是不是哪里没弄好才不会跳的,帮看看,谢谢
赞0
看清楚点啊楼主问的是条件判断不会跳
评论
2020-12-01
赞0
评论
2020-12-01
您需要登录后才可以回复 登录 | 注册