ENABLE command not always mandatory?


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891

    Default ENABLE command not always mandatory?

    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?

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

  2. #2
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    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.

Similar Threads

  1. Sleep Mode
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th March 2008, 11:31
  2. Enable and Disable in Interrupts
    By stevecrunch in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th October 2007, 02:10
  3. DMX512 Problem ..Schema+Code
    By programmer07 in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 21st March 2007, 16:39
  4. Can anyone help at getting OWIn & OWOut to work @ 16MHz?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th January 2006, 12:08
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 02:07

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts