LPC1768 EINT0 & EINT2 unwanted interrupt call

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1768 EINT0 & EINT2 unwanted interrupt call

2,125 Views
mostafanfs
Contributor III

I'm working on LPC1768. I have enabled EINT0 and EINT2 interrupts both in falling-edge sensitive mode. This is the code :

LPC_PINCON->PINSEL4 |= (0x01 << 20); // function: EINT0
LPC_SC->EXTMODE |= 1 << 0; // Edge sensitive
LPC_SC->EXTPOLAR &= ~(1 << 0); // falling-edge sensitive

LPC_SC->EXTINT = (1 << 0);  // clear flag
NVIC_EnableIRQ(EINT0_IRQn);

LPC_PINCON->PINSEL4 |= (0x01 << 24); // function: EINT2
LPC_SC->EXTMODE |= 1 << 2; // Edge sensitive
LPC_SC->EXTPOLAR &= ~(1 << 2); // falling-edge sensitive
LPC_SC->EXTINT = (1 << 2);  // clear flag. not important
NVIC_EnableIRQ(EINT2_IRQn);

I have connected EINT0 to a push button switch and EINT2 to the RING output pin of a GSM module to know when a SMS has arrived. 

I have couple of problems. First after running above code it goes straight to the EINT2_IRQHandler (or sometimes EINT0_IRQHandler) while there has not been a signal (a falling edge situation) that would cause this. Now why is that? 

Another problem is that sometimes it goes to the EINT0_IRQHandler while the push button switch has not been pressed!

Or sometimes after turning on the GSM module and/or receiving a SMS (which generates a falling edge on RING pin connected to EINT2 after receiving a SMS) the EINT0_IRQHandler gets called!

I don't understand. Why there would be a connection between these two pins? There are two different and separate pins, right?

Have I done something wrong in the code? Or am I missing something? 

Labels (1)
0 Kudos
5 Replies

1,185 Views
mostafanfs
Contributor III

So guess what. I did put two capacitor on EINT0 and EINT2 pins and it turns out to be pretty useful cause now the number of false triggers are less than it used to be. Though there are still some false interrupts and I think I just have to use capacitors very closely to the pins and do other things you guys mentioned. 

I will keep this posted maybe someone learned something. 

0 Kudos

1,185 Views
pavelhudecek
Contributor III

GSM: A random interrupts may be EMC problem: A spikes from the module. You need better supply blocking, and/or RC filter on the way to the LPC. Other possible problems: Ground loops, uncorrect antenna coupling, ...

Button:It will be appreciated that unconnected=undefined. The button that no pressed is the unconnected wire, that can be read as 0 or 1 depending on the circumstances: A moving charged things around, weather, ...
To correct this, you must switch on internal pull-up, or connect the external pull-up resistor 1-100 kiloohms to +supply.

Many LPCs have the switchable filter, that can be enabled in IOCON. This is very useful for interrupts.

0 Kudos

1,185 Views
mostafanfs
Contributor III

Thank you. I'm beginning to think that it has something to do with the spikes related to the GSM module. BUT how come sometimes after calling or texting the module (which leads to making RING pin low for almost 120mS) I get interrupts in EINT0 instead of EINT2 which is actually connected to the RING pin?!  I mean if it has something to do with the spikes or EMC problems well it should trigger EINT2 interrupt whether first it has triggered EINT0 or not after all. Right?  

I'm scared that this is somehow related to the MCU behavior and not only the spikes. I'm not sure. Cause we didn't have this kind of behavior in AVR MCUs. I wish I had a scope to dig a little more in that. 

About pull-ups. Yeah there is pull-up resistor connected to the button. But no capacitors for now. 

I've never heard about switchable filters. I will look into that. 

Thank you. Any other advice is greatly appreciated. 

0 Kudos

1,185 Views
wernerf
Contributor II

Hi,

to me your code looks ok. What about the hardware you're running? Are you sure the signals on EINT0 and EINT2 inputs are perfectly free of spikes and glitches? The LPC can react on really short spikes very difficult to see on a scope. Have you got some capacitors close to the EINT inputs? What about the ground connection between the LPC and the GSM module?

0 Kudos

1,185 Views
mostafanfs
Contributor III

Well I don't have a scope right now so I'm not sure. I just don't expect there would be spikes and glitch! Apparently that's not enough!  

No I don't have any capacitors on those pins. I will try them. I suppose a 100nF would be enough. 

Well the ground connection is not very ideal if that's what you mean. both GNDs are connected together widely. It's not really my design I tell you that. 

But that's a good help. Good to know that interrupts in LPC are very sensitive. 

But I still couldn't figure it out how come the program goes directly to the EINT2_IRQHandler right after calling EINT2 interrupt setup? I mean what are the odds that there is a signal there every time after calling the interrupt setup. That's why I was wondering. 

0 Kudos