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.

zstack1.2HA ,按键到应用层问题!

问题:模块休眠后,使用按键唤醒第一次可以触发

        case KEY_CHANGE:

                zclSampleDoorLock_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
                break

     但在休眠之前再次使用按键,则无法触发。等休眠后,按键唤醒又可以触发。

    调试发现,在按键唤醒时在该函数

void HalKeyPoll (void)
{
uint8 keys = 0;
if(!(HAL_KEY_SW_7_PORT & HAL_KEY_SW_7_BIT)) // Key is active low
{
keys |= HAL_KEY_SW_7;
}

............

if (keys && (pHalKeyProcessFunction))
{

(pHalKeyProcessFunction) (keys, HAL_KEY_STATE_NORMAL);
}
Keys有时为0,有时不为0。为0

疑问:每次都给该IO一个高电平。可为什么,Keys的情况不同?

//-------------------------------------------------------------------------------

//以下是对该按键的部分配置

#define HAL_KEY_FALLING_EDGE 1

#define HAL_KEY_DEBOUNCE_VALUE 5

// SW_7 is at P1.3
#define HAL_KEY_SW_7_PORT P1 
#define HAL_KEY_SW_7_BIT BV(3) 
#define HAL_KEY_SW_7_SEL P1SEL 
#define HAL_KEY_SW_7_DIR P1DIR 

// edge interrupt
#define HAL_KEY_SW_7_EDGEBIT BV(1) 
#define HAL_KEY_SW_7_EDGE HAL_KEY_RISING_EDGE

// SW_7 interrupts
#define HAL_KEY_SW_7_IEN IEN2 // CPU interrupt mask register 
#define HAL_KEY_SW_7_IENBIT BV(4) // Mask bit for all of Port_1 
#define HAL_KEY_SW_7_ICTL P1IEN // Port Interrupt Control register 
#define HAL_KEY_SW_7_ICTLBIT BV(3) // P0IEN - P0.5 enable/disable bit 
#define HAL_KEY_SW_7_PXIFG P1IFG // Interrupt flag at source

//--------------------------------------------------------------------------------------------

void HalKeyConfig (bool interruptEnable, halKeyCBack_t cback)
{
/* Enable/Disable Interrupt or */
Hal_KeyIntEnable = interruptEnable;

/* Register the callback fucntion */
pHalKeyProcessFunction = cback;

/* Determine if interrupt is enable or not */
if (Hal_KeyIntEnable)
{
P1SEL &= ~0x08; 
P1DIR &= ~0x08; 
P1INP &= ~0x08; 
P2INP |= 0x40; 
//PICTL |= 0x80;
PICTL &= ~0x02; 
//PICTL |= 0x02; 
//-------------------------------------------------------
EA = 1; 
IEN2 |= 0x10; 
P1IFG = 0; 
P1IEN |= 0x08;
//---------------------------------------------------------------------------