1506 views|2 replies

3180

Posts

0

Resources
The OP
 

External interrupt issues [Copy link]

I made a small board with CC2541, which has 10 buttons and a light.

Tried external interrupt, found that it sometimes worked and sometimes didn't, there was some erroneous operation.

The procedure is as follows:

/****************************************************** ***************************

* Name: InitKey()

* Function: Set the IO port corresponding to KEY, using interrupt mode

* Input parameters: None

* Export parameters: None

*************************************************** ******************************/

void InitKey()

{

P0IEN |= 0xf3; // P0.1 is set to interrupt mode 1: interrupt enable

PICTL |= 0xf3; // falling edge trigger

IEN1 |= 0x20; //Enable P0 port interrupt;

P0IFG = 0x00; // Initialize interrupt flag

P1IEN |= 0x0f; // P0.1 is set to interrupt mode 1: interrupt enable

PICTL |= 0x0f; //Falling edge trigger

IEN2 |= 0x10; //Enable P1 port interrupt;

P1IFG = 0x00; // Initialize interrupt flag

EA = 1; // Enable general interrupt

}

/****************************************************** ***************************

* Name: P0_ISR(void) interrupt processing function

* Description: #pragma vector = interrupt vector, followed by interrupt handler

*************************************************** ******************************/

#pragma vector = P0INT_VECTOR

__interrupt void P0_ISR(void)

{

DelayMS(20); //delay debounce

LED1 = ~LED1; //Change LED1 status

P0IFG = 0; // Clear interrupt flag

P0IF = 0; // Clear interrupt flag

}

/****************************************************** ***************************

* Name: P1_ISR(void) interrupt processing function

* Description: #pragma vector = interrupt vector, followed by interrupt handler

*************************************************** ******************************/

#pragma vector = P1INT_VECTOR

__interrupt void P1_ISR(void)

{

DelayMS(20); //delay debounce

LED1 = ~LED1; //Change LED1 status

P1IFG = 0; // Clear interrupt flag

P1IF = 0; // Clear interrupt flag

}

I have a 20ms delay, but it doesn't work. Can anyone tell me how to fix this? Thanks!

This post is from Wireless Connectivity

Latest reply

In the interrupt service program, first delay and eliminate jitter, then read the IO status of the interrupt, return the key value or judge it as interference, and finally allow the external interrupt again and return.   Details Published on 2019-9-9 13:59
Personal signature为江山踏坏了乌骓马,为社稷拉断了宝雕弓。
 

1w

Posts

142

Resources
2
 

In the interrupt service program, first delay and eliminate jitter, then read the IO status of the interrupt, return the key value or judge it as interference, and finally allow the external interrupt again and return.

This post is from Wireless Connectivity

Comments

Thanks! I'll try it.  Details Published on 2019-9-9 14:13
Personal signature上传了一些书籍资料,也许有你想要的:http://download.eeworld.com.cn/user/chunyang
 
 
 

3180

Posts

0

Resources
3
 
chunyang posted on 2019-9-9 13:59 In the interrupt service program, first delay and debounce, then read the IO status of the interrupt, return the key value or judge it as interference, and finally allow the external interrupt again and return.

Thanks! I'll try it.

This post is from Wireless Connectivity
Personal signature为江山踏坏了乌骓马,为社稷拉断了宝雕弓。
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list