Page 1 of 1

Disable interrupt while interrupt is running?

Posted: Wed Feb 13, 2013 7:14 pm
by markus747
I have been trying to prevent stack corruption and wonder if I need to disable interrupt for ( RB0 interrupt on change ) and if so how do I clear bit 1 in intcon register (10Bh) GIE

Re: Disable interrupt while interrupt is running?

Posted: Wed Feb 13, 2013 8:38 pm
by brandonb
what chip are you using?
when i set and clear bits i do it in a generic way for all compilers for instance to set bit 2 in t2con register
t2con|=1<<2;
to clear bit 2
t2con&=~1<<2;
if you look at bens tutorial on sleep function he shows how to do it in in a more eligant way
on your interrupt you can disable it with the icon, and if you want to do it in c drop in a icon and set it up for disable, then veiw the c code it generates, this should get you what you need to know, then look at datasheet to set and clear those bits,
sorry limited time

Re: Disable interrupt while interrupt is running?

Posted: Thu Feb 14, 2013 3:38 pm
by Benj
Hello,

Clearing bit 1 can be done like this using a C icon.

Code: Select all

clear_bit(intcon, 1);
GIE is not bit 1 so here is the code for the GIE bit.

Code: Select all

clear_bit(intcon, GIE);
So you know an interrupt cannot be re-triggered until after the interrupt macro has been completely processed and exited. Any interrupts which occur while the interrupt macro is being executed will be missed.