PDA

View Full Version : On Interrupt & Gie



yasser hassani
- 12th January 2008, 07:38
Hi
Suppose that I want to disable interrupts after ON INTERRUPT command.
I read below suggestion in a book:
We shuldn't disable interrupts after ON INTERRUPT command with clearing GIE because
clearing this bit declares to PBP that an interrupt's happened and PBP jumps to ISR.
Instead of above we should use INTCON=%10000000
IS it True? Why?
Regards.

Darrel Taylor
- 12th January 2008, 08:14
Hi yasser,

It's half right, and the solution is half wrong.

When using ON INTERRUPT, you can not "Disable" the interrupts by clearing the GIE bit. Clearing GIE tells PBP that an interrupt has occured.

In suggesting INTCON=%10000000, perhaps they were only considering the peripheral interrupt sources. Which means the global interrupts can still trigger.

For ON INTERRUPT, If you want to make sure interrupts can't happen in a section of code, you need to wrap DISABLE / ENABLE statements around the affected code.

Doing so also reduces the "Code Bloat" from checking interrupts in-between each and every line of code.
<br>

yasser hassani
- 12th January 2008, 08:37
Hi dear Darrel Taylor
Thank you very much for your really helpful reply.