PDA

View Full Version : ENABLE command not always mandatory?



flotulopex
- 22nd October 2006, 15:07
Hello,

I have found a clock code sample to (try to) understand how interrupts work.

I can't find informations about the necessity of the "ENABLE" command.

Actually, the code I have doesn't state any ENABLE command after the subroutine (after the DISABLE) has been executed; only RESUME is there. And it works well.

Shall I understand that ENABLE is not mandatory?



...
DISABLE
SubRoutine:
...
RESUME
'I can state an ENABLE command here but it will change nothing to the program

ErnieM
- 23rd October 2006, 18:11
I can't find informations about the necessity of the "ENABLE" command.

Actually, it is there, under the ON INTERRUPT command. The short version is you’re correct, ENABLE is not necessary, as interrupts are enabled or disabled via explicit code that adjust the INTCON register. ENABLE is only necessary if 1) you have already used a DISABLE command and B) you want to start checking for them again.

Keep in mind that interrupts are normally (in asm) hardware driven events, but in PBP they are software driven (this isn't quite correct, but will suffice for now). This means that PBP inserts instructions to see if an interrupt event trigger has happened, and then goes off to handle it; this way PBP can save the current state of the machine.

In your code fragment you DISABLE before the subroutine, this simply means that PBP will stop checking for interrupts from that point in the code to the end. As long as the sub returns to code before this line the interrupt will work as expected.

Probably the best way to explain interrupts (if you still have questions) is for you post how you are doing your test, what you are inputing and what you expect to get out.