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.

按键端口更改出现了问题

Other Parts Discussed in Thread: CC2540

我想把按键SW1、SW2端口改成P1_1,所以就把一些原来的端口配置都改成了P1口和BIT(1),其他的地方都没有变,更改的程序如下所示:

/* CPU port interrupt */

#define HAL_KEY_CPU_PORT_1_IF P1IF

#define HAL_KEY_CPU_PORT_2_IF P2IF

#if defined ( CC2540_MINIDK )||( WEBEE_BOARD )

/* SW_1 is at P0.0 */

#define HAL_KEY_SW_1_PORT   P1

#define HAL_KEY_SW_1_BIT    BV(0)

#define HAL_KEY_SW_1_SEL    P1SEL

#define HAL_KEY_SW_1_DIR    P1DIR

/* SW_2 is at P0.1 */

#define HAL_KEY_SW_2_PORT   P1

#define HAL_KEY_SW_2_BIT    BV(1)

#define HAL_KEY_SW_2_SEL    P1SEL

#define HAL_KEY_SW_2_DIR    P1DIR

#define HAL_KEY_SW_1_IEN      IEN1  /* CPU interrupt mask register */

#define HAL_KEY_SW_1_ICTL     P1IEN /* Port Interrupt Control register */

#define HAL_KEY_SW_1_ICTLBIT  BV(0) /* P0IEN - P0.0 enable/disable bit */

#define HAL_KEY_SW_1_IENBIT   BV(5) /* Mask bit for all of Port_0 */

#define HAL_KEY_SW_1_PXIFG    P1IFG /* Interrupt flag at source */

#define HAL_KEY_SW_2_IEN      IEN1  /* CPU interrupt mask register */

#define HAL_KEY_SW_2_ICTL     P1IEN /* Port Interrupt Control register */

#define HAL_KEY_SW_2_ICTLBIT  BV(1) /* P0IEN - P0.1 enable/disable bit */

#define HAL_KEY_SW_2_IENBIT   BV(5) /* Mask bit for all of Port_0 */

#define HAL_KEY_SW_2_PXIFG    P1IFG /* Interrupt flag at source */

#define HAL_KEY_SW_1_EDGEBIT  BV(0)

 PICTL |= HAL_KEY_SW_1_EDGEBIT; /* Set the edge bit to set falling edge to give int */

是不是这样就可以了?但是我测试了一下,按下按键没什么反应,这个是怎么回事呢?求大神指点下,谢谢了