Created Tue, 16 Aug 2011 15:12:07 +0000 by python
Tue, 16 Aug 2011 15:12:07 +0000
I am developing an application and was using an external interrupt on one of the IO pin (pin35).
The problem i face is that when i disable and then re-enable back the external interrupt. I found that the interrupt service routine was called immediately without any sign of a falling edge on the pin.
I was troubleshooting but still cannot find a reason for it. Is there any issue using "DisableINT0" and "EnableINT0"? Or is there any missing steps that i need to do when i am enabling and disabling of the interrupt?
Tue, 16 Aug 2011 15:55:24 +0000
In a PIC processor the interrupt flags are affected whether or not the interrupt is enabled. Therefore an edge will set the interrupt flag any time before the EnableINT0 is called, once enabled it will immediately generate an interrupt because the interrupt flag is set. To make sure this doesn't happen you must manually clear the flag before you enable the interrupt. I can't remember where the flag is off the top of my head.
Wed, 17 Aug 2011 01:54:26 +0000
This is what i did before re-enabling back the external interrupt
But i still get the same problem. Did i call the wrong macro code?
Wed, 17 Aug 2011 12:08:31 +0000
I'm not sure, I don't know where that macro is defined, you could try:
IFS0CLR = _IFS0_INT0IF_MASK;