This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

协议栈按键轮询方式如何使用,中断方式ok,轮询不通

协议栈按键轮询方式如何使用,中断方式ok,轮询不通

外部按键在P06

修改如下

#define HAL_KEY_SW_6_PORT     P0
#define HAL_KEY_SW_6_BIT    BV(6) //BV(1)
#define HAL_KEY_SW_6_SEL    P0SEL
#define HAL_KEY_SW_6_DIR    P0DIR

/* edge interrupt */
#define HAL_KEY_SW_6_EDGEBIT BV(0)
#define HAL_KEY_SW_6_EDGE HAL_KEY_FALLING_EDGE

#define HAL_KEY_SW_6_IEN     IEN1 /* CPU interrupt mask register */
#define HAL_KEY_SW_6_IENBIT     BV(5) /* Mask bit for all of Port_0 */
#define HAL_KEY_SW_6_ICTL      P0IEN /* Port Interrupt Control register */
#define HAL_KEY_SW_6_ICTLBIT     BV(6)//BV(1) /* P0IEN - P0.1 enable/disable bit */
#define HAL_KEY_SW_6_PXIFG     P0IFG

#define PUSH1_BV      BV(6)//BV(1)
#define PUSH1_SBIT    P0_6//P0_1

其他未修改,但是按下按键无法进入中断,

设置断点,系统可以进入轮询函数void HalKeyPoll (void)中

但是 在执行下列语句时,会直接return,将return注释掉,ok了,就变成了检测高电平

if (!Hal_KeyIntEnable)
{
if (keys == halKeySavedKeys)
{
/* Exit - since no keys have changed */
return;
}
/* Store the current keys for comparation next time */
halKeySavedKeys = keys;
}