Disable interrupt while interrupt is running?
Moderator: Benj
-
markus747
- Posts: 33
- Joined: Mon Jul 23, 2012 7:17 pm
- Location: Petaluma california USA
- Has thanked: 26 times
- Been thanked: 2 times
- Contact:
Disable interrupt while interrupt is running?
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
-
brandonb
- Posts: 438
- Joined: Mon Aug 29, 2011 12:26 am
- Location: arizona
- Has thanked: 175 times
- Been thanked: 173 times
Re: Disable interrupt while interrupt is running?
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Disable interrupt while interrupt is running?
Hello,
Clearing bit 1 can be done like this using a C icon.
GIE is not bit 1 so here is the code for the GIE bit.
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.
Clearing bit 1 can be done like this using a C icon.
Code: Select all
clear_bit(intcon, 1);Code: Select all
clear_bit(intcon, GIE);Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel