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.

CC2530 进入中断清除了其他io口状态

rt,用simplicit 协议站,p20作为按键中断,进入按键中断之后其他io口状态不可用,表现为led及蜂鸣器不可用,i2c外设不可用,程序如下:

按键中断:

void BSP_InitKey()
{
  P2IEN = 0x01;         // P2.0 设置为中断方式 1:中断使能
  PICTL |= 0x08;         //下降沿触发   
  IEN2  |= 0x02;         //允许P2口中断; 
  P2IFG  = 0x00;         //初始化中断标志位
  EA = 1;                //打开中断
}

按键IRQ:

#pragma vector = P2INT_VECTOR
__interrupt void P2_ISR(void) 
{
  EA = 0 ;
  if(!KEY)          //按键中断
  {
    NWK_DELAY(100); //延时去抖       
    if(!KEY)        //按键中断
    {
      Key_flag = 1 ;
//      Reinit();
      BSP_InitI2C();
      Handle_Key();
    }  
  }   
  P2IFG &=0xFD;   //清中断标志
  P2IF = 0;       //清端口0中断标志
  EA = 1 ;
}#pragma vector = P2INT_VECTOR
__interrupt void P2_ISR(void) 
{
  EA = 0 ;
  if(!KEY)          //按键中断
  {
    NWK_DELAY(100); //延时去抖       
    if(!KEY)        //按键中断
    {
      Key_flag = 1 ;
      LED_ON('G');
    }  
  }   
  P2IFG &=0xFD;   //清中断标志
  P2IF = 0;       //清端口0中断标志
  EA = 1 ;
}

led初始化函数

void BSP_InitLeds()
{
  P1DIR |= 0x06 ; //P1_0 LED2 RED   OUTPUT
  LED_G = 0 ;
  LED_R = 0 ;
}