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.

When I use the gpio interrupt, the connection will be broken?

I use the c2541 and simpleBLEperipheral as the peripheral device. I modify the default button interrupts,P0.0 and p0.1 to p1.2 and p1.3. Also the vector HAL_ISR_FUNCTION( halKeyPort0Isr, P1INT_VECTOR ).  When I press the button, it actually enters the halProcessKeyInterrupt function to deal with interrupts, but the connection is broken immediately. What's going on? I would appreciate it veru much if somebody could help. Here is my code about defination

#define HAL_KEY_SW_1_PORT P1
#define HAL_KEY_SW_1_BIT BV(2)
#define HAL_KEY_SW_1_SEL P1SEL
#define HAL_KEY_SW_1_DIR P1DIR

#define HAL_KEY_SW_2_PORT P1
#define HAL_KEY_SW_2_BIT BV(3)
#define HAL_KEY_SW_2_SEL P1SEL
#define HAL_KEY_SW_2_DIR P1DIR

#define HAL_KEY_SW_1_IEN IEN2 /* CPU interrupt mask register */
#define HAL_KEY_SW_1_ICTL P1IEN /* Port Interrupt Control register */
#define HAL_KEY_SW_1_ICTLBIT BV(2) /* P1IEN - P1.2 enable/disable bit */
#define HAL_KEY_SW_1_IENBIT BV(4) /* Mask bit for all of Port_0??? */
#define HAL_KEY_SW_1_PXIFG P1IFG /* Interrupt flag at source */

#define HAL_KEY_SW_2_IEN IEN2 /* CPU interrupt mask register */
#define HAL_KEY_SW_2_ICTL P1IEN /* Port Interrupt Control register */
#define HAL_KEY_SW_2_ICTLBIT BV(3) /* P0IEN - P1.3 enable/disable bit */
#define HAL_KEY_SW_2_IENBIT BV(4) /* Mask bit for all of Port_1 */
#define HAL_KEY_SW_2_PXIFG P1IFG /* Interrupt flag at source */

#define HAL_KEY_SW_1_EDGEBIT BV(0)

  • Since you use P1.2 and P1.3, you shouldn't use "HAL_ISR_FUNCTION( halKeyPort0Isr, P1INT_VECTOR )." It should be "HAL_ISR_FUNCTION( halKeyPort1Isr, P1INT_VECTOR )."

  • I think it doesn't matter. It's just a function name. Someone tells me it is usually caused by cpu interrupt registers, something like wrong configuration or not clear the interrupt flag. So he suggests me to check everything about interrupts and gpio registers. And I'm working on that. Thanks.